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 "utils/TuxBoxUtil.h"
43 #include "windowing/WindowingFactory.h"
44 #include "powermanagement/PowerManager.h"
45 #include "settings/AdvancedSettings.h"
46 #include "settings/Settings.h"
47 #include "guilib/LocalizeStrings.h"
48 #include "utils/CPUInfo.h"
49 #include "utils/StringUtils.h"
50 #include "utils/MathUtils.h"
51 #include "utils/SeekHandler.h"
53 #include "addons/Skin.h"
55 // stuff for current song
56 #include "music/MusicInfoLoader.h"
58 #include "GUIUserMessages.h"
59 #include "video/dialogs/GUIDialogVideoInfo.h"
60 #include "music/dialogs/GUIDialogMusicInfo.h"
61 #include "storage/MediaManager.h"
62 #include "utils/TimeUtils.h"
63 #include "threads/SingleLock.h"
64 #include "utils/log.h"
66 #include "pvr/PVRManager.h"
67 #include "pvr/channels/PVRChannelGroupsContainer.h"
68 #include "epg/EpgInfoTag.h"
69 #include "pvr/timers/PVRTimers.h"
70 #include "pvr/recordings/PVRRecording.h"
72 #include "addons/AddonManager.h"
73 #include "interfaces/info/InfoBool.h"
74 #include "video/VideoThumbLoader.h"
75 #include "music/MusicThumbLoader.h"
76 #include "video/VideoDatabase.h"
77 #include "cores/AudioEngine/Utils/AEUtil.h"
79 #define SYSHEATUPDATEINTERVAL 60000
82 using namespace XFILE;
83 using namespace MUSIC_INFO;
84 using namespace ADDON;
89 CGUIInfoManager::CGUIInfoManager(void) :
92 m_lastSysHeatInfoTime = -SYSHEATUPDATEINTERVAL; // make sure we grab CPU temp on the first pass
93 m_lastMusicBitrateTime = 0;
95 m_AfterSeekTimeout = 0;
97 m_playerSeeking = false;
98 m_performingSeek = false;
99 m_nextWindowID = WINDOW_INVALID;
100 m_prevWindowID = WINDOW_INVALID;
101 m_stringParameters.push_back("__ZZZZ__"); // to offset the string parameters by 1 to assure that all entries are non-zero
102 m_currentFile = new CFileItem;
103 m_currentSlide = new CFileItem;
108 m_playerShowTime = false;
109 m_playerShowCodec = false;
110 m_playerShowInfo = false;
115 CGUIInfoManager::~CGUIInfoManager(void)
117 delete m_currentFile;
118 delete m_currentSlide;
121 bool CGUIInfoManager::OnMessage(CGUIMessage &message)
123 if (message.GetMessage() == GUI_MSG_NOTIFY_ALL)
125 if (message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem())
127 CFileItemPtr item = boost::static_pointer_cast<CFileItem>(message.GetItem());
128 if (m_currentFile->IsSamePath(item.get()))
130 m_currentFile->UpdateInfo(*item);
138 /// \brief Translates a string as given by the skin into an int that we use for more
139 /// efficient retrieval of data. Can handle combined strings on the form
140 /// Player.Caching + VideoPlayer.IsFullscreen (Logical and)
141 /// Player.HasVideo | Player.HasAudio (Logical or)
142 int CGUIInfoManager::TranslateString(const CStdString &condition)
144 // translate $LOCALIZE as required
145 CStdString strCondition(CGUIInfoLabel::ReplaceLocalize(condition));
146 return TranslateSingleString(strCondition);
155 const infomap player_labels[] = {{ "hasmedia", PLAYER_HAS_MEDIA }, // bools from here
156 { "hasaudio", PLAYER_HAS_AUDIO },
157 { "hasvideo", PLAYER_HAS_VIDEO },
158 { "playing", PLAYER_PLAYING },
159 { "paused", PLAYER_PAUSED },
160 { "rewinding", PLAYER_REWINDING },
161 { "forwarding", PLAYER_FORWARDING },
162 { "rewinding2x", PLAYER_REWINDING_2x },
163 { "rewinding4x", PLAYER_REWINDING_4x },
164 { "rewinding8x", PLAYER_REWINDING_8x },
165 { "rewinding16x", PLAYER_REWINDING_16x },
166 { "rewinding32x", PLAYER_REWINDING_32x },
167 { "forwarding2x", PLAYER_FORWARDING_2x },
168 { "forwarding4x", PLAYER_FORWARDING_4x },
169 { "forwarding8x", PLAYER_FORWARDING_8x },
170 { "forwarding16x", PLAYER_FORWARDING_16x },
171 { "forwarding32x", PLAYER_FORWARDING_32x },
172 { "canrecord", PLAYER_CAN_RECORD },
173 { "recording", PLAYER_RECORDING },
174 { "displayafterseek", PLAYER_DISPLAY_AFTER_SEEK },
175 { "caching", PLAYER_CACHING },
176 { "seekbar", PLAYER_SEEKBAR },
177 { "seeking", PLAYER_SEEKING },
178 { "showtime", PLAYER_SHOWTIME },
179 { "showcodec", PLAYER_SHOWCODEC },
180 { "showinfo", PLAYER_SHOWINFO },
181 { "title", PLAYER_TITLE },
182 { "muted", PLAYER_MUTED },
183 { "hasduration", PLAYER_HASDURATION },
184 { "passthrough", PLAYER_PASSTHROUGH },
185 { "cachelevel", PLAYER_CACHELEVEL }, // labels from here
186 { "seekbar", PLAYER_SEEKBAR },
187 { "progress", PLAYER_PROGRESS },
188 { "progresscache", PLAYER_PROGRESS_CACHE },
189 { "volume", PLAYER_VOLUME },
190 { "subtitledelay", PLAYER_SUBTITLE_DELAY },
191 { "audiodelay", PLAYER_AUDIO_DELAY },
192 { "chapter", PLAYER_CHAPTER },
193 { "chaptercount", PLAYER_CHAPTERCOUNT },
194 { "chaptername", PLAYER_CHAPTERNAME },
195 { "starrating", PLAYER_STAR_RATING },
196 { "folderpath", PLAYER_PATH },
197 { "filenameandpath", PLAYER_FILEPATH },
198 { "pauseenabled", PLAYER_CAN_PAUSE },
199 { "seekenabled", PLAYER_CAN_SEEK }};
201 const infomap player_param[] = {{ "art", PLAYER_ITEM_ART }};
203 const infomap player_times[] = {{ "seektime", PLAYER_SEEKTIME },
204 { "seekoffset", PLAYER_SEEKOFFSET },
205 { "timeremaining", PLAYER_TIME_REMAINING },
206 { "timespeed", PLAYER_TIME_SPEED },
207 { "time", PLAYER_TIME },
208 { "duration", PLAYER_DURATION },
209 { "finishtime", PLAYER_FINISH_TIME },
210 { "starttime", PLAYER_START_TIME}};
212 const infomap weather[] = {{ "isfetched", WEATHER_IS_FETCHED },
213 { "conditions", WEATHER_CONDITIONS }, // labels from here
214 { "temperature", WEATHER_TEMPERATURE },
215 { "location", WEATHER_LOCATION },
216 { "fanartcode", WEATHER_FANART_CODE },
217 { "plugin", WEATHER_PLUGIN }};
219 const infomap system_labels[] = {{ "hasnetwork", SYSTEM_ETHERNET_LINK_ACTIVE },
220 { "hasmediadvd", SYSTEM_MEDIA_DVD },
221 { "dvdready", SYSTEM_DVDREADY },
222 { "trayopen", SYSTEM_TRAYOPEN },
223 { "haslocks", SYSTEM_HASLOCKS },
224 { "hasloginscreen", SYSTEM_HAS_LOGINSCREEN },
225 { "ismaster", SYSTEM_ISMASTER },
226 { "isfullscreen", SYSTEM_ISFULLSCREEN },
227 { "isstandalone", SYSTEM_ISSTANDALONE },
228 { "loggedon", SYSTEM_LOGGEDON },
229 { "showexitbutton", SYSTEM_SHOW_EXIT_BUTTON },
230 { "canpowerdown", SYSTEM_CAN_POWERDOWN },
231 { "cansuspend", SYSTEM_CAN_SUSPEND },
232 { "canhibernate", SYSTEM_CAN_HIBERNATE },
233 { "canreboot", SYSTEM_CAN_REBOOT },
234 { "screensaveractive",SYSTEM_SCREENSAVER_ACTIVE },
235 { "cputemperature", SYSTEM_CPU_TEMPERATURE }, // labels from here
236 { "cpuusage", SYSTEM_CPU_USAGE },
237 { "gputemperature", SYSTEM_GPU_TEMPERATURE },
238 { "fanspeed", SYSTEM_FAN_SPEED },
239 { "freespace", SYSTEM_FREE_SPACE },
240 { "usedspace", SYSTEM_USED_SPACE },
241 { "totalspace", SYSTEM_TOTAL_SPACE },
242 { "usedspacepercent", SYSTEM_USED_SPACE_PERCENT },
243 { "freespacepercent", SYSTEM_FREE_SPACE_PERCENT },
244 { "buildversion", SYSTEM_BUILD_VERSION },
245 { "builddate", SYSTEM_BUILD_DATE },
246 { "fps", SYSTEM_FPS },
247 { "dvdtraystate", SYSTEM_DVD_TRAY_STATE },
248 { "freememory", SYSTEM_FREE_MEMORY },
249 { "language", SYSTEM_LANGUAGE },
250 { "temperatureunits", SYSTEM_TEMPERATURE_UNITS },
251 { "screenmode", SYSTEM_SCREEN_MODE },
252 { "screenwidth", SYSTEM_SCREEN_WIDTH },
253 { "screenheight", SYSTEM_SCREEN_HEIGHT },
254 { "currentwindow", SYSTEM_CURRENT_WINDOW },
255 { "currentcontrol", SYSTEM_CURRENT_CONTROL },
256 { "dvdlabel", SYSTEM_DVD_LABEL },
257 { "internetstate", SYSTEM_INTERNET_STATE },
258 { "kernelversion", SYSTEM_KERNEL_VERSION },
259 { "uptime", SYSTEM_UPTIME },
260 { "totaluptime", SYSTEM_TOTALUPTIME },
261 { "cpufrequency", SYSTEM_CPUFREQUENCY },
262 { "screenresolution", SYSTEM_SCREEN_RESOLUTION },
263 { "videoencoderinfo", SYSTEM_VIDEO_ENCODER_INFO },
264 { "profilename", SYSTEM_PROFILENAME },
265 { "profilethumb", SYSTEM_PROFILETHUMB },
266 { "profilecount", SYSTEM_PROFILECOUNT },
267 { "progressbar", SYSTEM_PROGRESS_BAR },
268 { "batterylevel", SYSTEM_BATTERY_LEVEL },
269 { "friendlyname", SYSTEM_FRIENDLY_NAME },
270 { "alarmpos", SYSTEM_ALARM_POS },
271 { "isinhibit", SYSTEM_ISINHIBIT },
272 { "hasshutdown", SYSTEM_HAS_SHUTDOWN },
273 { "haspvr", SYSTEM_HAS_PVR }};
275 const infomap system_param[] = {{ "hasalarm", SYSTEM_HAS_ALARM },
276 { "hascoreid", SYSTEM_HAS_CORE_ID },
277 { "setting", SYSTEM_SETTING },
278 { "hasaddon", SYSTEM_HAS_ADDON },
279 { "coreusage", SYSTEM_GET_CORE_USAGE }};
281 const infomap network_labels[] = {{ "isdhcp", NETWORK_IS_DHCP },
282 { "ipaddress", NETWORK_IP_ADDRESS }, //labels from here
283 { "linkstate", NETWORK_LINK_STATE },
284 { "macaddress", NETWORK_MAC_ADDRESS },
285 { "subnetaddress", NETWORK_SUBNET_MASK }, //subnetaddress is misleading/wrong. should be deprecated. use subnetmask in stead
286 { "subnetmask", NETWORK_SUBNET_MASK },
287 { "gatewayaddress", NETWORK_GATEWAY_ADDRESS },
288 { "dns1address", NETWORK_DNS1_ADDRESS },
289 { "dns2address", NETWORK_DNS2_ADDRESS },
290 { "dhcpaddress", NETWORK_DHCP_ADDRESS }};
292 const infomap musicpartymode[] = {{ "enabled", MUSICPM_ENABLED },
293 { "songsplayed", MUSICPM_SONGSPLAYED },
294 { "matchingsongs", MUSICPM_MATCHINGSONGS },
295 { "matchingsongspicked", MUSICPM_MATCHINGSONGSPICKED },
296 { "matchingsongsleft", MUSICPM_MATCHINGSONGSLEFT },
297 { "relaxedsongspicked",MUSICPM_RELAXEDSONGSPICKED },
298 { "randomsongspicked", MUSICPM_RANDOMSONGSPICKED }};
300 const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE },
301 { "album", MUSICPLAYER_ALBUM },
302 { "artist", MUSICPLAYER_ARTIST },
303 { "albumartist", MUSICPLAYER_ALBUM_ARTIST },
304 { "year", MUSICPLAYER_YEAR },
305 { "genre", MUSICPLAYER_GENRE },
306 { "duration", MUSICPLAYER_DURATION },
307 { "tracknumber", MUSICPLAYER_TRACK_NUMBER },
308 { "cover", MUSICPLAYER_COVER },
309 { "bitrate", MUSICPLAYER_BITRATE },
310 { "playlistlength", MUSICPLAYER_PLAYLISTLEN },
311 { "playlistposition", MUSICPLAYER_PLAYLISTPOS },
312 { "channels", MUSICPLAYER_CHANNELS },
313 { "bitspersample", MUSICPLAYER_BITSPERSAMPLE },
314 { "samplerate", MUSICPLAYER_SAMPLERATE },
315 { "codec", MUSICPLAYER_CODEC },
316 { "discnumber", MUSICPLAYER_DISC_NUMBER },
317 { "rating", MUSICPLAYER_RATING },
318 { "comment", MUSICPLAYER_COMMENT },
319 { "lyrics", MUSICPLAYER_LYRICS },
320 { "playlistplaying", MUSICPLAYER_PLAYLISTPLAYING },
321 { "exists", MUSICPLAYER_EXISTS },
322 { "hasprevious", MUSICPLAYER_HASPREVIOUS },
323 { "hasnext", MUSICPLAYER_HASNEXT },
324 { "playcount", MUSICPLAYER_PLAYCOUNT },
325 { "lastplayed", MUSICPLAYER_LASTPLAYED },
326 { "channelname", MUSICPLAYER_CHANNEL_NAME },
327 { "channelnumber", MUSICPLAYER_CHANNEL_NUMBER },
328 { "channelgroup", MUSICPLAYER_CHANNEL_GROUP }
331 const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE },
332 { "genre", VIDEOPLAYER_GENRE },
333 { "country", VIDEOPLAYER_COUNTRY },
334 { "originaltitle", VIDEOPLAYER_ORIGINALTITLE },
335 { "director", VIDEOPLAYER_DIRECTOR },
336 { "year", VIDEOPLAYER_YEAR },
337 { "cover", VIDEOPLAYER_COVER },
338 { "usingoverlays", VIDEOPLAYER_USING_OVERLAYS },
339 { "isfullscreen", VIDEOPLAYER_ISFULLSCREEN },
340 { "hasmenu", VIDEOPLAYER_HASMENU },
341 { "playlistlength", VIDEOPLAYER_PLAYLISTLEN },
342 { "playlistposition", VIDEOPLAYER_PLAYLISTPOS },
343 { "plot", VIDEOPLAYER_PLOT },
344 { "plotoutline", VIDEOPLAYER_PLOT_OUTLINE },
345 { "episode", VIDEOPLAYER_EPISODE },
346 { "season", VIDEOPLAYER_SEASON },
347 { "rating", VIDEOPLAYER_RATING },
348 { "ratingandvotes", VIDEOPLAYER_RATING_AND_VOTES },
349 { "tvshowtitle", VIDEOPLAYER_TVSHOW },
350 { "premiered", VIDEOPLAYER_PREMIERED },
351 { "studio", VIDEOPLAYER_STUDIO },
352 { "mpaa", VIDEOPLAYER_MPAA },
353 { "top250", VIDEOPLAYER_TOP250 },
354 { "cast", VIDEOPLAYER_CAST },
355 { "castandrole", VIDEOPLAYER_CAST_AND_ROLE },
356 { "artist", VIDEOPLAYER_ARTIST },
357 { "album", VIDEOPLAYER_ALBUM },
358 { "writer", VIDEOPLAYER_WRITER },
359 { "tagline", VIDEOPLAYER_TAGLINE },
360 { "hasinfo", VIDEOPLAYER_HAS_INFO },
361 { "trailer", VIDEOPLAYER_TRAILER },
362 { "videocodec", VIDEOPLAYER_VIDEO_CODEC },
363 { "videoresolution", VIDEOPLAYER_VIDEO_RESOLUTION },
364 { "videoaspect", VIDEOPLAYER_VIDEO_ASPECT },
365 { "audiocodec", VIDEOPLAYER_AUDIO_CODEC },
366 { "audiochannels", VIDEOPLAYER_AUDIO_CHANNELS },
367 { "hasteletext", VIDEOPLAYER_HASTELETEXT },
368 { "lastplayed", VIDEOPLAYER_LASTPLAYED },
369 { "playcount", VIDEOPLAYER_PLAYCOUNT },
370 { "hassubtitles", VIDEOPLAYER_HASSUBTITLES },
371 { "subtitlesenabled", VIDEOPLAYER_SUBTITLESENABLED },
372 { "endtime", VIDEOPLAYER_ENDTIME },
373 { "nexttitle", VIDEOPLAYER_NEXT_TITLE },
374 { "nextgenre", VIDEOPLAYER_NEXT_GENRE },
375 { "nextplot", VIDEOPLAYER_NEXT_PLOT },
376 { "nextplotoutline", VIDEOPLAYER_NEXT_PLOT_OUTLINE },
377 { "nextstarttime", VIDEOPLAYER_NEXT_STARTTIME },
378 { "nextendtime", VIDEOPLAYER_NEXT_ENDTIME },
379 { "nextduration", VIDEOPLAYER_NEXT_DURATION },
380 { "channelname", VIDEOPLAYER_CHANNEL_NAME },
381 { "channelnumber", VIDEOPLAYER_CHANNEL_NUMBER },
382 { "channelgroup", VIDEOPLAYER_CHANNEL_GROUP },
383 { "hasepg", VIDEOPLAYER_HAS_EPG },
384 { "parentalrating", VIDEOPLAYER_PARENTAL_RATING }};
386 const infomap mediacontainer[] = {{ "hasfiles", CONTAINER_HASFILES },
387 { "hasfolders", CONTAINER_HASFOLDERS },
388 { "isstacked", CONTAINER_STACKED },
389 { "folderthumb", CONTAINER_FOLDERTHUMB },
390 { "tvshowthumb", CONTAINER_TVSHOWTHUMB },
391 { "seasonthumb", CONTAINER_SEASONTHUMB },
392 { "folderpath", CONTAINER_FOLDERPATH },
393 { "foldername", CONTAINER_FOLDERNAME },
394 { "pluginname", CONTAINER_PLUGINNAME },
395 { "viewmode", CONTAINER_VIEWMODE },
396 { "totaltime", CONTAINER_TOTALTIME },
397 { "hasthumb", CONTAINER_HAS_THUMB },
398 { "sortmethod", CONTAINER_SORT_METHOD },
399 { "showplot", CONTAINER_SHOWPLOT }};
401 const infomap container_bools[] ={{ "onnext", CONTAINER_MOVE_NEXT },
402 { "onprevious", CONTAINER_MOVE_PREVIOUS },
403 { "onscrollnext", CONTAINER_SCROLL_NEXT },
404 { "onscrollprevious", CONTAINER_SCROLL_PREVIOUS },
405 { "numpages", CONTAINER_NUM_PAGES },
406 { "numitems", CONTAINER_NUM_ITEMS },
407 { "currentpage", CONTAINER_CURRENT_PAGE },
408 { "scrolling", CONTAINER_SCROLLING },
409 { "hasnext", CONTAINER_HAS_NEXT },
410 { "hasprevious", CONTAINER_HAS_PREVIOUS },
411 { "canfilter", CONTAINER_CAN_FILTER },
412 { "canfilteradvanced",CONTAINER_CAN_FILTERADVANCED },
413 { "filtered", CONTAINER_FILTERED }};
415 const infomap container_ints[] = {{ "row", CONTAINER_ROW },
416 { "column", CONTAINER_COLUMN },
417 { "position", CONTAINER_POSITION },
418 { "subitem", CONTAINER_SUBITEM },
419 { "hasfocus", CONTAINER_HAS_FOCUS }};
421 const infomap container_str[] = {{ "property", CONTAINER_PROPERTY },
422 { "content", CONTAINER_CONTENT }};
424 const infomap listitem_labels[]= {{ "thumb", LISTITEM_THUMB },
425 { "icon", LISTITEM_ICON },
426 { "actualicon", LISTITEM_ACTUAL_ICON },
427 { "overlay", LISTITEM_OVERLAY },
428 { "label", LISTITEM_LABEL },
429 { "label2", LISTITEM_LABEL2 },
430 { "title", LISTITEM_TITLE },
431 { "tracknumber", LISTITEM_TRACKNUMBER },
432 { "artist", LISTITEM_ARTIST },
433 { "album", LISTITEM_ALBUM },
434 { "albumartist", LISTITEM_ALBUM_ARTIST },
435 { "year", LISTITEM_YEAR },
436 { "genre", LISTITEM_GENRE },
437 { "director", LISTITEM_DIRECTOR },
438 { "filename", LISTITEM_FILENAME },
439 { "filenameandpath", LISTITEM_FILENAME_AND_PATH },
440 { "fileextension", LISTITEM_FILE_EXTENSION },
441 { "date", LISTITEM_DATE },
442 { "size", LISTITEM_SIZE },
443 { "rating", LISTITEM_RATING },
444 { "ratingandvotes", LISTITEM_RATING_AND_VOTES },
445 { "programcount", LISTITEM_PROGRAM_COUNT },
446 { "duration", LISTITEM_DURATION },
447 { "isselected", LISTITEM_ISSELECTED },
448 { "isplaying", LISTITEM_ISPLAYING },
449 { "plot", LISTITEM_PLOT },
450 { "plotoutline", LISTITEM_PLOT_OUTLINE },
451 { "episode", LISTITEM_EPISODE },
452 { "season", LISTITEM_SEASON },
453 { "tvshowtitle", LISTITEM_TVSHOW },
454 { "premiered", LISTITEM_PREMIERED },
455 { "comment", LISTITEM_COMMENT },
456 { "path", LISTITEM_PATH },
457 { "foldername", LISTITEM_FOLDERNAME },
458 { "folderpath", LISTITEM_FOLDERPATH },
459 { "picturepath", LISTITEM_PICTURE_PATH },
460 { "pictureresolution",LISTITEM_PICTURE_RESOLUTION },
461 { "picturedatetime", LISTITEM_PICTURE_DATETIME },
462 { "picturecomment", LISTITEM_PICTURE_COMMENT },
463 { "picturecaption", LISTITEM_PICTURE_CAPTION },
464 { "picturedesc", LISTITEM_PICTURE_DESC },
465 { "picturekeywords", LISTITEM_PICTURE_KEYWORDS },
466 { "picturecammake", LISTITEM_PICTURE_CAM_MAKE },
467 { "picturecammodel", LISTITEM_PICTURE_CAM_MODEL },
468 { "pictureaperture", LISTITEM_PICTURE_APERTURE },
469 { "picturefocallen", LISTITEM_PICTURE_FOCAL_LEN },
470 { "picturefocusdist", LISTITEM_PICTURE_FOCUS_DIST },
471 { "pictureexpmode", LISTITEM_PICTURE_EXP_MODE },
472 { "pictureexptime", LISTITEM_PICTURE_EXP_TIME },
473 { "pictureiso", LISTITEM_PICTURE_ISO },
474 { "picturegpslat", LISTITEM_PICTURE_GPS_LAT },
475 { "picturegpslon", LISTITEM_PICTURE_GPS_LON },
476 { "picturegpsalt", LISTITEM_PICTURE_GPS_ALT },
477 { "studio", LISTITEM_STUDIO },
478 { "country", LISTITEM_COUNTRY },
479 { "mpaa", LISTITEM_MPAA },
480 { "cast", LISTITEM_CAST },
481 { "castandrole", LISTITEM_CAST_AND_ROLE },
482 { "writer", LISTITEM_WRITER },
483 { "tagline", LISTITEM_TAGLINE },
484 { "top250", LISTITEM_TOP250 },
485 { "trailer", LISTITEM_TRAILER },
486 { "starrating", LISTITEM_STAR_RATING },
487 { "sortletter", LISTITEM_SORT_LETTER },
488 { "videocodec", LISTITEM_VIDEO_CODEC },
489 { "videoresolution", LISTITEM_VIDEO_RESOLUTION },
490 { "videoaspect", LISTITEM_VIDEO_ASPECT },
491 { "audiocodec", LISTITEM_AUDIO_CODEC },
492 { "audiochannels", LISTITEM_AUDIO_CHANNELS },
493 { "audiolanguage", LISTITEM_AUDIO_LANGUAGE },
494 { "subtitlelanguage", LISTITEM_SUBTITLE_LANGUAGE },
495 { "isresumable", LISTITEM_IS_RESUMABLE},
496 { "percentplayed", LISTITEM_PERCENT_PLAYED},
497 { "isfolder", LISTITEM_IS_FOLDER },
498 { "originaltitle", LISTITEM_ORIGINALTITLE },
499 { "lastplayed", LISTITEM_LASTPLAYED },
500 { "playcount", LISTITEM_PLAYCOUNT },
501 { "discnumber", LISTITEM_DISC_NUMBER },
502 { "starttime", LISTITEM_STARTTIME },
503 { "endtime", LISTITEM_ENDTIME },
504 { "startdate", LISTITEM_STARTDATE },
505 { "enddate", LISTITEM_ENDDATE },
506 { "nexttitle", LISTITEM_NEXT_TITLE },
507 { "nextgenre", LISTITEM_NEXT_GENRE },
508 { "nextplot", LISTITEM_NEXT_PLOT },
509 { "nextplotoutline", LISTITEM_NEXT_PLOT_OUTLINE },
510 { "nextstarttime", LISTITEM_NEXT_STARTTIME },
511 { "nextendtime", LISTITEM_NEXT_ENDTIME },
512 { "nextstartdate", LISTITEM_NEXT_STARTDATE },
513 { "nextenddate", LISTITEM_NEXT_ENDDATE },
514 { "channelname", LISTITEM_CHANNEL_NAME },
515 { "channelnumber", LISTITEM_CHANNEL_NUMBER },
516 { "channelgroup", LISTITEM_CHANNEL_GROUP },
517 { "hasepg", LISTITEM_HAS_EPG },
518 { "hastimer", LISTITEM_HASTIMER },
519 { "isrecording", LISTITEM_ISRECORDING },
520 { "isencrypted", LISTITEM_ISENCRYPTED },
521 { "progress", LISTITEM_PROGRESS },
522 { "dateadded", LISTITEM_DATE_ADDED },
523 { "dbtype", LISTITEM_DBTYPE },
524 { "dbid", LISTITEM_DBID }};
526 const infomap visualisation[] = {{ "locked", VISUALISATION_LOCKED },
527 { "preset", VISUALISATION_PRESET },
528 { "name", VISUALISATION_NAME },
529 { "enabled", VISUALISATION_ENABLED }};
531 const infomap fanart_labels[] = {{ "color1", FANART_COLOR1 },
532 { "color2", FANART_COLOR2 },
533 { "color3", FANART_COLOR3 },
534 { "image", FANART_IMAGE }};
536 const infomap skin_labels[] = {{ "currenttheme", SKIN_THEME },
537 { "currentcolourtheme",SKIN_COLOUR_THEME },
538 {"hasvideooverlay", SKIN_HAS_VIDEO_OVERLAY},
539 {"hasmusicoverlay", SKIN_HAS_MUSIC_OVERLAY},
540 {"aspectratio", SKIN_ASPECT_RATIO}};
542 const infomap window_bools[] = {{ "ismedia", WINDOW_IS_MEDIA },
543 { "isactive", WINDOW_IS_ACTIVE },
544 { "istopmost", WINDOW_IS_TOPMOST },
545 { "isvisible", WINDOW_IS_VISIBLE },
546 { "previous", WINDOW_PREVIOUS },
547 { "next", WINDOW_NEXT }};
549 const infomap control_labels[] = {{ "hasfocus", CONTROL_HAS_FOCUS },
550 { "isvisible", CONTROL_IS_VISIBLE },
551 { "isenabled", CONTROL_IS_ENABLED },
552 { "getlabel", CONTROL_GET_LABEL }};
554 const infomap playlist[] = {{ "length", PLAYLIST_LENGTH },
555 { "position", PLAYLIST_POSITION },
556 { "random", PLAYLIST_RANDOM },
557 { "repeat", PLAYLIST_REPEAT },
558 { "israndom", PLAYLIST_ISRANDOM },
559 { "isrepeat", PLAYLIST_ISREPEAT },
560 { "isrepeatone", PLAYLIST_ISREPEATONE }};
562 const infomap pvr[] = {{ "isrecording", PVR_IS_RECORDING },
563 { "hastimer", PVR_HAS_TIMER },
564 { "hasnonrecordingtimer", PVR_HAS_NONRECORDING_TIMER },
565 { "nowrecordingtitle", PVR_NOW_RECORDING_TITLE },
566 { "nowrecordingdatetime", PVR_NOW_RECORDING_DATETIME },
567 { "nowrecordingchannel", PVR_NOW_RECORDING_CHANNEL },
568 { "nowrecordingchannelicon", PVR_NOW_RECORDING_CHAN_ICO },
569 { "nextrecordingtitle", PVR_NEXT_RECORDING_TITLE },
570 { "nextrecordingdatetime", PVR_NEXT_RECORDING_DATETIME },
571 { "nextrecordingchannel", PVR_NEXT_RECORDING_CHANNEL },
572 { "nextrecordingchannelicon", PVR_NEXT_RECORDING_CHAN_ICO },
573 { "backendname", PVR_BACKEND_NAME },
574 { "backendversion", PVR_BACKEND_VERSION },
575 { "backendhost", PVR_BACKEND_HOST },
576 { "backenddiskspace", PVR_BACKEND_DISKSPACE },
577 { "backendchannels", PVR_BACKEND_CHANNELS },
578 { "backendtimers", PVR_BACKEND_TIMERS },
579 { "backendrecordings", PVR_BACKEND_RECORDINGS },
580 { "backendnumber", PVR_BACKEND_NUMBER },
581 { "hasepg", PVR_HAS_EPG },
582 { "hastxt", PVR_HAS_TXT },
583 { "hasdirector", PVR_HAS_DIRECTOR },
584 { "totaldiscspace", PVR_TOTAL_DISKSPACE },
585 { "nexttimer", PVR_NEXT_TIMER },
586 { "isplayingtv", PVR_IS_PLAYING_TV },
587 { "isplayingradio", PVR_IS_PLAYING_RADIO },
588 { "isplayingrecording", PVR_IS_PLAYING_RECORDING },
589 { "duration", PVR_PLAYING_DURATION },
590 { "time", PVR_PLAYING_TIME },
591 { "progress", PVR_PLAYING_PROGRESS },
592 { "actstreamclient", PVR_ACTUAL_STREAM_CLIENT },
593 { "actstreamdevice", PVR_ACTUAL_STREAM_DEVICE },
594 { "actstreamstatus", PVR_ACTUAL_STREAM_STATUS },
595 { "actstreamsignal", PVR_ACTUAL_STREAM_SIG },
596 { "actstreamsnr", PVR_ACTUAL_STREAM_SNR },
597 { "actstreamber", PVR_ACTUAL_STREAM_BER },
598 { "actstreamunc", PVR_ACTUAL_STREAM_UNC },
599 { "actstreamvideobitrate", PVR_ACTUAL_STREAM_VIDEO_BR },
600 { "actstreamaudiobitrate", PVR_ACTUAL_STREAM_AUDIO_BR },
601 { "actstreamdolbybitrate", PVR_ACTUAL_STREAM_DOLBY_BR },
602 { "actstreamprogrsignal", PVR_ACTUAL_STREAM_SIG_PROGR },
603 { "actstreamprogrsnr", PVR_ACTUAL_STREAM_SNR_PROGR },
604 { "actstreamisencrypted", PVR_ACTUAL_STREAM_ENCRYPTED },
605 { "actstreamencryptionname", PVR_ACTUAL_STREAM_CRYPTION }};
607 const infomap slideshow[] = {{ "ispaused", SLIDESHOW_ISPAUSED },
608 { "isactive", SLIDESHOW_ISACTIVE },
609 { "israndom", SLIDESHOW_ISRANDOM }};
611 const int picture_slide_map[] = {/* LISTITEM_PICTURE_RESOLUTION => */ SLIDE_RESOLUTION,
612 /* LISTITEM_PICTURE_DATE => */ SLIDE_EXIF_DATE,
613 /* LISTITEM_PICTURE_DATETIME => */ SLIDE_EXIF_DATE_TIME,
614 /* LISTITEM_PICTURE_COMMENT => */ SLIDE_COMMENT,
615 /* LISTITEM_PICTURE_CAPTION => */ SLIDE_IPTC_CAPTION,
616 /* LISTITEM_PICTURE_DESC => */ SLIDE_EXIF_DESCRIPTION,
617 /* LISTITEM_PICTURE_KEYWORDS => */ SLIDE_IPTC_KEYWORDS,
618 /* LISTITEM_PICTURE_CAM_MAKE => */ SLIDE_EXIF_CAMERA_MAKE,
619 /* LISTITEM_PICTURE_CAM_MODEL => */ SLIDE_EXIF_CAMERA_MODEL,
620 /* LISTITEM_PICTURE_APERTURE => */ SLIDE_EXIF_APERTURE,
621 /* LISTITEM_PICTURE_FOCAL_LEN => */ SLIDE_EXIF_FOCAL_LENGTH,
622 /* LISTITEM_PICTURE_FOCUS_DIST => */ SLIDE_EXIF_FOCUS_DIST,
623 /* LISTITEM_PICTURE_EXP_MODE => */ SLIDE_EXIF_EXPOSURE_MODE,
624 /* LISTITEM_PICTURE_EXP_TIME => */ SLIDE_EXIF_EXPOSURE_TIME,
625 /* LISTITEM_PICTURE_ISO => */ SLIDE_EXIF_ISO_EQUIV,
626 /* LISTITEM_PICTURE_GPS_LAT => */ SLIDE_EXIF_GPS_LATITUDE,
627 /* LISTITEM_PICTURE_GPS_LON => */ SLIDE_EXIF_GPS_LONGITUDE,
628 /* LISTITEM_PICTURE_GPS_ALT => */ SLIDE_EXIF_GPS_ALTITUDE };
630 CGUIInfoManager::Property::Property(const CStdString &property, const CStdString ¶meters)
633 CUtil::SplitParams(parameters, params);
636 const CStdString &CGUIInfoManager::Property::param(unsigned int n /* = 0 */) const
638 if (n < params.size())
640 return StringUtils::EmptyString;
643 unsigned int CGUIInfoManager::Property::num_params() const
645 return params.size();
648 void CGUIInfoManager::SplitInfoString(const CStdString &infoString, vector<Property> &info)
650 // our string is of the form:
651 // category[(params)][.info(params).info2(params)] ...
652 // so we need to split on . while taking into account of () pairs
653 unsigned int parentheses = 0;
656 for (size_t i = 0; i < infoString.size(); ++i)
658 if (infoString[i] == '(')
663 else if (infoString[i] == ')')
666 CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
667 else if (!--parentheses)
670 else if (infoString[i] == '.' && !parentheses)
672 if (!property.IsEmpty()) // add our property and parameters
673 info.push_back(Property(property.ToLower(), param));
679 param += infoString[i];
681 property += infoString[i];
684 CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
685 if (!property.IsEmpty())
686 info.push_back(Property(property.ToLower(), param));
689 /// \brief Translates a string as given by the skin into an int that we use for more
690 /// efficient retrieval of data.
691 int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
694 CStdString strTest = strCondition;
695 strTest.TrimLeft(" \t\r\n");
696 strTest.TrimRight(" \t\r\n");
698 vector< Property> info;
699 SplitInfoString(strTest, info);
704 const Property &cat = info[0];
705 if (info.size() == 1)
707 if (cat.name == "false" || cat.name == "no" || cat.name == "off")
708 return SYSTEM_ALWAYS_FALSE;
709 else if (cat.name == "true" || cat.name == "yes" || cat.name == "on")
710 return SYSTEM_ALWAYS_TRUE;
711 if (cat.name == "isempty" && cat.num_params() == 1)
712 return AddMultiInfo(GUIInfo(STRING_IS_EMPTY, TranslateSingleString(cat.param())));
713 else if (cat.name == "stringcompare" && cat.num_params() == 2)
715 int info = TranslateSingleString(cat.param(0));
716 int info2 = TranslateSingleString(cat.param(1));
718 return AddMultiInfo(GUIInfo(STRING_COMPARE, info, -info2));
719 // pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
720 CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)).ToLower();
721 int compareString = ConditionalStringParameter(label);
722 return AddMultiInfo(GUIInfo(STRING_COMPARE, info, compareString));
724 else if (cat.name == "integergreaterthan" && cat.num_params() == 2)
726 int info = TranslateSingleString(cat.param(0));
727 int compareInt = atoi(cat.param(1).c_str());
728 return AddMultiInfo(GUIInfo(INTEGER_GREATER_THAN, info, compareInt));
730 else if (cat.name == "substring" && cat.num_params() >= 2)
732 int info = TranslateSingleString(cat.param(0));
733 CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)).ToLower();
734 int compareString = ConditionalStringParameter(label);
735 if (cat.num_params() > 2)
737 if (cat.param(2).CompareNoCase("left") == 0)
738 return AddMultiInfo(GUIInfo(STRING_STR_LEFT, info, compareString));
739 else if (cat.param(2).CompareNoCase("right") == 0)
740 return AddMultiInfo(GUIInfo(STRING_STR_RIGHT, info, compareString));
742 return AddMultiInfo(GUIInfo(STRING_STR, info, compareString));
745 else if (info.size() == 2)
747 const Property &prop = info[1];
748 if (cat.name == "player")
750 for (size_t i = 0; i < sizeof(player_labels) / sizeof(infomap); i++)
752 if (prop.name == player_labels[i].str)
753 return player_labels[i].val;
755 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++)
757 if (prop.name == player_times[i].str)
758 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
760 if (prop.num_params() == 1)
762 for (size_t i = 0; i < sizeof(player_param) / sizeof(infomap); i++)
764 if (prop.name == player_param[i].str)
765 return AddMultiInfo(GUIInfo(player_param[i].val, ConditionalStringParameter(prop.param())));
769 else if (cat.name == "weather")
771 for (size_t i = 0; i < sizeof(weather) / sizeof(infomap); i++)
773 if (prop.name == weather[i].str)
774 return weather[i].val;
777 else if (cat.name == "network")
779 for (size_t i = 0; i < sizeof(network_labels) / sizeof(infomap); i++)
781 if (prop.name == network_labels[i].str)
782 return network_labels[i].val;
785 else if (cat.name == "musicpartymode")
787 for (size_t i = 0; i < sizeof(musicpartymode) / sizeof(infomap); i++)
789 if (prop.name == musicpartymode[i].str)
790 return musicpartymode[i].val;
793 else if (cat.name == "system")
795 for (size_t i = 0; i < sizeof(system_labels) / sizeof(infomap); i++)
797 if (prop.name == system_labels[i].str)
798 return system_labels[i].val;
800 if (prop.num_params() == 1)
802 const CStdString ¶m = prop.param();
803 if (prop.name == "getbool")
805 std::string paramCopy = param;
806 StringUtils::ToLower(paramCopy);
807 return AddMultiInfo(GUIInfo(SYSTEM_GET_BOOL, ConditionalStringParameter(paramCopy, true)));
809 for (size_t i = 0; i < sizeof(system_param) / sizeof(infomap); i++)
811 if (prop.name == system_param[i].str)
812 return AddMultiInfo(GUIInfo(system_param[i].val, ConditionalStringParameter(param)));
814 if (prop.name == "memory")
816 if (param == "free") return SYSTEM_FREE_MEMORY;
817 else if (param == "free.percent") return SYSTEM_FREE_MEMORY_PERCENT;
818 else if (param == "used") return SYSTEM_USED_MEMORY;
819 else if (param == "used.percent") return SYSTEM_USED_MEMORY_PERCENT;
820 else if (param == "total") return SYSTEM_TOTAL_MEMORY;
822 else if (prop.name == "addontitle")
824 int infoLabel = TranslateSingleString(param);
826 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, infoLabel, 0));
827 CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
828 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, ConditionalStringParameter(label), 1));
830 else if (prop.name == "addonicon")
832 int infoLabel = TranslateSingleString(param);
834 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, infoLabel, 0));
835 CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
836 return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, ConditionalStringParameter(label), 1));
838 else if (prop.name == "idletime")
839 return AddMultiInfo(GUIInfo(SYSTEM_IDLE_TIME, atoi(param.c_str())));
841 if (prop.name == "alarmlessorequal" && prop.num_params() == 2)
842 return AddMultiInfo(GUIInfo(SYSTEM_ALARM_LESS_OR_EQUAL, ConditionalStringParameter(prop.param(0)), ConditionalStringParameter(prop.param(1))));
843 else if (prop.name == "date")
845 if (prop.num_params() == 2)
846 return AddMultiInfo(GUIInfo(SYSTEM_DATE, StringUtils::DateStringToYYYYMMDD(prop.param(0)) % 10000, StringUtils::DateStringToYYYYMMDD(prop.param(1)) % 10000));
847 else if (prop.num_params() == 1)
849 int dateformat = StringUtils::DateStringToYYYYMMDD(prop.param(0));
850 if (dateformat <= 0) // not concrete date
851 return AddMultiInfo(GUIInfo(SYSTEM_DATE, ConditionalStringParameter(prop.param(0), true), -1));
853 return AddMultiInfo(GUIInfo(SYSTEM_DATE, dateformat % 10000));
857 else if (prop.name == "time")
859 if (prop.num_params() == 0)
860 return AddMultiInfo(GUIInfo(SYSTEM_TIME, TIME_FORMAT_GUESS));
861 if (prop.num_params() == 1)
863 TIME_FORMAT timeFormat = TranslateTimeFormat(prop.param(0));
864 if (timeFormat == TIME_FORMAT_GUESS)
865 return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0))));
866 return AddMultiInfo(GUIInfo(SYSTEM_TIME, timeFormat));
869 return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0)), StringUtils::TimeStringToSeconds(prop.param(1))));
872 else if (cat.name == "library")
874 if (prop.name == "isscanning") return LIBRARY_IS_SCANNING;
875 else if (prop.name == "isscanningvideo") return LIBRARY_IS_SCANNING_VIDEO; // TODO: change to IsScanning(Video)
876 else if (prop.name == "isscanningmusic") return LIBRARY_IS_SCANNING_MUSIC;
877 else if (prop.name == "hascontent" && prop.num_params())
879 CStdString cat = prop.param(0); cat.ToLower();
880 if (cat == "music") return LIBRARY_HAS_MUSIC;
881 else if (cat == "video") return LIBRARY_HAS_VIDEO;
882 else if (cat == "movies") return LIBRARY_HAS_MOVIES;
883 else if (cat == "tvshows") return LIBRARY_HAS_TVSHOWS;
884 else if (cat == "musicvideos") return LIBRARY_HAS_MUSICVIDEOS;
885 else if (cat == "moviesets") return LIBRARY_HAS_MOVIE_SETS;
888 else if (cat.name == "musicplayer")
890 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
892 if (prop.name == player_times[i].str)
893 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
895 if (prop.name == "property")
897 if (prop.param().Equals("fanart_image"))
898 return AddMultiInfo(GUIInfo(PLAYER_ITEM_ART, ConditionalStringParameter("fanart")));
899 return AddListItemProp(prop.param(), MUSICPLAYER_PROPERTY_OFFSET);
901 return TranslateMusicPlayerString(prop.name);
903 else if (cat.name == "videoplayer")
905 for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
907 if (prop.name == player_times[i].str)
908 return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
910 if (prop.name == "content" && prop.num_params())
911 return AddMultiInfo(GUIInfo(VIDEOPLAYER_CONTENT, ConditionalStringParameter(prop.param()), 0));
912 for (size_t i = 0; i < sizeof(videoplayer) / sizeof(infomap); i++)
914 if (prop.name == videoplayer[i].str)
915 return videoplayer[i].val;
918 else if (cat.name == "slideshow")
920 for (size_t i = 0; i < sizeof(slideshow) / sizeof(infomap); i++)
922 if (prop.name == slideshow[i].str)
923 return slideshow[i].val;
925 return CPictureInfoTag::TranslateString(prop.name);
927 else if (cat.name == "container")
929 for (size_t i = 0; i < sizeof(mediacontainer) / sizeof(infomap); i++) // these ones don't have or need an id
931 if (prop.name == mediacontainer[i].str)
932 return mediacontainer[i].val;
934 int id = atoi(cat.param().c_str());
935 for (size_t i = 0; i < sizeof(container_bools) / sizeof(infomap); i++) // these ones can have an id (but don't need to?)
937 if (prop.name == container_bools[i].str)
938 return id ? AddMultiInfo(GUIInfo(container_bools[i].val, id)) : container_bools[i].val;
940 for (size_t i = 0; i < sizeof(container_ints) / sizeof(infomap); i++) // these ones can have an int param on the property
942 if (prop.name == container_ints[i].str)
943 return AddMultiInfo(GUIInfo(container_ints[i].val, id, atoi(prop.param().c_str())));
945 for (size_t i = 0; i < sizeof(container_str) / sizeof(infomap); i++) // these ones have a string param on the property
947 if (prop.name == container_str[i].str)
948 return AddMultiInfo(GUIInfo(container_str[i].val, id, ConditionalStringParameter(prop.param())));
950 if (prop.name == "sortdirection")
952 SortOrder order = SortOrderNone;
953 if (prop.param().Equals("ascending"))
954 order = SortOrderAscending;
955 else if (prop.param().Equals("descending"))
956 order = SortOrderDescending;
957 return AddMultiInfo(GUIInfo(CONTAINER_SORT_DIRECTION, order));
959 else if (prop.name == "sort")
961 SORT_METHOD sort = SORT_METHOD_NONE;
962 if (prop.param().Equals("songrating")) sort = SORT_METHOD_SONG_RATING;
963 if (sort != SORT_METHOD_NONE)
964 return AddMultiInfo(GUIInfo(CONTAINER_SORT_METHOD, sort));
967 else if (cat.name == "listitem")
969 int offset = atoi(cat.param().c_str());
970 int ret = TranslateListItem(prop);
971 if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
972 return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_WRAP));
975 else if (cat.name == "listitemposition")
977 int offset = atoi(cat.param().c_str());
978 int ret = TranslateListItem(prop);
979 if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
980 return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_POSITION));
983 else if (cat.name == "listitemnowrap")
985 int offset = atoi(cat.param().c_str());
986 int ret = TranslateListItem(prop);
987 if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
988 return AddMultiInfo(GUIInfo(ret, 0, offset));
991 else if (cat.name == "visualisation")
993 for (size_t i = 0; i < sizeof(visualisation) / sizeof(infomap); i++)
995 if (prop.name == visualisation[i].str)
996 return visualisation[i].val;
999 else if (cat.name == "fanart")
1001 for (size_t i = 0; i < sizeof(fanart_labels) / sizeof(infomap); i++)
1003 if (prop.name == fanart_labels[i].str)
1004 return fanart_labels[i].val;
1007 else if (cat.name == "skin")
1009 for (size_t i = 0; i < sizeof(skin_labels) / sizeof(infomap); i++)
1011 if (prop.name == skin_labels[i].str)
1012 return skin_labels[i].val;
1014 if (prop.num_params())
1016 if (prop.name == "string")
1018 if (prop.num_params() == 2)
1019 return AddMultiInfo(GUIInfo(SKIN_STRING, g_settings.TranslateSkinString(prop.param(0)), ConditionalStringParameter(prop.param(1))));
1021 return AddMultiInfo(GUIInfo(SKIN_STRING, g_settings.TranslateSkinString(prop.param(0))));
1023 if (prop.name == "hassetting")
1024 return AddMultiInfo(GUIInfo(SKIN_BOOL, g_settings.TranslateSkinBool(prop.param(0))));
1025 else if (prop.name == "hastheme")
1026 return AddMultiInfo(GUIInfo(SKIN_HAS_THEME, ConditionalStringParameter(prop.param(0))));
1029 else if (cat.name == "window")
1031 if (prop.name == "property" && prop.num_params() == 1)
1032 { // TODO: this doesn't support foo.xml
1033 int winID = cat.param().IsEmpty() ? 0 : CButtonTranslator::TranslateWindow(cat.param());
1034 if (winID != WINDOW_INVALID)
1035 return AddMultiInfo(GUIInfo(WINDOW_PROPERTY, winID, ConditionalStringParameter(prop.param())));
1037 for (size_t i = 0; i < sizeof(window_bools) / sizeof(infomap); i++)
1039 if (prop.name == window_bools[i].str)
1040 { // TODO: The parameter for these should really be on the first not the second property
1041 if (prop.param().Find("xml") >= 0)
1042 return AddMultiInfo(GUIInfo(window_bools[i].val, 0, ConditionalStringParameter(prop.param())));
1043 int winID = prop.param().IsEmpty() ? 0 : CButtonTranslator::TranslateWindow(prop.param());
1044 if (winID != WINDOW_INVALID)
1045 return AddMultiInfo(GUIInfo(window_bools[i].val, winID, 0));
1050 else if (cat.name == "control")
1052 for (size_t i = 0; i < sizeof(control_labels) / sizeof(infomap); i++)
1054 if (prop.name == control_labels[i].str)
1055 { // TODO: The parameter for these should really be on the first not the second property
1056 int controlID = atoi(prop.param().c_str());
1058 return AddMultiInfo(GUIInfo(control_labels[i].val, controlID, 0));
1063 else if (cat.name == "controlgroup" && prop.name == "hasfocus")
1065 int groupID = atoi(cat.param().c_str());
1067 return AddMultiInfo(GUIInfo(CONTROL_GROUP_HAS_FOCUS, groupID, atoi(prop.param(0).c_str())));
1069 else if (cat.name == "playlist")
1071 for (size_t i = 0; i < sizeof(playlist) / sizeof(infomap); i++)
1073 if (prop.name == playlist[i].str)
1074 return playlist[i].val;
1077 else if (cat.name == "pvr")
1079 for (size_t i = 0; i < sizeof(pvr) / sizeof(infomap); i++)
1081 if (prop.name == pvr[i].str)
1086 else if (info.size() == 3)
1088 if (info[0].name == "system" && info[1].name == "platform")
1089 { // TODO: replace with a single system.platform
1090 CStdString platform = info[2].name;
1091 if (platform == "linux") return SYSTEM_PLATFORM_LINUX;
1092 else if (platform == "windows") return SYSTEM_PLATFORM_WINDOWS;
1093 else if (platform == "darwin") return SYSTEM_PLATFORM_DARWIN;
1094 else if (platform == "osx") return SYSTEM_PLATFORM_DARWIN_OSX;
1095 else if (platform == "ios") return SYSTEM_PLATFORM_DARWIN_IOS;
1096 else if (platform == "atv2") return SYSTEM_PLATFORM_DARWIN_ATV2;
1097 else if (platform == "android") return SYSTEM_PLATFORM_ANDROID;
1099 if (info[0].name == "musicplayer")
1100 { // TODO: these two don't allow duration(foo) and also don't allow more than this number of levels...
1101 if (info[1].name == "position")
1103 int position = atoi(info[1].param().c_str());
1104 int value = TranslateMusicPlayerString(info[2].name); // musicplayer.position(foo).bar
1105 return AddMultiInfo(GUIInfo(value, 0, position));
1107 else if (info[1].name == "offset")
1109 int position = atoi(info[1].param().c_str());
1110 int value = TranslateMusicPlayerString(info[2].name); // musicplayer.offset(foo).bar
1111 return AddMultiInfo(GUIInfo(value, 1, position));
1114 else if (info[0].name == "container")
1116 int id = atoi(info[0].param().c_str());
1117 int offset = atoi(info[1].param().c_str());
1118 if (info[1].name == "listitemnowrap")
1119 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset));
1120 else if (info[1].name == "listitemposition")
1121 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_POSITION));
1122 else if (info[1].name == "listitem")
1123 return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_WRAP));
1130 int CGUIInfoManager::TranslateListItem(const Property &info)
1132 for (size_t i = 0; i < sizeof(listitem_labels) / sizeof(infomap); i++) // these ones don't have or need an id
1134 if (info.name == listitem_labels[i].str)
1135 return listitem_labels[i].val;
1137 if (info.name == "property" && info.num_params() == 1)
1139 if (info.param().Equals("fanart_image"))
1140 return AddListItemProp("fanart", LISTITEM_ART_OFFSET);
1141 return AddListItemProp(info.param());
1143 if (info.name == "art" && info.num_params() == 1)
1144 return AddListItemProp(info.param(), LISTITEM_ART_OFFSET);
1148 int CGUIInfoManager::TranslateMusicPlayerString(const CStdString &info) const
1150 for (size_t i = 0; i < sizeof(musicplayer) / sizeof(infomap); i++)
1152 if (info == musicplayer[i].str)
1153 return musicplayer[i].val;
1158 TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const CStdString &format)
1160 if (format.IsEmpty()) return TIME_FORMAT_GUESS;
1161 else if (format.Equals("hh")) return TIME_FORMAT_HH;
1162 else if (format.Equals("mm")) return TIME_FORMAT_MM;
1163 else if (format.Equals("ss")) return TIME_FORMAT_SS;
1164 else if (format.Equals("hh:mm")) return TIME_FORMAT_HH_MM;
1165 else if (format.Equals("mm:ss")) return TIME_FORMAT_MM_SS;
1166 else if (format.Equals("hh:mm:ss")) return TIME_FORMAT_HH_MM_SS;
1167 else if (format.Equals("h")) return TIME_FORMAT_H;
1168 else if (format.Equals("h:mm:ss")) return TIME_FORMAT_H_MM_SS;
1169 else if (format.Equals("xx")) return TIME_FORMAT_XX;
1170 return TIME_FORMAT_GUESS;
1173 CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fallback)
1175 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
1176 return GetSkinVariableString(info, false);
1178 CStdString strLabel;
1179 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
1180 return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
1182 if (info >= SLIDE_INFO_START && info <= SLIDE_INFO_END)
1183 return GetPictureLabel(info);
1185 if (info >= LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET &&
1186 info - (LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET) < (int)m_listitemProperties.size())
1187 { // grab the property
1191 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START-MUSICPLAYER_PROPERTY_OFFSET];
1192 return m_currentFile->GetProperty(property).asString();
1195 if (info >= LISTITEM_START && info <= LISTITEM_END)
1197 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS); // true for has list items
1200 CFileItemPtr item = window->GetCurrentListItem();
1201 strLabel = GetItemLabel(item.get(), info, fallback);
1209 case PVR_NEXT_RECORDING_CHANNEL:
1210 case PVR_NEXT_RECORDING_CHAN_ICO:
1211 case PVR_NEXT_RECORDING_DATETIME:
1212 case PVR_NEXT_RECORDING_TITLE:
1213 case PVR_NOW_RECORDING_CHANNEL:
1214 case PVR_NOW_RECORDING_CHAN_ICO:
1215 case PVR_NOW_RECORDING_DATETIME:
1216 case PVR_NOW_RECORDING_TITLE:
1217 case PVR_BACKEND_NAME:
1218 case PVR_BACKEND_VERSION:
1219 case PVR_BACKEND_HOST:
1220 case PVR_BACKEND_DISKSPACE:
1221 case PVR_BACKEND_CHANNELS:
1222 case PVR_BACKEND_TIMERS:
1223 case PVR_BACKEND_RECORDINGS:
1224 case PVR_BACKEND_NUMBER:
1225 case PVR_TOTAL_DISKSPACE:
1226 case PVR_NEXT_TIMER:
1227 case PVR_PLAYING_DURATION:
1228 case PVR_PLAYING_TIME:
1229 case PVR_PLAYING_PROGRESS:
1230 case PVR_ACTUAL_STREAM_CLIENT:
1231 case PVR_ACTUAL_STREAM_DEVICE:
1232 case PVR_ACTUAL_STREAM_STATUS:
1233 case PVR_ACTUAL_STREAM_SIG:
1234 case PVR_ACTUAL_STREAM_SNR:
1235 case PVR_ACTUAL_STREAM_SIG_PROGR:
1236 case PVR_ACTUAL_STREAM_SNR_PROGR:
1237 case PVR_ACTUAL_STREAM_BER:
1238 case PVR_ACTUAL_STREAM_UNC:
1239 case PVR_ACTUAL_STREAM_VIDEO_BR:
1240 case PVR_ACTUAL_STREAM_AUDIO_BR:
1241 case PVR_ACTUAL_STREAM_DOLBY_BR:
1242 case PVR_ACTUAL_STREAM_CRYPTION:
1243 g_PVRManager.TranslateCharInfo(info, strLabel);
1245 case WEATHER_CONDITIONS:
1246 strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND);
1247 strLabel = strLabel.Trim();
1249 case WEATHER_TEMPERATURE:
1250 strLabel.Format("%s%s", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP), g_langInfo.GetTempUnitString().c_str());
1252 case WEATHER_LOCATION:
1253 strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_LOCATION);
1255 case WEATHER_FANART_CODE:
1256 strLabel = URIUtils::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON));
1257 URIUtils::RemoveExtension(strLabel);
1259 case WEATHER_PLUGIN:
1260 strLabel = g_guiSettings.GetString("weather.addon");
1263 strLabel = GetDate();
1266 strLabel.Format("%02.2f", m_fps);
1269 strLabel.Format("%2.1f dB", CAEUtil::PercentToGain(g_settings.m_fVolumeLevel));
1271 case PLAYER_SUBTITLE_DELAY:
1272 strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_SubtitleDelay);
1274 case PLAYER_AUDIO_DELAY:
1275 strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_AudioDelay);
1277 case PLAYER_CHAPTER:
1278 if(g_application.IsPlaying() && g_application.m_pPlayer)
1279 strLabel.Format("%02d", g_application.m_pPlayer->GetChapter());
1281 case PLAYER_CHAPTERCOUNT:
1282 if(g_application.IsPlaying() && g_application.m_pPlayer)
1283 strLabel.Format("%02d", g_application.m_pPlayer->GetChapterCount());
1285 case PLAYER_CHAPTERNAME:
1286 if(g_application.IsPlaying() && g_application.m_pPlayer)
1287 g_application.m_pPlayer->GetChapterName(strLabel);
1289 case PLAYER_CACHELEVEL:
1292 if(g_application.IsPlaying() && GetInt(iLevel, PLAYER_CACHELEVEL) && iLevel >= 0)
1293 strLabel.Format("%i", iLevel);
1297 if(g_application.IsPlaying() && g_application.m_pPlayer)
1298 strLabel = GetCurrentPlayTime(TIME_FORMAT_HH_MM);
1300 case PLAYER_DURATION:
1301 if(g_application.IsPlaying() && g_application.m_pPlayer)
1302 strLabel = GetDuration(TIME_FORMAT_HH_MM);
1305 case PLAYER_FILEPATH:
1308 if (m_currentFile->HasMusicInfoTag())
1309 strLabel = m_currentFile->GetMusicInfoTag()->GetURL();
1310 else if (m_currentFile->HasVideoInfoTag())
1311 strLabel = m_currentFile->GetVideoInfoTag()->m_strFileNameAndPath;
1312 if (strLabel.IsEmpty())
1313 strLabel = m_currentFile->GetPath();
1315 if (info == PLAYER_PATH)
1317 // do this twice since we want the path outside the archive if this
1319 if (URIUtils::IsInArchive(strLabel))
1320 strLabel = URIUtils::GetParentPath(strLabel);
1321 strLabel = URIUtils::GetParentPath(strLabel);
1328 if (m_currentFile->HasPVRChannelInfoTag())
1331 return m_currentFile->GetPVRChannelInfoTag()->GetEPGNow(tag) ?
1333 g_guiSettings.GetBool("epg.hidenoinfoavailable") ?
1334 StringUtils::EmptyString :
1335 g_localizeStrings.Get(19055); // no information available
1337 if (m_currentFile->HasPVRRecordingInfoTag() && !m_currentFile->GetPVRRecordingInfoTag()->m_strTitle.IsEmpty())
1338 return m_currentFile->GetPVRRecordingInfoTag()->m_strTitle;
1339 if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_strTitle.IsEmpty())
1340 return m_currentFile->GetVideoInfoTag()->m_strTitle;
1341 if (m_currentFile->HasMusicInfoTag() && !m_currentFile->GetMusicInfoTag()->GetTitle().IsEmpty())
1342 return m_currentFile->GetMusicInfoTag()->GetTitle();
1343 // don't have the title, so use dvdplayer, label, or drop down to title from path
1344 if (g_application.m_pPlayer && !g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
1345 return g_application.m_pPlayer->GetPlayingTitle();
1346 if (!m_currentFile->GetLabel().IsEmpty())
1347 return m_currentFile->GetLabel();
1348 return CUtil::GetTitleFromPath(m_currentFile->GetPath());
1352 if (g_application.m_pPlayer && !g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
1353 return g_application.m_pPlayer->GetPlayingTitle();
1357 case MUSICPLAYER_TITLE:
1358 case MUSICPLAYER_ALBUM:
1359 case MUSICPLAYER_ARTIST:
1360 case MUSICPLAYER_ALBUM_ARTIST:
1361 case MUSICPLAYER_GENRE:
1362 case MUSICPLAYER_YEAR:
1363 case MUSICPLAYER_TRACK_NUMBER:
1364 case MUSICPLAYER_BITRATE:
1365 case MUSICPLAYER_PLAYLISTLEN:
1366 case MUSICPLAYER_PLAYLISTPOS:
1367 case MUSICPLAYER_CHANNELS:
1368 case MUSICPLAYER_BITSPERSAMPLE:
1369 case MUSICPLAYER_SAMPLERATE:
1370 case MUSICPLAYER_CODEC:
1371 case MUSICPLAYER_DISC_NUMBER:
1372 case MUSICPLAYER_RATING:
1373 case MUSICPLAYER_COMMENT:
1374 case MUSICPLAYER_LYRICS:
1375 case MUSICPLAYER_CHANNEL_NAME:
1376 case MUSICPLAYER_CHANNEL_NUMBER:
1377 case MUSICPLAYER_CHANNEL_GROUP:
1378 case MUSICPLAYER_PLAYCOUNT:
1379 case MUSICPLAYER_LASTPLAYED:
1380 strLabel = GetMusicLabel(info);
1382 case VIDEOPLAYER_TITLE:
1383 case VIDEOPLAYER_ORIGINALTITLE:
1384 case VIDEOPLAYER_GENRE:
1385 case VIDEOPLAYER_DIRECTOR:
1386 case VIDEOPLAYER_YEAR:
1387 case VIDEOPLAYER_PLAYLISTLEN:
1388 case VIDEOPLAYER_PLAYLISTPOS:
1389 case VIDEOPLAYER_PLOT:
1390 case VIDEOPLAYER_PLOT_OUTLINE:
1391 case VIDEOPLAYER_EPISODE:
1392 case VIDEOPLAYER_SEASON:
1393 case VIDEOPLAYER_RATING:
1394 case VIDEOPLAYER_RATING_AND_VOTES:
1395 case VIDEOPLAYER_TVSHOW:
1396 case VIDEOPLAYER_PREMIERED:
1397 case VIDEOPLAYER_STUDIO:
1398 case VIDEOPLAYER_COUNTRY:
1399 case VIDEOPLAYER_MPAA:
1400 case VIDEOPLAYER_TOP250:
1401 case VIDEOPLAYER_CAST:
1402 case VIDEOPLAYER_CAST_AND_ROLE:
1403 case VIDEOPLAYER_ARTIST:
1404 case VIDEOPLAYER_ALBUM:
1405 case VIDEOPLAYER_WRITER:
1406 case VIDEOPLAYER_TAGLINE:
1407 case VIDEOPLAYER_TRAILER:
1408 case VIDEOPLAYER_STARTTIME:
1409 case VIDEOPLAYER_ENDTIME:
1410 case VIDEOPLAYER_NEXT_TITLE:
1411 case VIDEOPLAYER_NEXT_GENRE:
1412 case VIDEOPLAYER_NEXT_PLOT:
1413 case VIDEOPLAYER_NEXT_PLOT_OUTLINE:
1414 case VIDEOPLAYER_NEXT_STARTTIME:
1415 case VIDEOPLAYER_NEXT_ENDTIME:
1416 case VIDEOPLAYER_NEXT_DURATION:
1417 case VIDEOPLAYER_CHANNEL_NAME:
1418 case VIDEOPLAYER_CHANNEL_NUMBER:
1419 case VIDEOPLAYER_CHANNEL_GROUP:
1420 case VIDEOPLAYER_PARENTAL_RATING:
1421 case VIDEOPLAYER_PLAYCOUNT:
1422 case VIDEOPLAYER_LASTPLAYED:
1423 strLabel = GetVideoLabel(info);
1425 case VIDEOPLAYER_VIDEO_CODEC:
1426 if(g_application.IsPlaying() && g_application.m_pPlayer)
1428 SPlayerVideoStreamInfo info;
1429 g_application.m_pPlayer->GetVideoStreamInfo(info);
1430 strLabel = info.videoCodecName;
1433 case VIDEOPLAYER_VIDEO_RESOLUTION:
1434 if(g_application.IsPlaying() && g_application.m_pPlayer)
1435 return CStreamDetails::VideoDimsToResolutionDescription(g_application.m_pPlayer->GetPictureWidth(), g_application.m_pPlayer->GetPictureHeight());
1437 case VIDEOPLAYER_AUDIO_CODEC:
1438 if(g_application.IsPlaying() && g_application.m_pPlayer)
1440 SPlayerAudioStreamInfo info;
1441 g_application.m_pPlayer->GetAudioStreamInfo(g_application.m_pPlayer->GetAudioStream(), info);
1442 strLabel = info.audioCodecName;
1445 case VIDEOPLAYER_VIDEO_ASPECT:
1446 if (g_application.IsPlaying() && g_application.m_pPlayer)
1448 SPlayerVideoStreamInfo info;
1449 g_application.m_pPlayer->GetVideoStreamInfo(info);
1450 strLabel = CStreamDetails::VideoAspectToAspectDescription(info.videoAspectRatio);
1453 case VIDEOPLAYER_AUDIO_CHANNELS:
1454 if(g_application.IsPlaying() && g_application.m_pPlayer)
1456 SPlayerAudioStreamInfo info;
1457 g_application.m_pPlayer->GetAudioStreamInfo(g_application.m_pPlayer->GetAudioStream(), info);
1458 strLabel.Format("%i", info.channels);
1461 case PLAYLIST_LENGTH:
1462 case PLAYLIST_POSITION:
1463 case PLAYLIST_RANDOM:
1464 case PLAYLIST_REPEAT:
1465 strLabel = GetPlaylistLabel(info);
1467 case MUSICPM_SONGSPLAYED:
1468 case MUSICPM_MATCHINGSONGS:
1469 case MUSICPM_MATCHINGSONGSPICKED:
1470 case MUSICPM_MATCHINGSONGSLEFT:
1471 case MUSICPM_RELAXEDSONGSPICKED:
1472 case MUSICPM_RANDOMSONGSPICKED:
1473 strLabel = GetMusicPartyModeLabel(info);
1476 case SYSTEM_FREE_SPACE:
1477 case SYSTEM_USED_SPACE:
1478 case SYSTEM_TOTAL_SPACE:
1479 case SYSTEM_FREE_SPACE_PERCENT:
1480 case SYSTEM_USED_SPACE_PERCENT:
1481 return g_sysinfo.GetHddSpaceInfo(info);
1484 case SYSTEM_CPU_TEMPERATURE:
1485 case SYSTEM_GPU_TEMPERATURE:
1486 case SYSTEM_FAN_SPEED:
1487 case SYSTEM_CPU_USAGE:
1488 return GetSystemHeatInfo(info);
1491 case SYSTEM_VIDEO_ENCODER_INFO:
1492 case NETWORK_MAC_ADDRESS:
1493 case SYSTEM_KERNEL_VERSION:
1494 case SYSTEM_CPUFREQUENCY:
1495 case SYSTEM_INTERNET_STATE:
1497 case SYSTEM_TOTALUPTIME:
1498 case SYSTEM_BATTERY_LEVEL:
1499 return g_sysinfo.GetInfo(info);
1502 case SYSTEM_SCREEN_RESOLUTION:
1503 if(g_Windowing.IsFullScreen())
1504 strLabel.Format("%ix%i@%.2fHz - %s (%02.2f fps)",
1505 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iScreenWidth,
1506 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iScreenHeight,
1507 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].fRefreshRate,
1508 g_localizeStrings.Get(244), GetFPS());
1510 strLabel.Format("%ix%i - %s (%02.2f fps)",
1511 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iScreenWidth,
1512 g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iScreenHeight,
1513 g_localizeStrings.Get(242), GetFPS());
1517 case CONTAINER_FOLDERPATH:
1518 case CONTAINER_FOLDERNAME:
1520 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1523 if (info==CONTAINER_FOLDERNAME)
1524 strLabel = ((CGUIMediaWindow*)window)->CurrentDirectory().GetLabel();
1526 strLabel = CURL(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath()).GetWithoutUserDetails();
1530 case CONTAINER_PLUGINNAME:
1532 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1535 CURL url(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath());
1536 if (url.GetProtocol().Equals("plugin"))
1538 strLabel = url.GetFileName();
1539 URIUtils::RemoveSlashAtEnd(strLabel);
1544 case CONTAINER_VIEWMODE:
1546 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1549 const CGUIControl *control = window->GetControl(window->GetViewContainerID());
1550 if (control && control->IsContainer())
1551 strLabel = ((IGUIContainer *)control)->GetLabel();
1555 case CONTAINER_SORT_METHOD:
1557 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1560 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
1562 strLabel = g_localizeStrings.Get(viewState->GetSortMethodLabel());
1566 case CONTAINER_NUM_PAGES:
1567 case CONTAINER_NUM_ITEMS:
1568 case CONTAINER_CURRENT_PAGE:
1569 return GetMultiInfoLabel(GUIInfo(info), contextWindow);
1571 case CONTAINER_SHOWPLOT:
1573 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1575 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("showplot").asString();
1578 case CONTAINER_TOTALTIME:
1580 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1583 const CFileItemList& items=((CGUIMediaWindow *)window)->CurrentDirectory();
1585 for (int i=0;i<items.Size();++i)
1587 CFileItemPtr item=items.Get(i);
1588 if (item->HasMusicInfoTag())
1589 duration += item->GetMusicInfoTag()->GetDuration();
1590 else if (item->HasVideoInfoTag())
1591 duration += item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration();
1594 return StringUtils::SecondsToTimeString(duration);
1598 case SYSTEM_BUILD_VERSION:
1599 strLabel = GetVersion();
1601 case SYSTEM_BUILD_DATE:
1602 strLabel = GetBuild();
1604 case SYSTEM_FREE_MEMORY:
1605 case SYSTEM_FREE_MEMORY_PERCENT:
1606 case SYSTEM_USED_MEMORY:
1607 case SYSTEM_USED_MEMORY_PERCENT:
1608 case SYSTEM_TOTAL_MEMORY:
1610 MEMORYSTATUSEX stat;
1611 stat.dwLength = sizeof(MEMORYSTATUSEX);
1612 GlobalMemoryStatusEx(&stat);
1613 int iMemPercentFree = 100 - ((int)( 100.0f* (stat.ullTotalPhys - stat.ullAvailPhys)/stat.ullTotalPhys + 0.5f ));
1614 int iMemPercentUsed = 100 - iMemPercentFree;
1616 if (info == SYSTEM_FREE_MEMORY)
1617 strLabel.Format("%luMB", (ULONG)(stat.ullAvailPhys/MB));
1618 else if (info == SYSTEM_FREE_MEMORY_PERCENT)
1619 strLabel.Format("%i%%", iMemPercentFree);
1620 else if (info == SYSTEM_USED_MEMORY)
1621 strLabel.Format("%luMB", (ULONG)((stat.ullTotalPhys - stat.ullAvailPhys)/MB));
1622 else if (info == SYSTEM_USED_MEMORY_PERCENT)
1623 strLabel.Format("%i%%", iMemPercentUsed);
1624 else if (info == SYSTEM_TOTAL_MEMORY)
1625 strLabel.Format("%luMB", (ULONG)(stat.ullTotalPhys/MB));
1628 case SYSTEM_SCREEN_MODE:
1629 strLabel = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].strMode;
1631 case SYSTEM_SCREEN_WIDTH:
1632 strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iScreenWidth);
1634 case SYSTEM_SCREEN_HEIGHT:
1635 strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iScreenHeight);
1637 case SYSTEM_CURRENT_WINDOW:
1638 return g_localizeStrings.Get(g_windowManager.GetFocusedWindow());
1640 case SYSTEM_CURRENT_CONTROL:
1642 CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetFocusedWindow());
1645 CGUIControl *control = window->GetFocusedControl();
1647 strLabel = control->GetDescription();
1651 #ifdef HAS_DVD_DRIVE
1652 case SYSTEM_DVD_LABEL:
1653 strLabel = g_mediaManager.GetDiskLabel();
1656 case SYSTEM_ALARM_POS:
1657 if (g_alarmClock.GetRemaining("shutdowntimer") == 0.f)
1661 double fTime = g_alarmClock.GetRemaining("shutdowntimer");
1663 strLabel.Format(g_localizeStrings.Get(13213).c_str(),g_alarmClock.GetRemaining("shutdowntimer")/60.f);
1665 strLabel.Format(g_localizeStrings.Get(13214).c_str(),g_alarmClock.GetRemaining("shutdowntimer"));
1668 case SYSTEM_PROFILENAME:
1669 strLabel = g_settings.GetCurrentProfile().getName();
1671 case SYSTEM_PROFILECOUNT:
1672 strLabel.Format("%i", g_settings.GetNumProfiles());
1674 case SYSTEM_LANGUAGE:
1675 strLabel = g_guiSettings.GetString("locale.language");
1677 case SYSTEM_TEMPERATURE_UNITS:
1678 strLabel = g_langInfo.GetTempUnitString();
1680 case SYSTEM_PROGRESS_BAR:
1683 if (GetInt(percent, SYSTEM_PROGRESS_BAR) && percent > 0)
1684 strLabel.Format("%i", percent);
1687 case SYSTEM_FRIENDLY_NAME:
1689 CStdString friendlyName = g_guiSettings.GetString("services.devicename");
1690 if (friendlyName.Equals("XBMC"))
1691 strLabel.Format("%s (%s)", friendlyName.c_str(), g_application.getNetwork().GetHostName().c_str());
1693 strLabel = friendlyName;
1698 strLabel = g_guiSettings.GetString("lookandfeel.skintheme");
1700 case SKIN_COLOUR_THEME:
1701 strLabel = g_guiSettings.GetString("lookandfeel.skincolors");
1703 case SKIN_ASPECT_RATIO:
1705 strLabel = g_SkinInfo->GetCurrentAspect();
1707 case NETWORK_IP_ADDRESS:
1709 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1711 return iface->GetCurrentIPAddress();
1714 case NETWORK_SUBNET_MASK:
1716 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1718 return iface->GetCurrentNetmask();
1721 case NETWORK_GATEWAY_ADDRESS:
1723 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1725 return iface->GetCurrentDefaultGateway();
1728 case NETWORK_DNS1_ADDRESS:
1730 vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1731 if (nss.size() >= 1)
1735 case NETWORK_DNS2_ADDRESS:
1737 vector<CStdString> nss = g_application.getNetwork().GetNameServers();
1738 if (nss.size() >= 2)
1742 case NETWORK_DHCP_ADDRESS:
1744 CStdString dhcpserver;
1748 case NETWORK_LINK_STATE:
1750 CStdString linkStatus = g_localizeStrings.Get(151);
1752 CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
1753 if (iface && iface->IsConnected())
1754 linkStatus += g_localizeStrings.Get(15207);
1756 linkStatus += g_localizeStrings.Get(15208);
1761 case VISUALISATION_PRESET:
1763 CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
1764 g_windowManager.SendMessage(msg);
1765 if (msg.GetPointer())
1767 CVisualisation* viz = NULL;
1768 viz = (CVisualisation*)msg.GetPointer();
1771 strLabel = viz->GetPresetName();
1772 URIUtils::RemoveExtension(strLabel);
1777 case VISUALISATION_NAME:
1780 strLabel = g_guiSettings.GetString("musicplayer.visualisation");
1781 if (CAddonMgr::Get().GetAddon(strLabel,addon) && addon)
1782 strLabel = addon->Name();
1787 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1789 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color1").asString();
1794 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1796 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color2").asString();
1801 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1803 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color3").asString();
1808 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
1810 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetArt("fanart");
1813 case SYSTEM_RENDER_VENDOR:
1814 strLabel = g_Windowing.GetRenderVendor();
1816 case SYSTEM_RENDER_RENDERER:
1817 strLabel = g_Windowing.GetRenderRenderer();
1819 case SYSTEM_RENDER_VERSION:
1820 strLabel = g_Windowing.GetRenderVersionString();
1827 // tries to get a integer value for use in progressbars/sliders and such
1828 bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUIListItem *item /* = NULL */) const
1830 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
1831 return GetMultiInfoInt(value, m_multiInfo[info - MULTI_INFO_START], contextWindow);
1833 if (info >= LISTITEM_START && info <= LISTITEM_END)
1834 return GetItemInt(value, item, info);
1840 value = g_application.GetVolume();
1842 case PLAYER_SUBTITLE_DELAY:
1843 value = g_application.GetSubtitleDelay();
1845 case PLAYER_AUDIO_DELAY:
1846 value = g_application.GetAudioDelay();
1848 case PLAYER_PROGRESS:
1849 case PLAYER_PROGRESS_CACHE:
1850 case PLAYER_SEEKBAR:
1851 case PLAYER_CACHELEVEL:
1852 case PLAYER_CHAPTER:
1853 case PLAYER_CHAPTERCOUNT:
1855 if( g_application.IsPlaying() && g_application.m_pPlayer)
1859 case PLAYER_PROGRESS:
1860 value = (int)(g_application.GetPercentage());
1862 case PLAYER_PROGRESS_CACHE:
1863 value = (int)(g_application.GetCachePercentage());
1865 case PLAYER_SEEKBAR:
1866 value = (int)g_application.GetSeekHandler()->GetPercent();
1868 case PLAYER_CACHELEVEL:
1869 value = (int)(g_application.m_pPlayer->GetCacheLevel());
1871 case PLAYER_CHAPTER:
1872 value = g_application.m_pPlayer->GetChapter();
1874 case PLAYER_CHAPTERCOUNT:
1875 value = g_application.m_pPlayer->GetChapterCount();
1881 case SYSTEM_FREE_MEMORY:
1882 case SYSTEM_USED_MEMORY:
1884 MEMORYSTATUSEX stat;
1885 stat.dwLength = sizeof(MEMORYSTATUSEX);
1886 GlobalMemoryStatusEx(&stat);
1887 int memPercentUsed = (int)( 100.0f* (stat.ullTotalPhys - stat.ullAvailPhys)/stat.ullTotalPhys + 0.5f );
1888 if (info == SYSTEM_FREE_MEMORY)
1889 value = 100 - memPercentUsed;
1891 value = memPercentUsed;
1894 case SYSTEM_PROGRESS_BAR:
1896 CGUIDialogProgress *bar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
1897 if (bar && bar->IsDialogRunning())
1898 value = bar->GetPercentage();
1901 case SYSTEM_FREE_SPACE:
1902 case SYSTEM_USED_SPACE:
1904 g_sysinfo.GetHddSpaceInfo(value, info, true);
1907 case SYSTEM_CPU_USAGE:
1908 value = g_cpuInfo.getUsedPercentage();
1910 case PVR_PLAYING_PROGRESS:
1911 case PVR_ACTUAL_STREAM_SIG_PROGR:
1912 case PVR_ACTUAL_STREAM_SNR_PROGR:
1913 value = g_PVRManager.TranslateIntInfo(info);
1915 case SYSTEM_BATTERY_LEVEL:
1916 value = g_powerManager.BatteryLevel();
1922 unsigned int CGUIInfoManager::Register(const CStdString &expression, int context)
1924 CStdString condition(CGUIInfoLabel::ReplaceLocalize(expression));
1925 condition.TrimLeft(" \t\r\n");
1926 condition.TrimRight(" \t\r\n");
1928 if (condition.IsEmpty())
1931 CSingleLock lock(m_critInfo);
1932 // do we have the boolean expression already registered?
1933 InfoBool test(condition, context);
1934 for (unsigned int i = 0; i < m_bools.size(); ++i)
1936 if (*m_bools[i] == test)
1940 if (condition.find_first_of("|+[]!") != condition.npos)
1941 m_bools.push_back(new InfoExpression(condition, context));
1943 m_bools.push_back(new InfoSingle(condition, context));
1945 return m_bools.size();
1948 bool CGUIInfoManager::EvaluateBool(const CStdString &expression, int contextWindow)
1950 bool result = false;
1951 unsigned int info = Register(expression, contextWindow);
1953 result = GetBoolValue(info);
1958 TODO: what to do with item-based infobools...
1960 1. if condition is between LISTITEM_START and LISTITEM_END
1961 2. if condition is STRING_IS_EMPTY, STRING_COMPARE, STRING_STR, INTEGER_GREATER_THAN and the
1962 corresponding label is between LISTITEM_START and LISTITEM_END
1964 In both cases they shouldn't be in our cache as they depend on items outside of our control atm.
1966 We only pass a listitem object in for controls inside a listitemlayout, so I think it's probably OK
1967 to not cache these, as they're "pushed" out anyway.
1969 The problem is how do we avoid these? The only thing we have to go on is the expression here, so I
1970 guess what we have to do is call through via Update. One thing we don't handle, however, is that the
1971 majority of conditions (even inside lists) don't depend on the listitem at all.
1973 Advantage is that we know this at creation time I think, so could perhaps signal it in IsDirty()?
1975 bool CGUIInfoManager::GetBoolValue(unsigned int expression, const CGUIListItem *item)
1977 if (expression && --expression < m_bools.size())
1978 return m_bools[expression]->Get(m_updateTime, item);
1982 // checks the condition and returns it as necessary. Currently used
1983 // for toggle button controls and visibility of images.
1984 bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListItem *item)
1986 bool bReturn = false;
1987 int condition = abs(condition1);
1989 if (item && condition >= LISTITEM_START && condition < LISTITEM_END)
1990 bReturn = GetItemBool(item, condition);
1991 // Ethernet Link state checking
1992 // Will check if system has a Ethernet Link connection! [Cable in!]
1993 // This can used for the skinner to switch off Network or Inter required functions
1994 else if ( condition == SYSTEM_ALWAYS_TRUE)
1996 else if (condition == SYSTEM_ALWAYS_FALSE)
1998 else if (condition == SYSTEM_ETHERNET_LINK_ACTIVE)
2000 else if (condition == WINDOW_IS_MEDIA)
2001 { // note: This doesn't return true for dialogs (content, favourites, login, videoinfo)
2002 CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
2003 bReturn = (pWindow && pWindow->IsMediaWindow());
2005 else if (condition == PLAYER_MUTED)
2006 bReturn = g_settings.m_bMute;
2007 else if (condition >= LIBRARY_HAS_MUSIC && condition <= LIBRARY_HAS_MUSICVIDEOS)
2008 bReturn = GetLibraryBool(condition);
2009 else if (condition == LIBRARY_IS_SCANNING)
2011 if (g_application.IsMusicScanning() || g_application.IsVideoScanning())
2016 else if (condition == LIBRARY_IS_SCANNING_VIDEO)
2018 bReturn = g_application.IsVideoScanning();
2020 else if (condition == LIBRARY_IS_SCANNING_MUSIC)
2022 bReturn = g_application.IsMusicScanning();
2024 else if (condition == SYSTEM_PLATFORM_LINUX)
2025 #if defined(_LINUX) && !defined(TARGET_DARWIN) && !defined(TARGET_ANDROID)
2030 else if (condition == SYSTEM_PLATFORM_WINDOWS)
2036 else if (condition == SYSTEM_PLATFORM_DARWIN)
2037 #ifdef TARGET_DARWIN
2042 else if (condition == SYSTEM_PLATFORM_DARWIN_OSX)
2043 #ifdef TARGET_DARWIN_OSX
2048 else if (condition == SYSTEM_PLATFORM_DARWIN_IOS)
2049 #ifdef TARGET_DARWIN_IOS
2054 else if (condition == SYSTEM_PLATFORM_DARWIN_ATV2)
2055 #ifdef TARGET_DARWIN_IOS_ATV2
2060 else if (condition == SYSTEM_PLATFORM_ANDROID)
2061 #if defined(TARGET_ANDROID)
2066 else if (condition == SYSTEM_MEDIA_DVD)
2067 bReturn = g_mediaManager.IsDiscInDrive();
2068 #ifdef HAS_DVD_DRIVE
2069 else if (condition == SYSTEM_DVDREADY)
2070 bReturn = g_mediaManager.GetDriveStatus() != DRIVE_NOT_READY;
2071 else if (condition == SYSTEM_TRAYOPEN)
2072 bReturn = g_mediaManager.GetDriveStatus() == DRIVE_OPEN;
2074 else if (condition == SYSTEM_CAN_POWERDOWN)
2075 bReturn = g_powerManager.CanPowerdown();
2076 else if (condition == SYSTEM_CAN_SUSPEND)
2077 bReturn = g_powerManager.CanSuspend();
2078 else if (condition == SYSTEM_CAN_HIBERNATE)
2079 bReturn = g_powerManager.CanHibernate();
2080 else if (condition == SYSTEM_CAN_REBOOT)
2081 bReturn = g_powerManager.CanReboot();
2082 else if (condition == SYSTEM_SCREENSAVER_ACTIVE)
2083 bReturn = g_application.IsInScreenSaver();
2085 else if (condition == PLAYER_SHOWINFO)
2086 bReturn = m_playerShowInfo;
2087 else if (condition == PLAYER_SHOWCODEC)
2088 bReturn = m_playerShowCodec;
2089 else if (condition >= MULTI_INFO_START && condition <= MULTI_INFO_END)
2091 return GetMultiInfoBool(m_multiInfo[condition - MULTI_INFO_START], contextWindow, item);
2093 else if (condition == SYSTEM_HASLOCKS)
2094 bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE;
2095 else if (condition == SYSTEM_HAS_PVR)
2097 else if (condition == SYSTEM_ISMASTER)
2098 bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
2099 else if (condition == SYSTEM_ISFULLSCREEN)
2100 bReturn = g_Windowing.IsFullScreen();
2101 else if (condition == SYSTEM_ISSTANDALONE)
2102 bReturn = g_application.IsStandAlone();
2103 else if (condition == SYSTEM_ISINHIBIT)
2104 bReturn = g_application.IsIdleShutdownInhibited();
2105 else if (condition == SYSTEM_HAS_SHUTDOWN)
2106 bReturn = (g_guiSettings.GetInt("powermanagement.shutdowntime") > 0);
2107 else if (condition == SYSTEM_LOGGEDON)
2108 bReturn = !(g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN);
2109 else if (condition == SYSTEM_SHOW_EXIT_BUTTON)
2110 bReturn = g_advancedSettings.m_showExitButton;
2111 else if (condition == SYSTEM_HAS_LOGINSCREEN)
2112 bReturn = g_settings.UsingLoginScreen();
2113 else if (condition == WEATHER_IS_FETCHED)
2114 bReturn = g_weatherManager.IsFetched();
2115 else if (condition >= PVR_CONDITIONS_START && condition <= PVR_CONDITIONS_END)
2116 bReturn = g_PVRManager.TranslateBoolInfo(condition);
2118 else if (condition == SYSTEM_INTERNET_STATE)
2120 g_sysinfo.GetInfo(condition);
2121 bReturn = g_sysinfo.HasInternet();
2123 else if (condition == SKIN_HAS_VIDEO_OVERLAY)
2125 bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingVideo();
2127 else if (condition == SKIN_HAS_MUSIC_OVERLAY)
2129 bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingAudio();
2131 else if (condition == CONTAINER_HASFILES || condition == CONTAINER_HASFOLDERS)
2133 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2136 const CFileItemList& items=((CGUIMediaWindow*)pWindow)->CurrentDirectory();
2137 for (int i=0;i<items.Size();++i)
2139 CFileItemPtr item=items.Get(i);
2140 if (!item->m_bIsFolder && condition == CONTAINER_HASFILES)
2145 else if (item->m_bIsFolder && !item->IsParentFolder() && condition == CONTAINER_HASFOLDERS)
2153 else if (condition == CONTAINER_STACKED)
2155 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2157 bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().GetProperty("isstacked").asBoolean();
2159 else if (condition == CONTAINER_HAS_THUMB)
2161 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2163 bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().HasArt("thumb");
2165 else if (condition == CONTAINER_HAS_NEXT || condition == CONTAINER_HAS_PREVIOUS || condition == CONTAINER_SCROLLING)
2167 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2170 const CGUIControl* control = window->GetControl(window->GetViewContainerID());
2172 bReturn = control->GetCondition(condition, 0);
2175 else if (condition == CONTAINER_CAN_FILTER)
2177 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2179 bReturn = !((CGUIMediaWindow*)window)->CanFilterAdvanced();
2181 else if (condition == CONTAINER_CAN_FILTERADVANCED)
2183 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2185 bReturn = ((CGUIMediaWindow*)window)->CanFilterAdvanced();
2187 else if (condition == CONTAINER_FILTERED)
2189 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2191 bReturn = ((CGUIMediaWindow*)window)->IsFiltered();
2193 else if (condition == VIDEOPLAYER_HAS_INFO)
2194 bReturn = ((m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->IsEmpty()) ||
2195 (m_currentFile->HasPVRChannelInfoTag() && !m_currentFile->GetPVRChannelInfoTag()->IsEmpty()));
2196 else if (condition >= CONTAINER_SCROLL_PREVIOUS && condition <= CONTAINER_SCROLL_NEXT)
2198 // no parameters, so we assume it's just requested for a media window. It therefore
2199 // can only happen if the list has focus.
2200 CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2203 map<int,int>::const_iterator it = m_containerMoves.find(pWindow->GetViewContainerID());
2204 if (it != m_containerMoves.end())
2206 if (condition > CONTAINER_STATIC) // moving up
2207 bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
2209 bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
2213 else if (condition == SLIDESHOW_ISPAUSED)
2215 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2216 bReturn = (slideShow && slideShow->IsPaused());
2218 else if (condition == SLIDESHOW_ISRANDOM)
2220 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2221 bReturn = (slideShow && slideShow->IsShuffled());
2223 else if (condition == SLIDESHOW_ISACTIVE)
2225 CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
2226 bReturn = (slideShow && slideShow->InSlideShow());
2228 else if (g_application.IsPlaying())
2232 case PLAYER_HAS_MEDIA:
2235 case PLAYER_HAS_AUDIO:
2236 bReturn = g_application.IsPlayingAudio();
2238 case PLAYER_HAS_VIDEO:
2239 bReturn = g_application.IsPlayingVideo();
2241 case PLAYER_PLAYING:
2242 bReturn = !g_application.IsPaused() && (g_application.GetPlaySpeed() == 1);
2245 bReturn = g_application.IsPaused();
2247 case PLAYER_REWINDING:
2248 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() < 1;
2250 case PLAYER_FORWARDING:
2251 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() > 1;
2253 case PLAYER_REWINDING_2x:
2254 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -2;
2256 case PLAYER_REWINDING_4x:
2257 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -4;
2259 case PLAYER_REWINDING_8x:
2260 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -8;
2262 case PLAYER_REWINDING_16x:
2263 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -16;
2265 case PLAYER_REWINDING_32x:
2266 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -32;
2268 case PLAYER_FORWARDING_2x:
2269 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 2;
2271 case PLAYER_FORWARDING_4x:
2272 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 4;
2274 case PLAYER_FORWARDING_8x:
2275 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 8;
2277 case PLAYER_FORWARDING_16x:
2278 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 16;
2280 case PLAYER_FORWARDING_32x:
2281 bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 32;
2283 case PLAYER_CAN_RECORD:
2284 bReturn = g_application.m_pPlayer->CanRecord();
2286 case PLAYER_CAN_PAUSE:
2287 bReturn = g_application.m_pPlayer->CanPause();
2289 case PLAYER_CAN_SEEK:
2290 bReturn = g_application.m_pPlayer->CanSeek();
2292 case PLAYER_RECORDING:
2293 bReturn = g_application.m_pPlayer->IsRecording();
2295 case PLAYER_DISPLAY_AFTER_SEEK:
2296 bReturn = GetDisplayAfterSeek();
2298 case PLAYER_CACHING:
2299 bReturn = g_application.m_pPlayer->IsCaching();
2301 case PLAYER_SEEKBAR:
2303 CGUIDialog *seekBar = (CGUIDialog*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
2304 bReturn = seekBar ? seekBar->IsDialogRunning() : false;
2307 case PLAYER_SEEKING:
2308 bReturn = m_playerSeeking;
2310 case PLAYER_SHOWTIME:
2311 bReturn = m_playerShowTime;
2313 case PLAYER_PASSTHROUGH:
2314 bReturn = g_application.m_pPlayer && g_application.m_pPlayer->IsPassthrough();
2316 case MUSICPM_ENABLED:
2317 bReturn = g_partyModeManager.IsEnabled();
2319 case MUSICPLAYER_HASPREVIOUS:
2321 // requires current playlist be PLAYLIST_MUSIC
2323 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2324 bReturn = (g_playlistPlayer.GetCurrentSong() > 0); // not first song
2327 case MUSICPLAYER_HASNEXT:
2329 // requires current playlist be PLAYLIST_MUSIC
2331 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2332 bReturn = (g_playlistPlayer.GetCurrentSong() < (g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size() - 1)); // not last song
2335 case MUSICPLAYER_PLAYLISTPLAYING:
2338 if (g_application.IsPlayingAudio() && g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
2342 case VIDEOPLAYER_USING_OVERLAYS:
2343 bReturn = (g_guiSettings.GetInt("videoplayer.rendermethod") == RENDER_OVERLAYS);
2345 case VIDEOPLAYER_ISFULLSCREEN:
2346 bReturn = g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO;
2348 case VIDEOPLAYER_HASMENU:
2349 bReturn = g_application.m_pPlayer->HasMenu();
2351 case PLAYLIST_ISRANDOM:
2352 bReturn = g_playlistPlayer.IsShuffled(g_playlistPlayer.GetCurrentPlaylist());
2354 case PLAYLIST_ISREPEAT:
2355 bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ALL;
2357 case PLAYLIST_ISREPEATONE:
2358 bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ONE;
2360 case PLAYER_HASDURATION:
2361 bReturn = g_application.GetTotalTime() > 0;
2363 case VIDEOPLAYER_HASTELETEXT:
2364 if (g_application.m_pPlayer->GetTeletextCache())
2367 case VIDEOPLAYER_HASSUBTITLES:
2368 bReturn = g_application.m_pPlayer->GetSubtitleCount() > 0;
2370 case VIDEOPLAYER_SUBTITLESENABLED:
2371 bReturn = g_application.m_pPlayer->GetSubtitleVisible();
2373 case VISUALISATION_LOCKED:
2375 CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
2376 g_windowManager.SendMessage(msg);
2377 if (msg.GetPointer())
2379 CVisualisation *pVis = (CVisualisation *)msg.GetPointer();
2380 bReturn = pVis->IsLocked();
2384 case VISUALISATION_ENABLED:
2385 bReturn = !g_guiSettings.GetString("musicplayer.visualisation").IsEmpty();
2387 case VIDEOPLAYER_HAS_EPG:
2388 if (m_currentFile->HasPVRChannelInfoTag())
2391 bReturn = m_currentFile->GetPVRChannelInfoTag()->GetEPGNow(epgTag);
2394 default: // default, use integer value different from 0 as true
2397 bReturn = GetInt(val, condition) && val != 0;
2406 /// \brief Examines the multi information sent and returns true or false accordingly.
2407 bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, const CGUIListItem *item)
2409 bool bReturn = false;
2410 int condition = abs(info.m_info);
2412 if (condition >= LISTITEM_START && condition <= LISTITEM_END)
2416 CGUIWindow *window = NULL;
2417 int data1 = info.GetData1();
2418 if (!data1) // No container specified, so we lookup the current view container
2420 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2421 if (window && window->IsMediaWindow())
2422 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2425 if (!window) // If we don't have a window already (from lookup above), get one
2426 window = GetWindowWithCondition(contextWindow, 0);
2430 const CGUIControl *control = window->GetControl(data1);
2431 if (control && control->IsContainer())
2432 item = ((IGUIContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()).get();
2435 if (item) // If we got a valid item, do the lookup
2436 bReturn = GetItemBool(item, condition); // Image prioritizes images over labels (in the case of music item ratings for instance)
2444 bReturn = g_settings.GetSkinBool(info.GetData1());
2449 if (info.GetData2())
2450 bReturn = g_settings.GetSkinString(info.GetData1()).Equals(m_stringParameters[info.GetData2()]);
2452 bReturn = !g_settings.GetSkinString(info.GetData1()).IsEmpty();
2455 case SKIN_HAS_THEME:
2457 CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme");
2459 URIUtils::RemoveExtension(theme);
2460 bReturn = theme.Equals(m_stringParameters[info.GetData1()]);
2463 case STRING_IS_EMPTY:
2464 // note: Get*Image() falls back to Get*Label(), so this should cover all of them
2465 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2466 bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).IsEmpty();
2468 bReturn = GetImage(info.GetData1(), contextWindow).IsEmpty();
2470 case STRING_COMPARE:
2473 if (info.GetData2() < 0) // info labels are stored with negative numbers
2475 int info2 = -info.GetData2();
2476 if (item && item->IsFileItem() && info2 >= LISTITEM_START && info2 < LISTITEM_END)
2477 compare = GetItemImage((const CFileItem *)item, info2);
2479 compare = GetImage(info2, contextWindow);
2481 else if (info.GetData2() < (int)m_stringParameters.size())
2482 { // conditional string
2483 compare = m_stringParameters[info.GetData2()];
2485 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2486 bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).Equals(compare);
2488 bReturn = GetImage(info.GetData1(), contextWindow).Equals(compare);
2491 case INTEGER_GREATER_THAN:
2494 if (GetInt(integer, info.GetData1(), contextWindow, item))
2495 bReturn = integer > info.GetData2();
2500 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2501 value = GetItemImage((const CFileItem *)item, info.GetData1());
2503 value = GetImage(info.GetData1(), contextWindow);
2505 // Handle the case when a value contains time separator (:). This makes IntegerGreaterThan
2506 // useful for Player.Time* members without adding a separate set of members returning time in seconds
2507 if ( value.find_first_of( ':' ) != value.npos )
2508 bReturn = StringUtils::TimeStringToSeconds( value ) > info.GetData2();
2510 bReturn = atoi( value.c_str() ) > info.GetData2();
2515 case STRING_STR_LEFT:
2516 case STRING_STR_RIGHT:
2518 CStdString compare = m_stringParameters[info.GetData2()];
2519 // our compare string is already in lowercase, so lower case our label as well
2520 // as CStdString::Find() is case sensitive
2522 if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
2523 label = GetItemImage((const CFileItem *)item, info.GetData1()).ToLower();
2525 label = GetImage(info.GetData1(), contextWindow).ToLower();
2526 if (condition == STRING_STR_LEFT)
2527 bReturn = label.Find(compare) == 0;
2528 else if (condition == STRING_STR_RIGHT)
2529 bReturn = label.Find(compare) == (int)(label.size()-compare.size());
2531 bReturn = label.Find(compare) > -1;
2534 case SYSTEM_ALARM_LESS_OR_EQUAL:
2536 int time = lrint(g_alarmClock.GetRemaining(m_stringParameters[info.GetData1()]));
2537 int timeCompare = atoi(m_stringParameters[info.GetData2()]);
2539 bReturn = timeCompare >= time;
2544 case SYSTEM_IDLE_TIME:
2545 bReturn = g_application.GlobalIdleTime() >= (int)info.GetData1();
2547 case CONTROL_GROUP_HAS_FOCUS:
2549 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2551 bReturn = window->ControlGroupHasFocus(info.GetData1(), info.GetData2());
2554 case CONTROL_IS_VISIBLE:
2556 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2559 // Note: This'll only work for unique id's
2560 const CGUIControl *control = window->GetControl(info.GetData1());
2562 bReturn = control->IsVisible();
2566 case CONTROL_IS_ENABLED:
2568 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2571 // Note: This'll only work for unique id's
2572 const CGUIControl *control = window->GetControl(info.GetData1());
2574 bReturn = !control->IsDisabled();
2578 case CONTROL_HAS_FOCUS:
2580 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2582 bReturn = (window->GetFocusedControlID() == (int)info.GetData1());
2586 if (info.GetData1())
2587 bReturn = ((int)info.GetData1() == m_nextWindowID);
2590 CGUIWindow *window = g_windowManager.GetWindow(m_nextWindowID);
2591 if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
2595 case WINDOW_PREVIOUS:
2596 if (info.GetData1())
2597 bReturn = ((int)info.GetData1() == m_prevWindowID);
2600 CGUIWindow *window = g_windowManager.GetWindow(m_prevWindowID);
2601 if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
2605 case WINDOW_IS_VISIBLE:
2606 if (info.GetData1())
2607 bReturn = g_windowManager.IsWindowVisible(info.GetData1());
2609 bReturn = g_windowManager.IsWindowVisible(m_stringParameters[info.GetData2()]);
2611 case WINDOW_IS_TOPMOST:
2612 if (info.GetData1())
2613 bReturn = g_windowManager.IsWindowTopMost(info.GetData1());
2615 bReturn = g_windowManager.IsWindowTopMost(m_stringParameters[info.GetData2()]);
2617 case WINDOW_IS_ACTIVE:
2618 if (info.GetData1())
2619 bReturn = g_windowManager.IsWindowActive(info.GetData1());
2621 bReturn = g_windowManager.IsWindowActive(m_stringParameters[info.GetData2()]);
2623 case SYSTEM_HAS_ALARM:
2624 bReturn = g_alarmClock.HasAlarm(m_stringParameters[info.GetData1()]);
2626 case SYSTEM_GET_BOOL:
2627 bReturn = g_guiSettings.GetBool(m_stringParameters[info.GetData1()]);
2629 case SYSTEM_HAS_CORE_ID:
2630 bReturn = g_cpuInfo.HasCoreId(info.GetData1());
2632 case SYSTEM_SETTING:
2634 if ( m_stringParameters[info.GetData1()].Equals("hidewatched") )
2636 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2638 bReturn = g_settings.GetWatchMode(((CGUIMediaWindow *)window)->CurrentDirectory().GetContent()) == VIDEO_SHOW_UNWATCHED;
2642 case SYSTEM_HAS_ADDON:
2645 bReturn = CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon) && addon;
2648 case CONTAINER_SCROLL_PREVIOUS:
2649 case CONTAINER_MOVE_PREVIOUS:
2650 case CONTAINER_MOVE_NEXT:
2651 case CONTAINER_SCROLL_NEXT:
2653 map<int,int>::const_iterator it = m_containerMoves.find(info.GetData1());
2654 if (it != m_containerMoves.end())
2656 if (condition > CONTAINER_STATIC) // moving up
2657 bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
2659 bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
2663 case CONTAINER_CONTENT:
2666 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2669 if (window->GetID() == WINDOW_DIALOG_MUSIC_INFO)
2670 content = ((CGUIDialogMusicInfo *)window)->CurrentDirectory().GetContent();
2671 else if (window->GetID() == WINDOW_DIALOG_VIDEO_INFO)
2672 content = ((CGUIDialogVideoInfo *)window)->CurrentDirectory().GetContent();
2674 if (content.IsEmpty())
2676 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2678 content = ((CGUIMediaWindow *)window)->CurrentDirectory().GetContent();
2680 bReturn = m_stringParameters[info.GetData2()].Equals(content);
2684 case CONTAINER_COLUMN:
2685 case CONTAINER_POSITION:
2686 case CONTAINER_HAS_NEXT:
2687 case CONTAINER_HAS_PREVIOUS:
2688 case CONTAINER_SCROLLING:
2689 case CONTAINER_SUBITEM:
2691 const CGUIControl *control = NULL;
2692 if (info.GetData1())
2693 { // container specified
2694 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2696 control = window->GetControl(info.GetData1());
2699 { // no container specified - assume a mediawindow
2700 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2702 control = window->GetControl(window->GetViewContainerID());
2705 bReturn = control->GetCondition(condition, info.GetData2());
2708 case CONTAINER_HAS_FOCUS:
2709 { // grab our container
2710 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2713 const CGUIControl *control = window->GetControl(info.GetData1());
2714 if (control && control->IsContainer())
2716 CFileItemPtr item = boost::static_pointer_cast<CFileItem>(((IGUIContainer *)control)->GetListItem(0));
2717 if (item && item->m_iprogramCount == info.GetData2()) // programcount used to store item id
2723 case VIDEOPLAYER_CONTENT:
2725 CStdString strContent="movies";
2726 if (!m_currentFile->HasVideoInfoTag() || m_currentFile->GetVideoInfoTag()->IsEmpty())
2727 strContent = "files";
2728 if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_iSeason > -1) // episode
2729 strContent = "episodes";
2730 if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_artist.empty())
2731 strContent = "musicvideos";
2732 if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_strStatus == "livetv")
2733 strContent = "livetv";
2734 if (m_currentFile->HasPVRChannelInfoTag())
2735 strContent = "livetv";
2736 bReturn = m_stringParameters[info.GetData1()].Equals(strContent);
2739 case CONTAINER_SORT_METHOD:
2741 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2744 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2746 bReturn = ((unsigned int)viewState->GetSortMethod() == info.GetData1());
2750 case CONTAINER_SORT_DIRECTION:
2752 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2755 const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
2757 bReturn = ((unsigned int)viewState->GetDisplaySortOrder() == info.GetData1());
2763 if (info.GetData2() == -1) // info doesn't contain valid startDate
2765 CDateTime date = CDateTime::GetCurrentDateTime();
2766 int currentDate = date.GetMonth()*100+date.GetDay();
2767 int startDate = info.GetData1();
2768 int stopDate = info.GetData2();
2770 if (stopDate < startDate)
2771 bReturn = currentDate >= startDate || currentDate < stopDate;
2773 bReturn = currentDate >= startDate && currentDate < stopDate;
2778 CDateTime time=CDateTime::GetCurrentDateTime();
2779 int currentTime = time.GetMinuteOfDay();
2780 int startTime = info.GetData1();
2781 int stopTime = info.GetData2();
2783 if (stopTime < startTime)
2784 bReturn = currentTime >= startTime || currentTime < stopTime;
2786 bReturn = currentTime >= startTime && currentTime < stopTime;
2789 case MUSICPLAYER_EXISTS:
2791 int index = info.GetData2();
2792 if (info.GetData1() == 1)
2794 if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
2796 index += g_playlistPlayer.GetCurrentSong();
2798 if (index >= 0 && index < g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size())
2805 return (info.m_info < 0) ? !bReturn : bReturn;
2808 bool CGUIInfoManager::GetMultiInfoInt(int &value, const GUIInfo &info, int contextWindow) const
2810 if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
2813 CGUIWindow *window = NULL;
2815 int data1 = info.GetData1();
2816 if (!data1) // No container specified, so we lookup the current view container
2818 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2819 if (window && window->IsMediaWindow())
2820 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2823 if (!window) // If we don't have a window already (from lookup above), get one
2824 window = GetWindowWithCondition(contextWindow, 0);
2828 const CGUIControl *control = window->GetControl(data1);
2829 if (control && control->IsContainer())
2830 item = boost::static_pointer_cast<CFileItem>(((IGUIContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
2833 if (item) // If we got a valid item, do the lookup
2834 return GetItemInt(value, item.get(), info.m_info);
2840 /// \brief Examines the multi information sent and returns the string as appropriate
2841 CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow, CStdString *fallback)
2843 if (info.m_info == SKIN_STRING)
2845 return g_settings.GetSkinString(info.GetData1());
2847 else if (info.m_info == SKIN_BOOL)
2849 bool bInfo = g_settings.GetSkinBool(info.GetData1());
2851 return g_localizeStrings.Get(20122);
2853 if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
2856 CGUIWindow *window = NULL;
2858 int data1 = info.GetData1();
2859 if (!data1) // No container specified, so we lookup the current view container
2861 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
2862 if (window && window->IsMediaWindow())
2863 data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
2866 if (!window) // If we don't have a window already (from lookup above), get one
2867 window = GetWindowWithCondition(contextWindow, 0);
2871 const CGUIControl *control = window->GetControl(data1);
2872 if (control && control->IsContainer())
2873 item = boost::static_pointer_cast<CFileItem>(((IGUIContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
2876 if (item) // If we got a valid item, do the lookup
2877 return GetItemImage(item.get(), info.m_info, fallback); // Image prioritizes images over labels (in the case of music item ratings for instance)
2879 else if (info.m_info == PLAYER_TIME)
2881 return GetCurrentPlayTime((TIME_FORMAT)info.GetData1());
2883 else if (info.m_info == PLAYER_TIME_REMAINING)
2885 return GetCurrentPlayTimeRemaining((TIME_FORMAT)info.GetData1());
2887 else if (info.m_info == PLAYER_FINISH_TIME)
2890 CEpgInfoTag currentTag;
2891 if (GetEpgInfoTag(currentTag))
2892 time = currentTag.EndAsLocalTime();
2895 time = CDateTime::GetCurrentDateTime();
2896 time += CDateTimeSpan(0, 0, 0, GetPlayTimeRemaining());
2898 return LocalizeTime(time, (TIME_FORMAT)info.GetData1());
2900 else if (info.m_info == PLAYER_START_TIME)
2903 CEpgInfoTag currentTag;
2904 if (GetEpgInfoTag(currentTag))
2905 time = currentTag.StartAsLocalTime();
2908 time = CDateTime::GetCurrentDateTime();
2909 time -= CDateTimeSpan(0, 0, 0, (int)GetPlayTime());
2911 return LocalizeTime(time, (TIME_FORMAT)info.GetData1());
2913 else if (info.m_info == PLAYER_TIME_SPEED)
2916 if (g_application.GetPlaySpeed() != 1)
2917 strTime.Format("%s (%ix)", GetCurrentPlayTime((TIME_FORMAT)info.GetData1()).c_str(), g_application.GetPlaySpeed());
2919 strTime = GetCurrentPlayTime();
2922 else if (info.m_info == PLAYER_DURATION)
2924 return GetDuration((TIME_FORMAT)info.GetData1());
2926 else if (info.m_info == PLAYER_SEEKTIME)
2928 return GetCurrentSeekTime((TIME_FORMAT)info.GetData1());
2930 else if (info.m_info == PLAYER_SEEKOFFSET)
2932 CStdString seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset), (TIME_FORMAT)info.GetData1());
2933 if (m_seekOffset < 0)
2934 return "-" + seekOffset;
2935 if (m_seekOffset > 0)
2936 return "+" + seekOffset;
2938 else if (info.m_info == PLAYER_ITEM_ART)
2940 return m_currentFile->GetArt(m_stringParameters[info.GetData1()]);
2942 else if (info.m_info == SYSTEM_TIME)
2944 return GetTime((TIME_FORMAT)info.GetData1());
2946 else if (info.m_info == SYSTEM_DATE)
2948 CDateTime time=CDateTime::GetCurrentDateTime();
2949 return time.GetAsLocalizedDate(m_stringParameters[info.GetData1()],false);
2951 else if (info.m_info == CONTAINER_NUM_PAGES || info.m_info == CONTAINER_CURRENT_PAGE ||
2952 info.m_info == CONTAINER_NUM_ITEMS || info.m_info == CONTAINER_POSITION)
2954 const CGUIControl *control = NULL;
2955 if (info.GetData1())
2956 { // container specified
2957 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
2959 control = window->GetControl(info.GetData1());
2962 { // no container specified - assume a mediawindow
2963 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2965 control = window->GetControl(window->GetViewContainerID());
2969 if (control->IsContainer())
2970 return ((IGUIContainer *)control)->GetLabel(info.m_info);
2971 else if (control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX)
2972 return ((CGUITextBox *)control)->GetLabel(info.m_info);
2975 else if (info.m_info == SYSTEM_GET_CORE_USAGE)
2978 strCpu.Format("%4.2f", g_cpuInfo.GetCoreInfo(atoi(m_stringParameters[info.GetData1()].c_str())).m_fPct);
2981 else if (info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST)
2982 return GetMusicPlaylistInfo(info);
2983 else if (info.m_info == CONTAINER_PROPERTY)
2985 CGUIWindow *window = NULL;
2986 if (info.GetData1())
2987 { // container specified
2988 window = GetWindowWithCondition(contextWindow, 0);
2991 { // no container specified - assume a mediawindow
2992 window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
2995 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty(m_stringParameters[info.GetData2()]).asString();
2997 else if (info.m_info == CONTROL_GET_LABEL)
2999 CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
3002 const CGUIControl *control = window->GetControl(info.GetData1());
3004 return control->GetDescription();
3007 else if (info.m_info == WINDOW_PROPERTY)
3009 CGUIWindow *window = NULL;
3010 if (info.GetData1())
3011 { // window specified
3012 window = g_windowManager.GetWindow(info.GetData1());//GetWindowWithCondition(contextWindow, 0);
3015 { // no window specified - assume active
3016 window = GetWindowWithCondition(contextWindow, 0);
3020 return window->GetProperty(m_stringParameters[info.GetData2()]).asString();
3022 else if (info.m_info == SYSTEM_ADDON_TITLE ||
3023 info.m_info == SYSTEM_ADDON_ICON)
3025 // This logic does not check/care whether an addon has been disabled/marked as broken,
3026 // it simply retrieves it's name or icon that means if an addon is placed on the home screen it
3027 // will stay there even if it's disabled/marked as broken. This might need to be changed/fixed
3030 if (info.GetData2() == 0)
3031 CAddonMgr::Get().GetAddon(const_cast<CGUIInfoManager*>(this)->GetLabel(info.GetData1(), contextWindow),addon,ADDON_UNKNOWN,false);
3033 CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon,ADDON_UNKNOWN,false);
3034 if (addon && info.m_info == SYSTEM_ADDON_TITLE)
3035 return addon->Name();
3036 if (addon && info.m_info == SYSTEM_ADDON_ICON)
3037 return addon->Icon();
3040 return StringUtils::EmptyString;
3043 /// \brief Obtains the filename of the image to show from whichever subsystem is needed
3044 CStdString CGUIInfoManager::GetImage(int info, int contextWindow, CStdString *fallback)
3046 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
3047 return GetSkinVariableString(info, true);
3049 if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
3051 return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow, fallback);
3053 else if (info == WEATHER_CONDITIONS)
3054 return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON);
3055 else if (info == SYSTEM_PROFILETHUMB)
3057 CStdString thumb = g_settings.GetCurrentProfile().getThumb();
3058 if (thumb.IsEmpty())
3059 thumb = "unknown-user.png";
3062 else if (info == MUSICPLAYER_COVER)
3064 if (!g_application.IsPlayingAudio()) return "";
3066 *fallback = "DefaultAlbumCover.png";
3067 return m_currentFile->HasArt("thumb") ? m_currentFile->GetArt("thumb") : "DefaultAlbumCover.png";
3069 else if (info == MUSICPLAYER_RATING)
3071 if (!g_application.IsPlayingAudio()) return "";
3072 return GetItemImage(m_currentFile, LISTITEM_RATING);
3074 else if (info == PLAYER_STAR_RATING)
3076 if (!g_application.IsPlaying()) return "";
3077 return GetItemImage(m_currentFile, LISTITEM_STAR_RATING);
3079 else if (info == VIDEOPLAYER_COVER)
3081 if (!g_application.IsPlayingVideo()) return "";
3083 *fallback = "DefaultVideoCover.png";
3084 if(m_currentMovieThumb.IsEmpty())
3085 return m_currentFile->HasArt("thumb") ? m_currentFile->GetArt("thumb") : "DefaultVideoCover.png";
3086 else return m_currentMovieThumb;
3088 else if (info == CONTAINER_FOLDERTHUMB)
3090 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3092 return GetItemImage(&const_cast<CFileItemList&>(((CGUIMediaWindow*)window)->CurrentDirectory()), LISTITEM_THUMB, fallback);
3094 else if (info == CONTAINER_TVSHOWTHUMB)
3096 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3098 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetArt("tvshow.thumb");
3100 else if (info == CONTAINER_SEASONTHUMB)
3102 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
3104 return ((CGUIMediaWindow *)window)->CurrentDirectory().GetArt("season.thumb");
3106 else if (info == LISTITEM_THUMB || info == LISTITEM_ICON || info == LISTITEM_ACTUAL_ICON ||
3107 info == LISTITEM_OVERLAY || info == LISTITEM_RATING || info == LISTITEM_STAR_RATING)
3109 CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
3112 CFileItemPtr item = window->GetCurrentListItem();
3114 return GetItemImage(item.get(), info, fallback);
3117 return GetLabel(info, contextWindow, fallback);
3120 CStdString CGUIInfoManager::GetDate(bool bNumbersOnly)
3122 CDateTime time=CDateTime::GetCurrentDateTime();
3123 return time.GetAsLocalizedDate(!bNumbersOnly);
3126 CStdString CGUIInfoManager::GetTime(TIME_FORMAT format) const
3128 CDateTime time=CDateTime::GetCurrentDateTime();
3129 return LocalizeTime(time, format);
3132 CStdString CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT format) const
3134 const CStdString timeFormat = g_langInfo.GetTimeFormat();
3135 bool use12hourclock = timeFormat.Find('h') != -1;
3138 case TIME_FORMAT_GUESS:
3139 return time.GetAsLocalizedTime("", false);
3140 case TIME_FORMAT_SS:
3141 return time.GetAsLocalizedTime("ss", true);
3142 case TIME_FORMAT_MM:
3143 return time.GetAsLocalizedTime("mm", true);
3144 case TIME_FORMAT_MM_SS:
3145 return time.GetAsLocalizedTime("mm:ss", true);
3146 case TIME_FORMAT_HH: // this forces it to a 12 hour clock
3147 return time.GetAsLocalizedTime(use12hourclock ? "h" : "HH", false);
3148 case TIME_FORMAT_HH_MM:
3149 return time.GetAsLocalizedTime(use12hourclock ? "h:mm" : "HH:mm", false);
3150 case TIME_FORMAT_HH_MM_XX:
3151 return time.GetAsLocalizedTime(use12hourclock ? "h:mm xx" : "HH:mm", false);
3152 case TIME_FORMAT_HH_MM_SS:
3153 return time.GetAsLocalizedTime("", true);
3155 return time.GetAsLocalizedTime("h", false);
3156 case TIME_FORMAT_H_MM_SS:
3157 return time.GetAsLocalizedTime("h:mm:ss", true);
3158 case TIME_FORMAT_XX:
3159 return use12hourclock ? time.GetAsLocalizedTime("xx", false) : "";
3163 return time.GetAsLocalizedTime("", false);
3166 CStdString CGUIInfoManager::GetDuration(TIME_FORMAT format) const
3168 if (g_application.IsPlayingAudio() && m_currentFile->HasMusicInfoTag())
3170 const CMusicInfoTag& tag = *m_currentFile->GetMusicInfoTag();
3171 if (tag.GetDuration() > 0)
3172 return StringUtils::SecondsToTimeString(tag.GetDuration(), format);
3174 if (g_application.IsPlayingVideo() && !m_currentMovieDuration.IsEmpty())
3175 return m_currentMovieDuration; // for tuxbox
3176 unsigned int iTotal = (unsigned int)g_application.GetTotalTime();
3178 return StringUtils::SecondsToTimeString(iTotal, format);
3182 CStdString CGUIInfoManager::GetMusicPartyModeLabel(int item)
3185 if (item >= MUSICPM_SONGSPLAYED && item <= MUSICPM_RANDOMSONGSPICKED)
3190 case MUSICPM_SONGSPLAYED:
3192 iSongs = g_partyModeManager.GetSongsPlayed();
3195 case MUSICPM_MATCHINGSONGS:
3197 iSongs = g_partyModeManager.GetMatchingSongs();
3200 case MUSICPM_MATCHINGSONGSPICKED:
3202 iSongs = g_partyModeManager.GetMatchingSongsPicked();
3205 case MUSICPM_MATCHINGSONGSLEFT:
3207 iSongs = g_partyModeManager.GetMatchingSongsLeft();
3210 case MUSICPM_RELAXEDSONGSPICKED:
3212 iSongs = g_partyModeManager.GetRelaxedSongs();
3215 case MUSICPM_RANDOMSONGSPICKED:
3217 iSongs = g_partyModeManager.GetRandomSongs();
3223 CStdString strLabel;
3224 strLabel.Format("%i", iSongs);
3230 const CStdString CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info)
3232 PLAYLIST::CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
3233 if (playlist.size() < 1)
3235 int index = info.GetData2();
3236 if (info.GetData1() == 1)
3237 { // relative index (requires current playlist is PLAYLIST_MUSIC)
3238 if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
3240 index = g_playlistPlayer.GetNextSong(index);
3242 if (index < 0 || index >= playlist.size())
3244 CFileItemPtr playlistItem = playlist[index];
3245 if (!playlistItem->GetMusicInfoTag()->Loaded())
3247 playlistItem->LoadMusicTag();
3248 playlistItem->GetMusicInfoTag()->SetLoaded();
3250 // try to set a thumbnail
3251 if (!playlistItem->HasArt("thumb"))
3253 CMusicThumbLoader loader;
3254 loader.LoadItem(playlistItem.get());
3255 // still no thumb? then just the set the default cover
3256 if (!playlistItem->HasArt("thumb"))
3257 playlistItem->SetArt("thumb", "DefaultAlbumCover.png");
3259 if (info.m_info == MUSICPLAYER_PLAYLISTPOS)
3261 CStdString strPosition = "";
3262 strPosition.Format("%i", index + 1);
3265 else if (info.m_info == MUSICPLAYER_COVER)
3266 return playlistItem->GetArt("thumb");
3267 return GetMusicTagLabel(info.m_info, playlistItem.get());
3270 CStdString CGUIInfoManager::GetPlaylistLabel(int item) const
3272 if (!g_application.IsPlaying()) return "";
3273 int iPlaylist = g_playlistPlayer.GetCurrentPlaylist();
3276 case PLAYLIST_LENGTH:
3278 CStdString strLength = "";
3279 strLength.Format("%i", g_playlistPlayer.GetPlaylist(iPlaylist).size());
3282 case PLAYLIST_POSITION:
3284 CStdString strPosition = "";
3285 strPosition.Format("%i", g_playlistPlayer.GetCurrentSong() + 1);
3288 case PLAYLIST_RANDOM:
3290 if (g_playlistPlayer.IsShuffled(iPlaylist))
3291 return g_localizeStrings.Get(590); // 590: Random
3293 return g_localizeStrings.Get(591); // 591: Off
3295 case PLAYLIST_REPEAT:
3297 PLAYLIST::REPEAT_STATE state = g_playlistPlayer.GetRepeat(iPlaylist);
3298 if (state == PLAYLIST::REPEAT_ONE)
3299 return g_localizeStrings.Get(592); // 592: One
3300 else if (state == PLAYLIST::REPEAT_ALL)
3301 return g_localizeStrings.Get(593); // 593: All
3303 return g_localizeStrings.Get(594); // 594: Off
3309 CStdString CGUIInfoManager::GetMusicLabel(int item)
3311 if (!g_application.IsPlaying() || !m_currentFile->HasMusicInfoTag()) return "";
3313 SPlayerAudioStreamInfo info;
3314 g_application.m_pPlayer->GetAudioStreamInfo(g_application.m_pPlayer->GetAudioStream(), info);
3318 case MUSICPLAYER_PLAYLISTLEN:
3320 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
3321 return GetPlaylistLabel(PLAYLIST_LENGTH);
3324 case MUSICPLAYER_PLAYLISTPOS:
3326 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
3327 return GetPlaylistLabel(PLAYLIST_POSITION);
3330 case MUSICPLAYER_BITRATE:
3332 float fTimeSpan = (float)(CTimeUtils::GetFrameTime() - m_lastMusicBitrateTime);
3333 if (fTimeSpan >= 500.0f)
3335 m_MusicBitrate = info.bitrate;
3336 m_lastMusicBitrateTime = CTimeUtils::GetFrameTime();
3338 CStdString strBitrate = "";
3339 if (m_MusicBitrate > 0)
3340 strBitrate.Format("%i", MathUtils::round_int((double)m_MusicBitrate / 1000.0));
3344 case MUSICPLAYER_CHANNELS:
3346 CStdString strChannels = "";
3347 if (info.channels > 0)
3349 strChannels.Format("%i", info.channels);
3354 case MUSICPLAYER_BITSPERSAMPLE:
3356 CStdString strBitsPerSample = "";
3357 if (g_application.m_pPlayer->GetBitsPerSample() > 0)
3359 strBitsPerSample.Format("%i", g_application.m_pPlayer->GetBitsPerSample());
3361 return strBitsPerSample;
3364 case MUSICPLAYER_SAMPLERATE:
3366 CStdString strSampleRate = "";
3367 if (g_application.m_pPlayer->GetSampleRate() > 0)
3369 strSampleRate.Format("%.5g", ((double)g_application.m_pPlayer->GetSampleRate() / 1000.0));
3371 return strSampleRate;
3374 case MUSICPLAYER_CODEC:
3376 CStdString strCodec;
3377 strCodec.Format("%s", info.audioCodecName);
3381 case MUSICPLAYER_LYRICS:
3382 return GetItemLabel(m_currentFile, AddListItemProp("lyrics"));
3384 return GetMusicTagLabel(item, m_currentFile);
3387 CStdString CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item)
3389 if (!item->HasMusicInfoTag()) return "";
3390 const CMusicInfoTag &tag = *item->GetMusicInfoTag();
3393 case MUSICPLAYER_TITLE:
3394 if (tag.GetTitle().size()) { return tag.GetTitle(); }
3396 case MUSICPLAYER_ALBUM:
3397 if (tag.GetAlbum().size()) { return tag.GetAlbum(); }
3399 case MUSICPLAYER_ARTIST:
3400 if (tag.GetArtist().size()) { return StringUtils::Join(tag.GetArtist(), g_advancedSettings.m_musicItemSeparator); }
3402 case MUSICPLAYER_ALBUM_ARTIST:
3403 if (tag.GetAlbumArtist().size()) { return StringUtils::Join(tag.GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator); }
3405 case MUSICPLAYER_YEAR:
3406 if (tag.GetYear()) { return tag.GetYearString(); }
3408 case MUSICPLAYER_GENRE:
3409 if (tag.GetGenre().size()) { return StringUtils::Join(tag.GetGenre(), g_advancedSettings.m_musicItemSeparator); }
3411 case MUSICPLAYER_LYRICS:
3412 if (tag.GetLyrics().size()) { return tag.GetLyrics(); }
3414 case MUSICPLAYER_TRACK_NUMBER:
3416 CStdString strTrack;
3417 if (tag.Loaded() && tag.GetTrackNumber() > 0)
3419 strTrack.Format("%02i", tag.GetTrackNumber());
3424 case MUSICPLAYER_DISC_NUMBER:
3425 return GetItemLabel(item, LISTITEM_DISC_NUMBER);
3426 case MUSICPLAYER_RATING:
3427 return GetItemLabel(item, LISTITEM_RATING);
3428 case MUSICPLAYER_COMMENT:
3429 return GetItemLabel(item, LISTITEM_COMMENT);
3430 case MUSICPLAYER_DURATION:
3431 return GetItemLabel(item, LISTITEM_DURATION);
3432 case MUSICPLAYER_CHANNEL_NAME:
3434 CPVRChannel* channeltag = m_currentFile->GetPVRChannelInfoTag();
3436 return channeltag->ChannelName();
3439 case MUSICPLAYER_CHANNEL_NUMBER:
3441 CPVRChannel* channeltag = m_currentFile->GetPVRChannelInfoTag();
3444 CStdString strNumber;
3445 strNumber.Format("%i", channeltag->ChannelNumber());
3450 case MUSICPLAYER_CHANNEL_GROUP:
3452 CPVRChannel* channeltag = m_currentFile->GetPVRChannelInfoTag();
3453 if (channeltag && channeltag->IsRadio())
3454 return g_PVRManager.GetPlayingGroup(true)->GroupName();
3457 case MUSICPLAYER_PLAYCOUNT:
3458 return GetItemLabel(item, LISTITEM_PLAYCOUNT);
3459 case MUSICPLAYER_LASTPLAYED:
3460 return GetItemLabel(item, LISTITEM_LASTPLAYED);
3465 CStdString CGUIInfoManager::GetVideoLabel(int item)
3467 if (!g_application.IsPlaying())
3470 if (item == VIDEOPLAYER_TITLE)
3472 if(g_application.IsPlayingVideo())
3473 return GetLabel(PLAYER_TITLE);
3475 else if (item == VIDEOPLAYER_PLAYLISTLEN)
3477 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3478 return GetPlaylistLabel(PLAYLIST_LENGTH);
3480 else if (item == VIDEOPLAYER_PLAYLISTPOS)
3482 if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
3483 return GetPlaylistLabel(PLAYLIST_POSITION);
3485 else if (m_currentFile->HasPVRChannelInfoTag())
3487 CPVRChannel* tag = m_currentFile->GetPVRChannelInfoTag();
3492 /* Now playing infos */
3493 case VIDEOPLAYER_ORIGINALTITLE:
3494 return tag->GetEPGNow(epgTag) ?
3496 g_guiSettings.GetBool("epg.hidenoinfoavailable") ?
3497 StringUtils::EmptyString :
3498 g_localizeStrings.Get(19055); // no information available
3499 case VIDEOPLAYER_GENRE:
3500 return tag->GetEPGNow(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : StringUtils::EmptyString;
3501 case VIDEOPLAYER_PLOT:
3502 return tag->GetEPGNow(epgTag) ? epgTag.Plot() : StringUtils::EmptyString;
3503 case VIDEOPLAYER_PLOT_OUTLINE:
3504 return tag->GetEPGNow(epgTag) ? epgTag.PlotOutline() : StringUtils::EmptyString;
3505 case VIDEOPLAYER_STARTTIME:
3506 return tag->GetEPGNow(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3507 case VIDEOPLAYER_ENDTIME:
3508 return tag->GetEPGNow(epgTag) ? epgTag.EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3510 /* Next playing infos */
3511 case VIDEOPLAYER_NEXT_TITLE:
3512 return tag->GetEPGNext(epgTag) ?
3514 g_guiSettings.GetBool("epg.hidenoinfoavailable") ?
3515 StringUtils::EmptyString :
3516 g_localizeStrings.Get(19055); // no information available
3517 case VIDEOPLAYER_NEXT_GENRE:
3518 return tag->GetEPGNext(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : StringUtils::EmptyString;
3519 case VIDEOPLAYER_NEXT_PLOT:
3520 return tag->GetEPGNext(epgTag) ? epgTag.Plot() : StringUtils::EmptyString;
3521 case VIDEOPLAYER_NEXT_PLOT_OUTLINE:
3522 return tag->GetEPGNext(epgTag) ? epgTag.PlotOutline() : StringUtils::EmptyString;
3523 case VIDEOPLAYER_NEXT_STARTTIME:
3524 return tag->GetEPGNext(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3525 case VIDEOPLAYER_NEXT_ENDTIME:
3526 return tag->GetEPGNext(epgTag) ? epgTag.EndAsLocalTime().GetAsLocalizedTime("", false) : CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
3527 case VIDEOPLAYER_NEXT_DURATION:
3529 CStdString duration;
3530 if (tag->GetEPGNext(epgTag) && epgTag.GetDuration() > 0)
3531 duration = StringUtils::SecondsToTimeString(epgTag.GetDuration());
3535 case VIDEOPLAYER_PARENTAL_RATING:
3538 if (tag->GetEPGNow(epgTag) && epgTag.ParentalRating() > 0)
3539 rating.Format("%i", epgTag.ParentalRating());
3544 /* General channel infos */
3545 case VIDEOPLAYER_CHANNEL_NAME:
3546 return tag->ChannelName();
3547 case VIDEOPLAYER_CHANNEL_NUMBER:
3549 CStdString strNumber;
3550 strNumber.Format("%i", tag->ChannelNumber());
3553 case VIDEOPLAYER_CHANNEL_GROUP:
3555 if (tag && !tag->IsRadio())
3556 return g_PVRManager.GetPlayingGroup(false)->GroupName();
3560 else if (m_currentFile->HasVideoInfoTag())
3564 case VIDEOPLAYER_ORIGINALTITLE:
3565 return m_currentFile->GetVideoInfoTag()->m_strOriginalTitle;
3567 case VIDEOPLAYER_GENRE:
3568 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
3570 case VIDEOPLAYER_DIRECTOR:
3571 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
3573 case VIDEOPLAYER_RATING:
3575 CStdString strRating;
3576 if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3577 strRating.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
3581 case VIDEOPLAYER_RATING_AND_VOTES:
3583 CStdString strRatingAndVotes;
3584 if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
3586 if (m_currentFile->GetVideoInfoTag()->m_strVotes.IsEmpty())
3587 strRatingAndVotes.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
3589 strRatingAndVotes.Format("%.1f (%s %s)", m_currentFile->GetVideoInfoTag()->m_fRating, m_currentFile->GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
3591 return strRatingAndVotes;
3594 case VIDEOPLAYER_YEAR:
3597 if (m_currentFile->GetVideoInfoTag()->m_iYear > 0)
3598 strYear.Format("%i", m_currentFile->GetVideoInfoTag()->m_iYear);
3602 case VIDEOPLAYER_PREMIERED:
3605 if (m_currentFile->GetVideoInfoTag()->m_firstAired.IsValid())
3606 dateTime = m_currentFile->GetVideoInfoTag()->m_firstAired;
3607 else if (m_currentFile->GetVideoInfoTag()->m_premiered.IsValid())
3608 dateTime = m_currentFile->GetVideoInfoTag()->m_premiered;
3610 if (dateTime.IsValid())
3611 return dateTime.GetAsLocalizedDate();
3615 case VIDEOPLAYER_PLOT:
3616 return m_currentFile->GetVideoInfoTag()->m_strPlot;
3617 case VIDEOPLAYER_TRAILER:
3618 return m_currentFile->GetVideoInfoTag()->m_strTrailer;
3619 case VIDEOPLAYER_PLOT_OUTLINE:
3620 return m_currentFile->GetVideoInfoTag()->m_strPlotOutline;
3621 case VIDEOPLAYER_EPISODE:
3623 CStdString strEpisode;
3624 if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
3625 strEpisode.Format("S%i", m_currentFile->GetVideoInfoTag()->m_iSpecialSortEpisode);
3626 else if(m_currentFile->GetVideoInfoTag()->m_iEpisode > 0)
3627 strEpisode.Format("%i", m_currentFile->GetVideoInfoTag()->m_iEpisode);
3631 case VIDEOPLAYER_SEASON:
3633 CStdString strSeason;
3634 if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason > 0)
3635 strSeason.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason);
3636 else if(m_currentFile->GetVideoInfoTag()->m_iSeason > 0)
3637 strSeason.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSeason);
3641 case VIDEOPLAYER_TVSHOW:
3642 return m_currentFile->GetVideoInfoTag()->m_strShowTitle;
3644 case VIDEOPLAYER_STUDIO:
3645 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_studio, g_advancedSettings.m_videoItemSeparator);
3646 case VIDEOPLAYER_COUNTRY:
3647 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_country, g_advancedSettings.m_videoItemSeparator);
3648 case VIDEOPLAYER_MPAA:
3649 return m_currentFile->GetVideoInfoTag()->m_strMPAARating;
3650 case VIDEOPLAYER_TOP250:
3652 CStdString strTop250;
3653 if (m_currentFile->GetVideoInfoTag()->m_iTop250 > 0)
3654 strTop250.Format("%i", m_currentFile->GetVideoInfoTag()->m_iTop250);
3658 case VIDEOPLAYER_CAST:
3659 return m_currentFile->GetVideoInfoTag()->GetCast();
3660 case VIDEOPLAYER_CAST_AND_ROLE:
3661 return m_currentFile->GetVideoInfoTag()->GetCast(true);
3662 case VIDEOPLAYER_ARTIST:
3663 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
3664 case VIDEOPLAYER_ALBUM:
3665 return m_currentFile->GetVideoInfoTag()->m_strAlbum;
3666 case VIDEOPLAYER_WRITER:
3667 return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_writingCredits, g_advancedSettings.m_videoItemSeparator);
3668 case VIDEOPLAYER_TAGLINE:
3669 return m_currentFile->GetVideoInfoTag()->m_strTagLine;
3670 case VIDEOPLAYER_LASTPLAYED:
3672 if (m_currentFile->GetVideoInfoTag()->m_lastPlayed.IsValid())
3673 return m_currentFile->GetVideoInfoTag()->m_lastPlayed.GetAsLocalizedDateTime();
3676 case VIDEOPLAYER_PLAYCOUNT:
3678 CStdString strPlayCount;
3679 if (m_currentFile->GetVideoInfoTag()->m_playCount > 0)
3680 strPlayCount.Format("%i", m_currentFile->GetVideoInfoTag()->m_playCount);
3681 return strPlayCount;
3688 int64_t CGUIInfoManager::GetPlayTime() const
3690 if (g_application.IsPlaying())
3692 int64_t lPTS = (int64_t)(g_application.GetTime() * 1000);
3693 if (lPTS < 0) lPTS = 0;
3699 CStdString CGUIInfoManager::GetCurrentPlayTime(TIME_FORMAT format) const
3701 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3702 format = TIME_FORMAT_HH_MM_SS;
3703 if (g_application.IsPlaying())
3704 return StringUtils::SecondsToTimeString((int)(GetPlayTime()/1000), format);
3708 CStdString CGUIInfoManager::GetCurrentSeekTime(TIME_FORMAT format) const
3710 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3711 format = TIME_FORMAT_HH_MM_SS;
3712 float time = GetTotalPlayTime() * g_application.GetSeekHandler()->GetPercent() * 0.01f;
3713 return StringUtils::SecondsToTimeString((int)time, format);
3716 int CGUIInfoManager::GetTotalPlayTime() const
3718 int iTotalTime = (int)g_application.GetTotalTime();
3719 return iTotalTime > 0 ? iTotalTime : 0;
3722 int CGUIInfoManager::GetPlayTimeRemaining() const
3724 int iReverse = GetTotalPlayTime() - (int)g_application.GetTime();
3725 return iReverse > 0 ? iReverse : 0;
3728 CStdString CGUIInfoManager::GetCurrentPlayTimeRemaining(TIME_FORMAT format) const
3730 if (format == TIME_FORMAT_GUESS && GetTotalPlayTime() >= 3600)
3731 format = TIME_FORMAT_HH_MM_SS;
3732 int timeRemaining = GetPlayTimeRemaining();
3733 if (timeRemaining && g_application.IsPlaying())
3734 return StringUtils::SecondsToTimeString(timeRemaining, format);
3738 void CGUIInfoManager::ResetCurrentItem()
3740 m_currentFile->Reset();
3741 m_currentMovieThumb = "";
3742 m_currentMovieDuration = "";
3745 void CGUIInfoManager::SetCurrentItem(CFileItem &item)
3750 SetCurrentSong(item);
3752 SetCurrentMovie(item);
3754 if (item.HasEPGInfoTag())
3755 *m_currentFile->GetEPGInfoTag() = *item.GetEPGInfoTag();
3756 else if (item.HasPVRChannelInfoTag())
3759 if (item.GetPVRChannelInfoTag()->GetEPGNow(tag))
3760 *m_currentFile->GetEPGInfoTag() = tag;
3764 NotifyObservers(ObservableMessageCurrentItem);
3767 void CGUIInfoManager::SetCurrentAlbumThumb(const CStdString thumbFileName)
3769 if (CFile::Exists(thumbFileName))
3770 m_currentFile->SetArt("thumb", thumbFileName);
3773 m_currentFile->SetArt("thumb", "");
3774 m_currentFile->FillInDefaultIcon();
3778 void CGUIInfoManager::SetCurrentSong(CFileItem &item)
3780 CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentSong(%s)",item.GetPath().c_str());
3781 *m_currentFile = item;
3783 m_currentFile->LoadMusicTag();
3784 if (m_currentFile->GetMusicInfoTag()->GetTitle().IsEmpty())
3786 // No title in tag, show filename only
3787 m_currentFile->GetMusicInfoTag()->SetTitle(CUtil::GetTitleFromPath(m_currentFile->GetPath()));
3789 m_currentFile->GetMusicInfoTag()->SetLoaded(true);
3791 // find a thumb for this file.
3792 if (m_currentFile->IsInternetStream())
3794 if (!g_application.m_strPlayListFile.IsEmpty())
3796 CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
3797 CFileItem streamingItem(g_application.m_strPlayListFile,false);
3798 CMusicThumbLoader::FillThumb(streamingItem);
3799 if (streamingItem.HasArt("thumb"))
3800 m_currentFile->SetArt("thumb", streamingItem.GetArt("thumb"));
3805 CMusicThumbLoader loader;
3806 loader.LoadItem(m_currentFile);
3808 m_currentFile->FillInDefaultIcon();
3810 CMusicInfoLoader::LoadAdditionalTagInfo(m_currentFile);
3813 void CGUIInfoManager::SetCurrentMovie(CFileItem &item)
3815 CLog::Log(LOGDEBUG,"CGUIInfoManager::SetCurrentMovie(%s)",item.GetPath().c_str());
3816 *m_currentFile = item;
3818 /* also call GetMovieInfo() when a VideoInfoTag is already present or additional info won't be present in the tag */
3819 if (!m_currentFile->HasPVRChannelInfoTag())
3824 dbs.LoadVideoInfo(item.GetPath(), *m_currentFile->GetVideoInfoTag());
3829 // Find a thumb for this file.
3830 if (!item.HasArt("thumb"))
3832 CVideoThumbLoader loader;
3833 loader.LoadItem(m_currentFile);
3836 // find a thumb for this stream
3837 if (item.IsInternetStream())
3839 // case where .strm is used to start an audio stream
3840 if (g_application.IsPlayingAudio())
3842 SetCurrentSong(item);
3847 if (!g_application.m_strPlayListFile.IsEmpty())
3849 CLog::Log(LOGDEBUG,"Streaming media detected... using %s to find a thumb", g_application.m_strPlayListFile.c_str());
3850 CFileItem thumbItem(g_application.m_strPlayListFile,false);
3851 if (CVideoThumbLoader::FillThumb(thumbItem))
3852 item.SetArt("thumb", thumbItem.GetArt("thumb"));
3856 item.FillInDefaultIcon();
3857 m_currentMovieThumb = item.GetArt("thumb");
3860 string CGUIInfoManager::GetSystemHeatInfo(int info)
3862 if (CTimeUtils::GetFrameTime() - m_lastSysHeatInfoTime >= SYSHEATUPDATEINTERVAL)
3863 { // update our variables
3864 m_lastSysHeatInfoTime = CTimeUtils::GetFrameTime();
3866 g_cpuInfo.getTemperature(m_cpuTemp);
3867 m_gpuTemp = GetGPUTemperature();
3874 case SYSTEM_CPU_TEMPERATURE:
3875 return m_cpuTemp.IsValid() ? m_cpuTemp.ToString() : "?";
3877 case SYSTEM_GPU_TEMPERATURE:
3878 return m_gpuTemp.IsValid() ? m_gpuTemp.ToString() : "?";
3880 case SYSTEM_FAN_SPEED:
3881 text.Format("%i%%", m_fanSpeed * 2);
3883 case SYSTEM_CPU_USAGE:
3884 #if defined(TARGET_DARWIN) || defined(_WIN32)
3885 text.Format("%d%%", g_cpuInfo.getUsedPercentage());
3887 text.Format("%s", g_cpuInfo.GetCoresUsageString());
3894 CTemperature CGUIInfoManager::GetGPUTemperature()
3896 CStdString cmd = g_advancedSettings.m_gpuTempCmd;
3902 if (cmd.IsEmpty() || !(p = popen(cmd.c_str(), "r")))
3903 return CTemperature();
3905 ret = fscanf(p, "%d %c", &value, &scale);
3909 return CTemperature();
3911 if (scale == 'C' || scale == 'c')
3912 return CTemperature::CreateFromCelsius(value);
3913 if (scale == 'F' || scale == 'f')
3914 return CTemperature::CreateFromFahrenheit(value);
3915 return CTemperature();
3918 // Version string MUST NOT contain spaces. It is used
3919 // in the HTTP request user agent.
3920 CStdString CGUIInfoManager::GetVersion()
3924 tmp.Format("%d.%d%s Git:%s", VERSION_MAJOR, VERSION_MINOR, VERSION_TAG, GIT_REV);
3926 tmp.Format("%d.%d%s", VERSION_MAJOR, VERSION_MINOR, VERSION_TAG);
3931 CStdString CGUIInfoManager::GetBuild()
3934 tmp.Format("%s", __DATE__);
3938 void CGUIInfoManager::SetDisplayAfterSeek(unsigned int timeOut, int seekOffset)
3940 g_infoManager.m_performingSeek = false;
3943 m_AfterSeekTimeout = CTimeUtils::GetFrameTime() + timeOut;
3945 m_seekOffset = seekOffset;
3948 m_AfterSeekTimeout = 0;
3951 bool CGUIInfoManager::GetDisplayAfterSeek()
3953 if (CTimeUtils::GetFrameTime() < m_AfterSeekTimeout)
3959 void CGUIInfoManager::Clear()
3961 CSingleLock lock(m_critInfo);
3962 for (unsigned int i = 0; i < m_bools.size(); ++i)
3966 m_skinVariableStrings.clear();
3969 void CGUIInfoManager::UpdateFPS()
3972 unsigned int curTime = CTimeUtils::GetFrameTime();
3974 float fTimeSpan = (float)(curTime - m_lastFPSTime);
3975 if (fTimeSpan >= 1000.0f)
3977 fTimeSpan /= 1000.0f;
3978 m_fps = m_frameCounter / fTimeSpan;
3979 m_lastFPSTime = curTime;
3984 int CGUIInfoManager::AddListItemProp(const CStdString &str, int offset)
3986 for (int i=0; i < (int)m_listitemProperties.size(); i++)
3987 if (m_listitemProperties[i] == str)
3988 return (LISTITEM_PROPERTY_START+offset + i);
3990 if (m_listitemProperties.size() < LISTITEM_PROPERTY_END - LISTITEM_PROPERTY_START)
3992 m_listitemProperties.push_back(str);
3993 return LISTITEM_PROPERTY_START + offset + m_listitemProperties.size() - 1;
3996 CLog::Log(LOGERROR,"%s - not enough listitem property space!", __FUNCTION__);
4000 int CGUIInfoManager::AddMultiInfo(const GUIInfo &info)
4002 // check to see if we have this info already
4003 for (unsigned int i = 0; i < m_multiInfo.size(); i++)
4004 if (m_multiInfo[i] == info)
4005 return (int)i + MULTI_INFO_START;
4006 // return the new offset
4007 m_multiInfo.push_back(info);
4008 int id = (int)m_multiInfo.size() + MULTI_INFO_START - 1;
4009 if (id > MULTI_INFO_END)
4010 CLog::Log(LOGERROR, "%s - too many multiinfo bool/labels in this skin", __FUNCTION__);
4014 int CGUIInfoManager::ConditionalStringParameter(const CStdString ¶meter, bool caseSensitive /*= false*/)
4016 // check to see if we have this parameter already
4017 for (unsigned int i = 0; i < m_stringParameters.size(); i++)
4018 if (parameter.Equals(m_stringParameters[i], caseSensitive))
4020 // return the new offset
4021 m_stringParameters.push_back(parameter);
4022 return (int)m_stringParameters.size() - 1;
4025 bool CGUIInfoManager::GetItemInt(int &value, const CGUIListItem *item, int info) const
4033 if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4034 { // grab the property
4035 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
4036 CStdString val = item->GetProperty(property).asString();
4043 case LISTITEM_PROGRESS:
4046 if (item->IsFileItem())
4048 const CFileItem *pItem = (const CFileItem *)item;
4049 if (pItem && pItem->HasPVRChannelInfoTag())
4052 if (pItem->GetPVRChannelInfoTag()->GetEPGNow(epgNow))
4053 value = (int) epgNow.ProgressPercentage();
4055 else if (pItem && pItem->HasEPGInfoTag())
4057 value = (int) pItem->GetEPGInfoTag()->ProgressPercentage();
4064 case LISTITEM_PERCENT_PLAYED:
4065 if (item->IsFileItem() && ((const CFileItem *)item)->HasVideoInfoTag() && ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.IsPartWay())
4066 value = (int)(100 * ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds / ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds);
4067 else if (item->IsFileItem() && ((const CFileItem *)item)->HasPVRRecordingInfoTag() && ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.IsPartWay())
4068 value = (int)(100 * ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.timeInSeconds / ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.totalTimeInSeconds);
4078 CStdString CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, CStdString *fallback)
4080 if (!item) return "";
4082 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
4083 return GetSkinVariableString(info, false, item);
4085 if (info >= LISTITEM_PROPERTY_START + LISTITEM_ART_OFFSET && info - (LISTITEM_PROPERTY_START + LISTITEM_ART_OFFSET) < (int)m_listitemProperties.size())
4087 std::string art = m_listitemProperties[info - (LISTITEM_PROPERTY_START + LISTITEM_ART_OFFSET)];
4088 return item->GetArt(art);
4091 if (info >= LISTITEM_PROPERTY_START && info - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4092 { // grab the property
4093 CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START];
4094 return item->GetProperty(property).asString();
4097 if (info >= LISTITEM_PICTURE_START && info <= LISTITEM_PICTURE_END && item->HasPictureInfoTag())
4098 return item->GetPictureInfoTag()->GetInfo(picture_slide_map[info - LISTITEM_PICTURE_START]);
4102 case LISTITEM_LABEL:
4103 return item->GetLabel();
4104 case LISTITEM_LABEL2:
4105 return item->GetLabel2();
4106 case LISTITEM_TITLE:
4107 if (item->HasPVRChannelInfoTag())
4110 return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ?
4112 g_guiSettings.GetBool("epg.hidenoinfoavailable") ?
4113 StringUtils::EmptyString :
4114 g_localizeStrings.Get(19055); // no information available
4116 if (item->HasPVRRecordingInfoTag())
4117 return item->GetPVRRecordingInfoTag()->m_strTitle;
4118 if (item->HasEPGInfoTag())
4119 return item->GetEPGInfoTag()->Title();
4120 if (item->HasPVRTimerInfoTag())
4121 return item->GetPVRTimerInfoTag()->Title();
4122 if (item->HasVideoInfoTag())
4123 return item->GetVideoInfoTag()->m_strTitle;
4124 if (item->HasMusicInfoTag())
4125 return item->GetMusicInfoTag()->GetTitle();
4127 case LISTITEM_ORIGINALTITLE:
4128 if (item->HasVideoInfoTag())
4129 return item->GetVideoInfoTag()->m_strOriginalTitle;
4131 case LISTITEM_PLAYCOUNT:
4133 CStdString strPlayCount;
4134 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_playCount > 0)
4135 strPlayCount.Format("%i", item->GetVideoInfoTag()->m_playCount);
4136 if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetPlayCount() > 0)
4137 strPlayCount.Format("%i", item->GetMusicInfoTag()->GetPlayCount());
4138 return strPlayCount;
4140 case LISTITEM_LASTPLAYED:
4143 if (item->HasVideoInfoTag())
4144 dateTime = item->GetVideoInfoTag()->m_lastPlayed;
4145 else if (item->HasMusicInfoTag())
4146 dateTime = item->GetMusicInfoTag()->GetLastPlayed();
4148 if (dateTime.IsValid())
4149 return dateTime.GetAsLocalizedDate();
4152 case LISTITEM_TRACKNUMBER:
4155 if (item->HasMusicInfoTag())
4156 track.Format("%i", item->GetMusicInfoTag()->GetTrackNumber());
4160 case LISTITEM_DISC_NUMBER:
4163 if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDiscNumber() > 0)
4164 disc.Format("%i", item->GetMusicInfoTag()->GetDiscNumber());
4167 case LISTITEM_ARTIST:
4168 if (item->HasVideoInfoTag())
4169 return StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
4170 if (item->HasMusicInfoTag())
4171 return StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
4173 case LISTITEM_ALBUM_ARTIST:
4174 if (item->HasMusicInfoTag())
4175 return StringUtils::Join(item->GetMusicInfoTag()->GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator);
4177 case LISTITEM_DIRECTOR:
4178 if (item->HasVideoInfoTag())
4179 return StringUtils::Join(item->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
4181 case LISTITEM_ALBUM:
4182 if (item->HasVideoInfoTag())
4183 return item->GetVideoInfoTag()->m_strAlbum;
4184 if (item->HasMusicInfoTag())
4185 return item->GetMusicInfoTag()->GetAlbum();
4188 if (item->HasVideoInfoTag())
4190 CStdString strResult;
4191 if (item->GetVideoInfoTag()->m_iYear > 0)
4192 strResult.Format("%i",item->GetVideoInfoTag()->m_iYear);
4195 if (item->HasMusicInfoTag())
4196 return item->GetMusicInfoTag()->GetYearString();
4198 case LISTITEM_PREMIERED:
4199 if (item->HasVideoInfoTag())
4202 if (item->GetVideoInfoTag()->m_firstAired.IsValid())
4203 dateTime = item->GetVideoInfoTag()->m_firstAired;
4204 else if (item->GetVideoInfoTag()->m_premiered.IsValid())
4205 dateTime = item->GetVideoInfoTag()->m_premiered;
4207 if (dateTime.IsValid())
4208 return dateTime.GetAsLocalizedDate();
4212 case LISTITEM_GENRE:
4213 if (item->HasVideoInfoTag())
4214 return StringUtils::Join(item->GetVideoInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
4215 if (item->HasMusicInfoTag())
4216 return StringUtils::Join(item->GetMusicInfoTag()->GetGenre(), g_advancedSettings.m_musicItemSeparator);
4217 if (item->HasPVRChannelInfoTag())
4220 return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? StringUtils::Join(epgTag.Genre(), g_advancedSettings.m_videoItemSeparator) : StringUtils::EmptyString;
4222 if (item->HasPVRRecordingInfoTag())
4223 return StringUtils::Join(item->GetPVRRecordingInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
4224 if (item->HasEPGInfoTag())
4225 return StringUtils::Join(item->GetEPGInfoTag()->Genre(), g_advancedSettings.m_videoItemSeparator);
4227 case LISTITEM_FILENAME:
4228 case LISTITEM_FILE_EXTENSION:
4231 if (item->IsMusicDb() && item->HasMusicInfoTag())
4232 strFile = URIUtils::GetFileName(item->GetMusicInfoTag()->GetURL());
4233 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4234 strFile = URIUtils::GetFileName(item->GetVideoInfoTag()->m_strFileNameAndPath);
4236 strFile = URIUtils::GetFileName(item->GetPath());
4238 if (info==LISTITEM_FILE_EXTENSION)
4240 CStdString strExtension = URIUtils::GetExtension(strFile);
4241 return strExtension.TrimLeft(".");
4247 if (item->HasEPGInfoTag())
4248 return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedDateTime(false, false);
4249 if (item->HasPVRChannelInfoTag())
4252 return item->GetPVRChannelInfoTag()->GetEPGNow(epgTag) ? epgTag.StartAsLocalTime().GetAsLocalizedDateTime(false, false) : CDateTime::GetCurrentDateTime().GetAsLocalizedDateTime(false, false);
4254 if (item->HasPVRRecordingInfoTag())
4255 return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedDateTime(false, false);
4256 if (item->HasPVRTimerInfoTag())
4257 return item->GetPVRTimerInfoTag()->Summary();
4258 if (item->m_dateTime.IsValid())
4259 return item->m_dateTime.GetAsLocalizedDate();
4262 if (!item->m_bIsFolder || item->m_dwSize)
4263 return StringUtils::SizeToString(item->m_dwSize);
4265 case LISTITEM_RATING:
4268 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
4269 rating.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
4270 else if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetRating() > '0')
4271 { // song rating. Images will probably be better than numbers for this in the long run
4272 rating = item->GetMusicInfoTag()->GetRating();
4276 case LISTITEM_RATING_AND_VOTES:
4278 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_fRating > 0.f) // movie rating
4280 CStdString strRatingAndVotes;
4281 if (item->GetVideoInfoTag()->m_strVotes.IsEmpty())
4282 strRatingAndVotes.Format("%.1f", item->GetVideoInfoTag()->m_fRating);
4284 strRatingAndVotes.Format("%.1f (%s %s)", item->GetVideoInfoTag()->m_fRating, item->GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
4285 return strRatingAndVotes;
4289 case LISTITEM_PROGRAM_COUNT:
4292 count.Format("%i", item->m_iprogramCount);
4295 case LISTITEM_DURATION:
4297 CStdString duration;
4298 if (item->HasPVRChannelInfoTag())
4300 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4302 if (channel && channel->GetEPGNow(tag))
4303 return StringUtils::SecondsToTimeString(tag.GetDuration());
4304 return StringUtils::EmptyString;
4306 else if (item->HasPVRRecordingInfoTag())
4308 if (item->GetPVRRecordingInfoTag()->GetDuration() > 0)
4309 duration = StringUtils::SecondsToTimeString(item->GetPVRRecordingInfoTag()->GetDuration());
4311 else if (item->HasEPGInfoTag())
4313 if (item->GetEPGInfoTag()->GetDuration() > 0)
4314 duration = StringUtils::SecondsToTimeString(item->GetEPGInfoTag()->GetDuration());
4316 else if (item->HasVideoInfoTag())
4318 if (item->GetVideoInfoTag()->GetDuration() > 0)
4319 duration.Format("%d", item->GetVideoInfoTag()->GetDuration() / 60);
4321 else if (item->HasMusicInfoTag())
4323 if (item->GetMusicInfoTag()->GetDuration() > 0)
4324 duration = StringUtils::SecondsToTimeString(item->GetMusicInfoTag()->GetDuration());
4329 if (item->HasPVRChannelInfoTag())
4331 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4333 if (channel && channel->GetEPGNow(tag))
4335 return StringUtils::EmptyString;
4337 if (item->HasEPGInfoTag())
4338 return item->GetEPGInfoTag()->Plot();
4339 if (item->HasPVRRecordingInfoTag())
4340 return item->GetPVRRecordingInfoTag()->m_strPlot;
4341 if (item->HasVideoInfoTag())
4343 if (!(!item->GetVideoInfoTag()->m_strShowTitle.IsEmpty() && item->GetVideoInfoTag()->m_iSeason == -1)) // dont apply to tvshows
4344 if (item->GetVideoInfoTag()->m_playCount == 0 && !g_guiSettings.GetBool("videolibrary.showunwatchedplots"))
4345 return g_localizeStrings.Get(20370);
4347 return item->GetVideoInfoTag()->m_strPlot;
4350 case LISTITEM_PLOT_OUTLINE:
4351 if (item->HasPVRChannelInfoTag())
4353 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4355 if (channel && channel->GetEPGNow(tag))
4356 return tag.PlotOutline();
4357 return StringUtils::EmptyString;
4359 if (item->HasEPGInfoTag())
4360 return item->GetEPGInfoTag()->PlotOutline();
4361 if (item->HasPVRRecordingInfoTag())
4362 return item->GetPVRRecordingInfoTag()->m_strPlotOutline;
4363 if (item->HasVideoInfoTag())
4364 return item->GetVideoInfoTag()->m_strPlotOutline;
4366 case LISTITEM_EPISODE:
4367 if (item->HasVideoInfoTag())
4369 CStdString strResult;
4370 if (item->GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
4371 strResult.Format("S%d",item->GetVideoInfoTag()->m_iEpisode);
4372 else if (item->GetVideoInfoTag()->m_iEpisode > 0) // if m_iEpisode = -1 there's no episode detail
4373 strResult.Format("%d",item->GetVideoInfoTag()->m_iEpisode);
4377 case LISTITEM_SEASON:
4378 if (item->HasVideoInfoTag())
4380 CStdString strResult;
4381 if (item->GetVideoInfoTag()->m_iSpecialSortSeason > 0)
4382 strResult.Format("%d",item->GetVideoInfoTag()->m_iSpecialSortSeason);
4383 else if (item->GetVideoInfoTag()->m_iSeason > 0) // if m_iSeason = -1 there's no season detail
4384 strResult.Format("%d",item->GetVideoInfoTag()->m_iSeason);
4388 case LISTITEM_TVSHOW:
4389 if (item->HasVideoInfoTag())
4390 return item->GetVideoInfoTag()->m_strShowTitle;
4392 case LISTITEM_COMMENT:
4393 if (item->HasPVRTimerInfoTag())
4394 return item->GetPVRTimerInfoTag()->GetStatus();
4395 if (item->HasMusicInfoTag())
4396 return item->GetMusicInfoTag()->GetComment();
4398 case LISTITEM_ACTUAL_ICON:
4399 return item->GetIconImage();
4402 CStdString strThumb = item->GetArt("thumb");
4403 if (strThumb.IsEmpty())
4404 strThumb = item->GetIconImage();
4406 *fallback = item->GetIconImage();
4409 case LISTITEM_OVERLAY:
4410 return item->GetOverlayImage();
4411 case LISTITEM_THUMB:
4412 return item->GetArt("thumb");
4413 case LISTITEM_FOLDERPATH:
4414 return CURL(item->GetPath()).GetWithoutUserDetails();
4415 case LISTITEM_FOLDERNAME:
4419 if (item->IsMusicDb() && item->HasMusicInfoTag())
4420 URIUtils::GetDirectory(item->GetMusicInfoTag()->GetURL(), path);
4421 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4423 if( item->m_bIsFolder )
4424 path = item->GetVideoInfoTag()->m_strPath;
4426 URIUtils::GetParentPath(item->GetVideoInfoTag()->m_strFileNameAndPath, path);
4429 URIUtils::GetParentPath(item->GetPath(), path);
4430 path = CURL(path).GetWithoutUserDetails();
4431 if (info==LISTITEM_FOLDERNAME)
4433 URIUtils::RemoveSlashAtEnd(path);
4434 path=URIUtils::GetFileName(path);
4439 case LISTITEM_FILENAME_AND_PATH:
4442 if (item->IsMusicDb() && item->HasMusicInfoTag())
4443 path = item->GetMusicInfoTag()->GetURL();
4444 else if (item->IsVideoDb() && item->HasVideoInfoTag())
4445 path = item->GetVideoInfoTag()->m_strFileNameAndPath;
4447 path = item->GetPath();
4448 path = CURL(path).GetWithoutUserDetails();
4452 case LISTITEM_PICTURE_PATH:
4453 if (item->IsPicture() && (!item->IsZIP() || item->IsRAR() || item->IsCBZ() || item->IsCBR()))
4454 return item->GetPath();
4456 case LISTITEM_STUDIO:
4457 if (item->HasVideoInfoTag())
4458 return StringUtils::Join(item->GetVideoInfoTag()->m_studio, g_advancedSettings.m_videoItemSeparator);
4460 case LISTITEM_COUNTRY:
4461 if (item->HasVideoInfoTag())
4462 return StringUtils::Join(item->GetVideoInfoTag()->m_country, g_advancedSettings.m_videoItemSeparator);
4465 if (item->HasVideoInfoTag())
4466 return item->GetVideoInfoTag()->m_strMPAARating;
4469 if (item->HasVideoInfoTag())
4470 return item->GetVideoInfoTag()->GetCast();
4472 case LISTITEM_CAST_AND_ROLE:
4473 if (item->HasVideoInfoTag())
4474 return item->GetVideoInfoTag()->GetCast(true);
4476 case LISTITEM_WRITER:
4477 if (item->HasVideoInfoTag())
4478 return StringUtils::Join(item->GetVideoInfoTag()->m_writingCredits, g_advancedSettings.m_videoItemSeparator);
4480 case LISTITEM_TAGLINE:
4481 if (item->HasVideoInfoTag())
4482 return item->GetVideoInfoTag()->m_strTagLine;
4484 case LISTITEM_TRAILER:
4485 if (item->HasVideoInfoTag())
4486 return item->GetVideoInfoTag()->m_strTrailer;
4488 case LISTITEM_TOP250:
4489 if (item->HasVideoInfoTag())
4491 CStdString strResult;
4492 if (item->GetVideoInfoTag()->m_iTop250 > 0)
4493 strResult.Format("%i",item->GetVideoInfoTag()->m_iTop250);
4497 case LISTITEM_SORT_LETTER:
4500 g_charsetConverter.wToUTF8(item->GetSortLabel().Left(1).ToUpper(), letter);
4504 case LISTITEM_VIDEO_CODEC:
4505 if (item->HasVideoInfoTag())
4506 return item->GetVideoInfoTag()->m_streamDetails.GetVideoCodec();
4508 case LISTITEM_VIDEO_RESOLUTION:
4509 if (item->HasVideoInfoTag())
4510 return CStreamDetails::VideoDimsToResolutionDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoWidth(), item->GetVideoInfoTag()->m_streamDetails.GetVideoHeight());
4512 case LISTITEM_VIDEO_ASPECT:
4513 if (item->HasVideoInfoTag())
4514 return CStreamDetails::VideoAspectToAspectDescription(item->GetVideoInfoTag()->m_streamDetails.GetVideoAspect());
4516 case LISTITEM_AUDIO_CODEC:
4517 if (item->HasVideoInfoTag())
4519 return item->GetVideoInfoTag()->m_streamDetails.GetAudioCodec();
4522 case LISTITEM_AUDIO_CHANNELS:
4523 if (item->HasVideoInfoTag())
4525 CStdString strResult;
4526 int iChannels = item->GetVideoInfoTag()->m_streamDetails.GetAudioChannels();
4528 strResult.Format("%i", iChannels);
4532 case LISTITEM_AUDIO_LANGUAGE:
4533 if (item->HasVideoInfoTag())
4534 return item->GetVideoInfoTag()->m_streamDetails.GetAudioLanguage();
4536 case LISTITEM_SUBTITLE_LANGUAGE:
4537 if (item->HasVideoInfoTag())
4538 return item->GetVideoInfoTag()->m_streamDetails.GetSubtitleLanguage();
4540 case LISTITEM_STARTTIME:
4541 if (item->HasPVRChannelInfoTag())
4543 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4545 if (channel && channel->GetEPGNow(tag))
4546 return tag.StartAsLocalTime().GetAsLocalizedTime("", false);
4547 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4549 if (item->HasEPGInfoTag())
4550 return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedTime("", false);
4551 if (item->HasPVRTimerInfoTag())
4552 return item->GetPVRTimerInfoTag()->StartAsLocalTime().GetAsLocalizedTime("", false);
4553 if (item->HasPVRRecordingInfoTag())
4554 return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedTime("", false);
4555 if (item->m_dateTime.IsValid())
4556 return item->m_dateTime.GetAsLocalizedTime("", false);
4558 case LISTITEM_ENDTIME:
4559 if (item->HasPVRChannelInfoTag())
4561 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4563 if (channel && channel->GetEPGNow(tag))
4564 return tag.EndAsLocalTime().GetAsLocalizedTime("", false);
4565 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4567 if (item->HasEPGInfoTag())
4568 return item->GetEPGInfoTag()->EndAsLocalTime().GetAsLocalizedTime("", false);
4569 if (item->HasPVRTimerInfoTag())
4570 return item->GetPVRTimerInfoTag()->EndAsLocalTime().GetAsLocalizedTime("", false);
4572 case LISTITEM_STARTDATE:
4573 if (item->HasPVRChannelInfoTag())
4575 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4577 if (channel && channel->GetEPGNow(tag))
4578 return tag.StartAsLocalTime().GetAsLocalizedDate(true);
4579 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4581 if (item->HasEPGInfoTag())
4582 return item->GetEPGInfoTag()->StartAsLocalTime().GetAsLocalizedDate(true);
4583 if (item->HasPVRTimerInfoTag())
4584 return item->GetPVRTimerInfoTag()->StartAsLocalTime().GetAsLocalizedDate(true);
4585 if (item->HasPVRRecordingInfoTag())
4586 return item->GetPVRRecordingInfoTag()->RecordingTimeAsLocalTime().GetAsLocalizedDate(true);
4587 if (item->m_dateTime.IsValid())
4588 return item->m_dateTime.GetAsLocalizedDate(true);
4590 case LISTITEM_ENDDATE:
4591 if (item->HasPVRChannelInfoTag())
4593 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4595 if (channel && channel->GetEPGNow(tag))
4596 return tag.EndAsLocalTime().GetAsLocalizedDate(true);
4597 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4599 if (item->HasEPGInfoTag())
4600 return item->GetEPGInfoTag()->EndAsLocalTime().GetAsLocalizedDate(true);
4601 if (item->HasPVRTimerInfoTag())
4602 return item->GetPVRTimerInfoTag()->EndAsLocalTime().GetAsLocalizedDate(true);
4604 case LISTITEM_CHANNEL_NUMBER:
4607 if (item->HasPVRChannelInfoTag())
4608 number.Format("%i", item->GetPVRChannelInfoTag()->ChannelNumber());
4609 if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->HasPVRChannel())
4610 number.Format("%i", item->GetEPGInfoTag()->PVRChannelNumber());
4611 if (item->HasPVRTimerInfoTag())
4612 number.Format("%i", item->GetPVRTimerInfoTag()->ChannelNumber());
4617 case LISTITEM_CHANNEL_NAME:
4618 if (item->HasPVRChannelInfoTag())
4619 return item->GetPVRChannelInfoTag()->ChannelName();
4620 if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->HasPVRChannel())
4621 return item->GetEPGInfoTag()->PVRChannelName();
4622 if (item->HasPVRRecordingInfoTag())
4623 return item->GetPVRRecordingInfoTag()->m_strChannelName;
4624 if (item->HasPVRTimerInfoTag())
4625 return item->GetPVRTimerInfoTag()->ChannelName();
4627 case LISTITEM_NEXT_STARTTIME:
4629 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4631 if (channel && channel->GetEPGNext(tag))
4632 return tag.StartAsLocalTime().GetAsLocalizedTime("", false);
4634 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4635 case LISTITEM_NEXT_ENDTIME:
4637 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4639 if (channel && channel->GetEPGNext(tag))
4640 return tag.EndAsLocalTime().GetAsLocalizedTime("", false);
4642 return CDateTime::GetCurrentDateTime().GetAsLocalizedTime("", false);
4643 case LISTITEM_NEXT_STARTDATE:
4645 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4647 if (channel && channel->GetEPGNext(tag))
4648 return tag.StartAsLocalTime().GetAsLocalizedDate(true);
4650 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4651 case LISTITEM_NEXT_ENDDATE:
4653 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4655 if (channel && channel->GetEPGNext(tag))
4656 return tag.EndAsLocalTime().GetAsLocalizedDate(true);
4658 return CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true);
4659 case LISTITEM_NEXT_PLOT:
4661 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4663 if (channel && channel->GetEPGNext(tag))
4666 return StringUtils::EmptyString;
4667 case LISTITEM_NEXT_PLOT_OUTLINE:
4669 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4671 if (channel && channel->GetEPGNext(tag))
4672 return tag.PlotOutline();
4674 return StringUtils::EmptyString;
4675 case LISTITEM_NEXT_DURATION:
4677 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4679 if (channel && channel->GetEPGNext(tag))
4680 return StringUtils::SecondsToTimeString(tag.GetDuration());
4682 return StringUtils::EmptyString;
4683 case LISTITEM_NEXT_GENRE:
4685 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4687 if (channel && channel->GetEPGNext(tag))
4688 return StringUtils::Join(tag.Genre(), g_advancedSettings.m_videoItemSeparator);
4690 return StringUtils::EmptyString;
4691 case LISTITEM_NEXT_TITLE:
4693 const CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL;
4695 if (channel && channel->GetEPGNext(tag))
4698 return StringUtils::EmptyString;
4699 case LISTITEM_PARENTALRATING:
4702 if (item->HasEPGInfoTag() && item->GetEPGInfoTag()->ParentalRating() > 0)
4703 rating.Format("%i", item->GetEPGInfoTag()->ParentalRating());
4707 case LISTITEM_PERCENT_PLAYED:
4710 if (GetItemInt(val, item, info))
4713 str.Format("%d", val);
4718 case LISTITEM_DATE_ADDED:
4719 if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_dateAdded.IsValid())
4720 return item->GetVideoInfoTag()->m_dateAdded.GetAsLocalizedDate();
4722 case LISTITEM_DBTYPE:
4723 if (item->HasVideoInfoTag())
4724 return item->GetVideoInfoTag()->m_type;
4727 if (item->HasVideoInfoTag())
4730 dbid.Format("%i", item->GetVideoInfoTag()->m_iDbId);
4733 if (item->HasMusicInfoTag())
4736 dbid.Format("%i", item->GetMusicInfoTag()->GetDatabaseId());
4744 CStdString CGUIInfoManager::GetItemImage(const CFileItem *item, int info, CStdString *fallback)
4746 if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
4747 return GetSkinVariableString(info, true, item);
4751 case LISTITEM_RATING: // old song rating format
4754 if (item->HasMusicInfoTag())
4756 rating.Format("songrating%c.png", item->GetMusicInfoTag()->GetRating());
4761 case LISTITEM_STAR_RATING:
4764 if (item->HasVideoInfoTag())
4765 { // rating for videos is assumed 0..10, so convert to 0..5
4766 rating.Format("rating%d.png", (long)((item->GetVideoInfoTag()->m_fRating * 0.5f) + 0.5f));
4768 else if (item->HasMusicInfoTag())
4770 rating.Format("rating%c.png", item->GetMusicInfoTag()->GetRating());
4775 } /* switch (info) */
4777 return GetItemLabel(item, info, fallback);
4780 bool CGUIInfoManager::GetItemBool(const CGUIListItem *item, int condition) const
4782 if (!item) return false;
4783 if (condition >= LISTITEM_PROPERTY_START && condition - LISTITEM_PROPERTY_START < (int)m_listitemProperties.size())
4784 { // grab the property
4785 CStdString property = m_listitemProperties[condition - LISTITEM_PROPERTY_START];
4786 return item->GetProperty(property).asBoolean();
4788 else if (condition == LISTITEM_ISPLAYING)
4790 if (item->HasProperty("playlistposition"))
4791 return (int)item->GetProperty("playlisttype").asInteger() == g_playlistPlayer.GetCurrentPlaylist() && (int)item->GetProperty("playlistposition").asInteger() == g_playlistPlayer.GetCurrentSong();
4792 else if (item->IsFileItem() && !m_currentFile->GetPath().IsEmpty())
4794 if (!g_application.m_strPlayListFile.IsEmpty())
4796 //playlist file that is currently playing or the playlistitem that is currently playing.
4797 return g_application.m_strPlayListFile.Equals(((const CFileItem *)item)->GetPath()) || m_currentFile->IsSamePath((const CFileItem *)item);
4799 return m_currentFile->IsSamePath((const CFileItem *)item);
4802 else if (condition == LISTITEM_ISSELECTED)
4803 return item->IsSelected();
4804 else if (condition == LISTITEM_IS_FOLDER)
4805 return item->m_bIsFolder;
4806 else if (condition == LISTITEM_IS_RESUMABLE)
4808 if (item->IsFileItem())
4810 if (((const CFileItem *)item)->HasVideoInfoTag())
4811 return ((const CFileItem *)item)->GetVideoInfoTag()->m_resumePoint.timeInSeconds > 0;
4812 else if (((const CFileItem *)item)->HasPVRRecordingInfoTag())
4813 return ((const CFileItem *)item)->GetPVRRecordingInfoTag()->m_resumePoint.timeInSeconds > 0;
4816 else if (item->IsFileItem())
4818 const CFileItem *pItem = (const CFileItem *)item;
4819 if (condition == LISTITEM_ISRECORDING)
4821 if (!g_PVRManager.IsStarted())
4824 if (pItem->HasPVRChannelInfoTag())
4826 return pItem->GetPVRChannelInfoTag()->IsRecording();
4828 else if (pItem->HasPVRTimerInfoTag())
4830 const CPVRTimerInfoTag *timer = pItem->GetPVRTimerInfoTag();
4832 return timer->IsRecording();
4834 else if (pItem->HasEPGInfoTag())
4836 CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(pItem);
4837 if (timer && timer->HasPVRTimerInfoTag())
4838 return timer->GetPVRTimerInfoTag()->IsRecording();
4841 else if (condition == LISTITEM_HASTIMER)
4843 if (pItem->HasEPGInfoTag())
4845 CFileItemPtr timer = g_PVRTimers->GetTimerForEpgTag(pItem);
4846 if (timer && timer->HasPVRTimerInfoTag())
4847 return timer->GetPVRTimerInfoTag()->IsActive();
4850 else if (condition == LISTITEM_HAS_EPG)
4852 if (pItem->HasPVRChannelInfoTag())
4855 return pItem->GetPVRChannelInfoTag()->GetEPGNow(epgTag);
4859 return pItem->HasEPGInfoTag();
4862 else if (condition == LISTITEM_ISENCRYPTED)
4864 if (pItem->HasPVRChannelInfoTag())
4866 return pItem->GetPVRChannelInfoTag()->IsEncrypted();
4868 else if (pItem->HasEPGInfoTag() && pItem->GetEPGInfoTag()->HasPVRChannel())
4870 return pItem->GetEPGInfoTag()->ChannelTag()->IsEncrypted();
4878 void CGUIInfoManager::ResetCache()
4880 // reset any animation triggers as well
4881 m_containerMoves.clear();
4885 // Called from tuxbox service thread to update current status
4886 void CGUIInfoManager::UpdateFromTuxBox()
4888 if(g_tuxbox.vVideoSubChannel.mode)
4889 m_currentFile->GetVideoInfoTag()->m_strTitle = g_tuxbox.vVideoSubChannel.current_name;
4891 // Set m_currentMovieDuration
4892 if(!g_tuxbox.sCurSrvData.current_event_duration.IsEmpty() &&
4893 !g_tuxbox.sCurSrvData.next_event_description.IsEmpty() &&
4894 !g_tuxbox.sCurSrvData.current_event_duration.Equals("-") &&
4895 !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
4897 g_tuxbox.sCurSrvData.current_event_duration.Replace("(","");
4898 g_tuxbox.sCurSrvData.current_event_duration.Replace(")","");
4900 m_currentMovieDuration.Format("%s: %s %s (%s - %s)",
4901 g_localizeStrings.Get(180),
4902 g_tuxbox.sCurSrvData.current_event_duration,
4903 g_localizeStrings.Get(12391),
4904 g_tuxbox.sCurSrvData.current_event_time,
4905 g_tuxbox.sCurSrvData.next_event_time);
4909 if (!g_tuxbox.sCurSrvData.current_event_description.IsEmpty() &&
4910 !g_tuxbox.sCurSrvData.next_event_description.IsEmpty() &&
4911 !g_tuxbox.sCurSrvData.current_event_description.Equals("-") &&
4912 !g_tuxbox.sCurSrvData.next_event_description.Equals("-"))
4915 genre.Format("%s %s - (%s: %s)",
4916 g_localizeStrings.Get(143),
4917 g_tuxbox.sCurSrvData.current_event_description,
4918 g_localizeStrings.Get(209),
4919 g_tuxbox.sCurSrvData.next_event_description);
4920 m_currentFile->GetVideoInfoTag()->m_genre = StringUtils::Split(genre, g_advancedSettings.m_videoItemSeparator);
4923 //Set m_currentMovie.m_director
4924 if (!g_tuxbox.sCurSrvData.current_event_details.Equals("-") &&
4925 !g_tuxbox.sCurSrvData.current_event_details.IsEmpty())
4927 m_currentFile->GetVideoInfoTag()->m_director = StringUtils::Split(g_tuxbox.sCurSrvData.current_event_details, g_advancedSettings.m_videoItemSeparator);
4931 CStdString CGUIInfoManager::GetPictureLabel(int info)
4933 if (info == SLIDE_FILE_NAME)
4934 return GetItemLabel(m_currentSlide, LISTITEM_FILENAME);
4935 else if (info == SLIDE_FILE_PATH)
4938 URIUtils::GetDirectory(m_currentSlide->GetPath(), path);
4939 return CURL(path).GetWithoutUserDetails();
4941 else if (info == SLIDE_FILE_SIZE)
4942 return GetItemLabel(m_currentSlide, LISTITEM_SIZE);
4943 else if (info == SLIDE_FILE_DATE)
4944 return GetItemLabel(m_currentSlide, LISTITEM_DATE);
4945 else if (info == SLIDE_INDEX)
4947 CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
4948 if (slideshow && slideshow->NumSlides())
4951 index.Format("%d/%d", slideshow->CurrentSlide(), slideshow->NumSlides());
4955 if (m_currentSlide->HasPictureInfoTag())
4956 return m_currentSlide->GetPictureInfoTag()->GetInfo(info);
4960 void CGUIInfoManager::SetCurrentSlide(CFileItem &item)
4962 if (m_currentSlide->GetPath() != item.GetPath())
4964 if (!item.GetPictureInfoTag()->Loaded()) // If picture metadata has not been loaded yet, load it now
4965 item.GetPictureInfoTag()->Load(item.GetPath());
4966 *m_currentSlide = item;
4970 void CGUIInfoManager::ResetCurrentSlide()
4972 m_currentSlide->Reset();
4975 bool CGUIInfoManager::CheckWindowCondition(CGUIWindow *window, int condition) const
4977 // check if it satisfies our condition
4978 if (!window) return false;
4979 if ((condition & WINDOW_CONDITION_HAS_LIST_ITEMS) && !window->HasListItems())
4981 if ((condition & WINDOW_CONDITION_IS_MEDIA_WINDOW) && !window->IsMediaWindow())
4986 CGUIWindow *CGUIInfoManager::GetWindowWithCondition(int contextWindow, int condition) const
4988 CGUIWindow *window = g_windowManager.GetWindow(contextWindow);
4989 if (CheckWindowCondition(window, condition))
4992 // try topmost dialog
4993 window = g_windowManager.GetWindow(g_windowManager.GetTopMostModalDialogID());
4994 if (CheckWindowCondition(window, condition))
4997 // try active window
4998 window = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
4999 if (CheckWindowCondition(window, condition))
5005 void CGUIInfoManager::SetCurrentVideoTag(const CVideoInfoTag &tag)
5007 *m_currentFile->GetVideoInfoTag() = tag;
5008 m_currentFile->m_lStartOffset = 0;
5011 void CGUIInfoManager::SetCurrentSongTag(const MUSIC_INFO::CMusicInfoTag &tag)
5013 //CLog::Log(LOGDEBUG, "Asked to SetCurrentTag");
5014 *m_currentFile->GetMusicInfoTag() = tag;
5015 m_currentFile->m_lStartOffset = 0;
5018 const CFileItem& CGUIInfoManager::GetCurrentSlide() const
5020 return *m_currentSlide;
5023 const MUSIC_INFO::CMusicInfoTag* CGUIInfoManager::GetCurrentSongTag() const
5025 if (m_currentFile->HasMusicInfoTag())
5026 return m_currentFile->GetMusicInfoTag();
5031 const CVideoInfoTag* CGUIInfoManager::GetCurrentMovieTag() const
5033 if (m_currentFile->HasVideoInfoTag())
5034 return m_currentFile->GetVideoInfoTag();
5039 void GUIInfo::SetInfoFlag(uint32_t flag)
5041 assert(flag >= (1 << 24));
5045 uint32_t GUIInfo::GetInfoFlag() const
5047 // we strip out the bottom 24 bits, where we keep data
5048 // and return the flag only
5049 return m_data1 & 0xff000000;
5052 uint32_t GUIInfo::GetData1() const
5054 // we strip out the top 8 bits, where we keep flags
5055 // and return the unflagged data
5056 return m_data1 & ((1 << 24) -1);
5059 int GUIInfo::GetData2() const
5064 void CGUIInfoManager::SetLibraryBool(int condition, bool value)
5068 case LIBRARY_HAS_MUSIC:
5069 m_libraryHasMusic = value ? 1 : 0;
5071 case LIBRARY_HAS_MOVIES:
5072 m_libraryHasMovies = value ? 1 : 0;
5074 case LIBRARY_HAS_MOVIE_SETS:
5075 m_libraryHasMovieSets = value ? 1 : 0;
5077 case LIBRARY_HAS_TVSHOWS:
5078 m_libraryHasTVShows = value ? 1 : 0;
5080 case LIBRARY_HAS_MUSICVIDEOS:
5081 m_libraryHasMusicVideos = value ? 1 : 0;
5088 void CGUIInfoManager::ResetLibraryBools()
5090 m_libraryHasMusic = -1;
5091 m_libraryHasMovies = -1;
5092 m_libraryHasTVShows = -1;
5093 m_libraryHasMusicVideos = -1;
5094 m_libraryHasMovieSets = -1;
5097 bool CGUIInfoManager::GetLibraryBool(int condition)
5099 if (condition == LIBRARY_HAS_MUSIC)
5101 if (m_libraryHasMusic < 0)
5106 m_libraryHasMusic = (db.GetSongsCount() > 0) ? 1 : 0;
5110 return m_libraryHasMusic > 0;
5112 else if (condition == LIBRARY_HAS_MOVIES)
5114 if (m_libraryHasMovies < 0)
5119 m_libraryHasMovies = db.HasContent(VIDEODB_CONTENT_MOVIES) ? 1 : 0;
5123 return m_libraryHasMovies > 0;
5125 else if (condition == LIBRARY_HAS_MOVIE_SETS)
5127 if (m_libraryHasMovieSets < 0)
5132 m_libraryHasMovieSets = db.HasSets() ? 1 : 0;
5136 return m_libraryHasMovieSets > 0;
5138 else if (condition == LIBRARY_HAS_TVSHOWS)
5140 if (m_libraryHasTVShows < 0)
5145 m_libraryHasTVShows = db.HasContent(VIDEODB_CONTENT_TVSHOWS) ? 1 : 0;
5149 return m_libraryHasTVShows > 0;
5151 else if (condition == LIBRARY_HAS_MUSICVIDEOS)
5153 if (m_libraryHasMusicVideos < 0)
5158 m_libraryHasMusicVideos = db.HasContent(VIDEODB_CONTENT_MUSICVIDEOS) ? 1 : 0;
5162 return m_libraryHasMusicVideos > 0;
5164 else if (condition == LIBRARY_HAS_VIDEO)
5166 return (GetLibraryBool(LIBRARY_HAS_MOVIES) ||
5167 GetLibraryBool(LIBRARY_HAS_TVSHOWS) ||
5168 GetLibraryBool(LIBRARY_HAS_MUSICVIDEOS));
5173 int CGUIInfoManager::RegisterSkinVariableString(const CSkinVariableString* info)
5178 CSingleLock lock(m_critInfo);
5179 m_skinVariableStrings.push_back(*info);
5181 return CONDITIONAL_LABEL_START + m_skinVariableStrings.size() - 1;
5184 int CGUIInfoManager::TranslateSkinVariableString(const CStdString& name, int context)
5186 for (vector<CSkinVariableString>::const_iterator it = m_skinVariableStrings.begin();
5187 it != m_skinVariableStrings.end(); ++it)
5189 if (it->GetName().Equals(name) && it->GetContext() == context)
5190 return it - m_skinVariableStrings.begin() + CONDITIONAL_LABEL_START;
5195 CStdString CGUIInfoManager::GetSkinVariableString(int info,
5196 bool preferImage /*= false*/,
5197 const CGUIListItem *item /*= NULL*/)
5199 info -= CONDITIONAL_LABEL_START;
5200 if (info >= 0 && info < (int)m_skinVariableStrings.size())
5201 return m_skinVariableStrings[info].GetValue(preferImage, item);
5206 bool CGUIInfoManager::ConditionsChangedValues(const std::map<int, bool>& map)
5208 for (std::map<int, bool>::const_iterator it = map.begin() ; it != map.end() ; it++)
5210 if (GetBoolValue(it->first) != it->second)
5216 bool CGUIInfoManager::GetEpgInfoTag(CEpgInfoTag& tag) const
5218 if (m_currentFile->HasEPGInfoTag())
5220 CEpgInfoTag* currentTag = m_currentFile->GetEPGInfoTag();
5221 while (currentTag && !currentTag->IsActive())
5222 currentTag = currentTag->GetNextEvent().get();