Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: d82d1a7ff8
Fetching contributors…

Cannot retrieve contributors at this time

4643 lines (4419 sloc) 174.356 kB
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "system.h"
#include "GUIInfoManager.h"
#include "windows/GUIMediaWindow.h"
#include "dialogs/GUIDialogProgress.h"
#include "Application.h"
#include "Util.h"
#include "network/libscrobbler/lastfmscrobbler.h"
#include "utils/URIUtils.h"
#include "utils/Weather.h"
#include "PartyModeManager.h"
#include "addons/Visualisation.h"
#include "input/ButtonTranslator.h"
#include "utils/AlarmClock.h"
#ifdef HAS_LCD
#include "utils/LCD.h"
#endif
#include "LangInfo.h"
#include "utils/SystemInfo.h"
#include "guilib/GUITextBox.h"
#include "pictures/GUIWindowSlideShow.h"
#include "music/LastFmManager.h"
#include "pictures/PictureInfoTag.h"
#include "music/tags/MusicInfoTag.h"
#include "guilib/GUIWindowManager.h"
#include "playlists/PlayList.h"
#include "utils/TuxBoxUtil.h"
#include "windowing/WindowingFactory.h"
#include "powermanagement/PowerManager.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "guilib/LocalizeStrings.h"
#include "utils/CPUInfo.h"
#include "utils/StringUtils.h"
#include "utils/MathUtils.h"
#include "utils/SeekHandler.h"
#include "URL.h"
// stuff for current song
#include "music/MusicInfoLoader.h"
#include "GUIUserMessages.h"
#include "video/dialogs/GUIDialogVideoInfo.h"
#include "music/dialogs/GUIDialogMusicInfo.h"
#include "storage/MediaManager.h"
#include "utils/TimeUtils.h"
#include "threads/SingleLock.h"
#include "utils/log.h"
#include "addons/AddonManager.h"
#include "interfaces/info/InfoBool.h"
#include "ThumbLoader.h"
#include "cores/AudioEngine/Utils/AEUtil.h"
#define SYSHEATUPDATEINTERVAL 60000
using namespace std;
using namespace XFILE;
using namespace MUSIC_INFO;
using namespace ADDON;
using namespace INFO;
CGUIInfoManager::CGUIInfoManager(void)
{
m_lastSysHeatInfoTime = -SYSHEATUPDATEINTERVAL; // make sure we grab CPU temp on the first pass
m_lastMusicBitrateTime = 0;
m_fanSpeed = 0;
m_AfterSeekTimeout = 0;
m_seekOffset = 0;
m_playerSeeking = false;
m_performingSeek = false;
m_nextWindowID = WINDOW_INVALID;
m_prevWindowID = WINDOW_INVALID;
m_stringParameters.push_back("__ZZZZ__"); // to offset the string parameters by 1 to assure that all entries are non-zero
m_currentFile = new CFileItem;
m_currentSlide = new CFileItem;
m_frameCounter = 0;
m_lastFPSTime = 0;
m_updateTime = 1;
ResetLibraryBools();
}
CGUIInfoManager::~CGUIInfoManager(void)
{
delete m_currentFile;
delete m_currentSlide;
}
bool CGUIInfoManager::OnMessage(CGUIMessage &message)
{
if (message.GetMessage() == GUI_MSG_NOTIFY_ALL)
{
if (message.GetParam1() == GUI_MSG_UPDATE_ITEM && message.GetItem())
{
CFileItemPtr item = boost::static_pointer_cast<CFileItem>(message.GetItem());
if (m_currentFile->IsSamePath(item.get()))
{
*m_currentFile = *item;
return true;
}
}
}
return false;
}
/// \brief Translates a string as given by the skin into an int that we use for more
/// efficient retrieval of data. Can handle combined strings on the form
/// Player.Caching + VideoPlayer.IsFullscreen (Logical and)
/// Player.HasVideo | Player.HasAudio (Logical or)
int CGUIInfoManager::TranslateString(const CStdString &condition)
{
// translate $LOCALIZE as required
CStdString strCondition(CGUIInfoLabel::ReplaceLocalize(condition));
return TranslateSingleString(strCondition);
}
typedef struct
{
const char *str;
int val;
} infomap;
const infomap player_labels[] = {{ "hasmedia", PLAYER_HAS_MEDIA }, // bools from here
{ "hasaudio", PLAYER_HAS_AUDIO },
{ "hasvideo", PLAYER_HAS_VIDEO },
{ "playing", PLAYER_PLAYING },
{ "paused", PLAYER_PAUSED },
{ "rewinding", PLAYER_REWINDING },
{ "forwarding", PLAYER_FORWARDING },
{ "rewinding2x", PLAYER_REWINDING_2x },
{ "rewinding4x", PLAYER_REWINDING_4x },
{ "rewinding8x", PLAYER_REWINDING_8x },
{ "rewinding16x", PLAYER_REWINDING_16x },
{ "rewinding32x", PLAYER_REWINDING_32x },
{ "forwarding2x", PLAYER_FORWARDING_2x },
{ "forwarding4x", PLAYER_FORWARDING_4x },
{ "forwarding8x", PLAYER_FORWARDING_8x },
{ "forwarding16x", PLAYER_FORWARDING_16x },
{ "forwarding32x", PLAYER_FORWARDING_32x },
{ "canrecord", PLAYER_CAN_RECORD },
{ "recording", PLAYER_RECORDING },
{ "displayafterseek", PLAYER_DISPLAY_AFTER_SEEK },
{ "caching", PLAYER_CACHING },
{ "seekbar", PLAYER_SEEKBAR },
{ "seeking", PLAYER_SEEKING },
{ "showtime", PLAYER_SHOWTIME },
{ "showcodec", PLAYER_SHOWCODEC },
{ "showinfo", PLAYER_SHOWINFO },
{ "muted", PLAYER_MUTED },
{ "hasduration", PLAYER_HASDURATION },
{ "passthrough", PLAYER_PASSTHROUGH },
{ "cachelevel", PLAYER_CACHELEVEL }, // labels from here
{ "seekbar", PLAYER_SEEKBAR },
{ "progress", PLAYER_PROGRESS },
{ "progresscache", PLAYER_PROGRESS_CACHE },
{ "volume", PLAYER_VOLUME },
{ "subtitledelay", PLAYER_SUBTITLE_DELAY },
{ "audiodelay", PLAYER_AUDIO_DELAY },
{ "chapter", PLAYER_CHAPTER },
{ "chaptercount", PLAYER_CHAPTERCOUNT },
{ "chaptername", PLAYER_CHAPTERNAME },
{ "starrating", PLAYER_STAR_RATING },
{ "folderpath", PLAYER_PATH },
{ "filenameandpath", PLAYER_FILEPATH }};
const infomap player_param[] = {{ "property", PLAYER_ITEM_PROPERTY }};
const infomap player_times[] = {{ "seektime", PLAYER_SEEKTIME },
{ "seekoffset", PLAYER_SEEKOFFSET },
{ "timeremaining", PLAYER_TIME_REMAINING },
{ "timespeed", PLAYER_TIME_SPEED },
{ "time", PLAYER_TIME },
{ "duration", PLAYER_DURATION },
{ "finishtime", PLAYER_FINISH_TIME }};
const infomap weather[] = {{ "isfetched", WEATHER_IS_FETCHED },
{ "conditions", WEATHER_CONDITIONS }, // labels from here
{ "temperature", WEATHER_TEMPERATURE },
{ "location", WEATHER_LOCATION },
{ "fanartcode", WEATHER_FANART_CODE },
{ "plugin", WEATHER_PLUGIN }};
const infomap system_labels[] = {{ "hasnetwork", SYSTEM_ETHERNET_LINK_ACTIVE },
{ "hasmediadvd", SYSTEM_MEDIA_DVD },
{ "dvdready", SYSTEM_DVDREADY },
{ "trayopen", SYSTEM_TRAYOPEN },
{ "haslocks", SYSTEM_HASLOCKS },
{ "hasloginscreen", SYSTEM_HAS_LOGINSCREEN },
{ "ismaster", SYSTEM_ISMASTER },
{ "isfullscreen", SYSTEM_ISFULLSCREEN },
{ "isstandalone", SYSTEM_ISSTANDALONE },
{ "loggedon", SYSTEM_LOGGEDON },
{ "showexitbutton", SYSTEM_SHOW_EXIT_BUTTON },
{ "canpowerdown", SYSTEM_CAN_POWERDOWN },
{ "cansuspend", SYSTEM_CAN_SUSPEND },
{ "canhibernate", SYSTEM_CAN_HIBERNATE },
{ "canreboot", SYSTEM_CAN_REBOOT },
{ "screensaveractive",SYSTEM_SCREENSAVER_ACTIVE },
{ "cputemperature", SYSTEM_CPU_TEMPERATURE }, // labels from here
{ "cpuusage", SYSTEM_CPU_USAGE },
{ "gputemperature", SYSTEM_GPU_TEMPERATURE },
{ "fanspeed", SYSTEM_FAN_SPEED },
{ "freespace", SYSTEM_FREE_SPACE },
{ "usedspace", SYSTEM_USED_SPACE },
{ "totalspace", SYSTEM_TOTAL_SPACE },
{ "usedspacepercent", SYSTEM_USED_SPACE_PERCENT },
{ "freespacepercent", SYSTEM_FREE_SPACE_PERCENT },
{ "buildversion", SYSTEM_BUILD_VERSION },
{ "builddate", SYSTEM_BUILD_DATE },
{ "fps", SYSTEM_FPS },
{ "dvdtraystate", SYSTEM_DVD_TRAY_STATE },
{ "freememory", SYSTEM_FREE_MEMORY },
{ "language", SYSTEM_LANGUAGE },
{ "temperatureunits", SYSTEM_TEMPERATURE_UNITS },
{ "screenmode", SYSTEM_SCREEN_MODE },
{ "screenwidth", SYSTEM_SCREEN_WIDTH },
{ "screenheight", SYSTEM_SCREEN_HEIGHT },
{ "currentwindow", SYSTEM_CURRENT_WINDOW },
{ "currentcontrol", SYSTEM_CURRENT_CONTROL },
{ "dvdlabel", SYSTEM_DVD_LABEL },
{ "internetstate", SYSTEM_INTERNET_STATE },
{ "kernelversion", SYSTEM_KERNEL_VERSION },
{ "uptime", SYSTEM_UPTIME },
{ "totaluptime", SYSTEM_TOTALUPTIME },
{ "cpufrequency", SYSTEM_CPUFREQUENCY },
{ "screenresolution", SYSTEM_SCREEN_RESOLUTION },
{ "videoencoderinfo", SYSTEM_VIDEO_ENCODER_INFO },
{ "profilename", SYSTEM_PROFILENAME },
{ "profilethumb", SYSTEM_PROFILETHUMB },
{ "profilecount", SYSTEM_PROFILECOUNT },
{ "progressbar", SYSTEM_PROGRESS_BAR },
{ "batterylevel", SYSTEM_BATTERY_LEVEL },
{ "friendlyname", SYSTEM_FRIENDLY_NAME },
{ "alarmpos", SYSTEM_ALARM_POS },
{ "haspvr", SYSTEM_HAS_PVR }};
const infomap system_param[] = {{ "hasalarm", SYSTEM_HAS_ALARM },
{ "getbool", SYSTEM_GET_BOOL },
{ "hascoreid", SYSTEM_HAS_CORE_ID },
{ "setting", SYSTEM_SETTING },
{ "hasaddon", SYSTEM_HAS_ADDON },
{ "coreusage", SYSTEM_GET_CORE_USAGE }};
const infomap lcd_labels[] = {{ "playicon", LCD_PLAY_ICON },
{ "progressbar", LCD_PROGRESS_BAR },
{ "cputemperature", LCD_CPU_TEMPERATURE },
{ "gputemperature", LCD_GPU_TEMPERATURE },
{ "hddtemperature", LCD_HDD_TEMPERATURE },
{ "fanspeed", LCD_FAN_SPEED },
{ "date", LCD_DATE },
{ "time21", LCD_TIME_21 },
{ "time22", LCD_TIME_22 },
{ "timewide21", LCD_TIME_W21 },
{ "timewide22", LCD_TIME_W22 },
{ "time41", LCD_TIME_41 },
{ "time42", LCD_TIME_42 },
{ "time43", LCD_TIME_43 },
{ "time44", LCD_TIME_44 }};
const infomap network_labels[] = {{ "isdhcp", NETWORK_IS_DHCP },
{ "ipaddress", NETWORK_IP_ADDRESS }, //labels from here
{ "linkstate", NETWORK_LINK_STATE },
{ "macaddress", NETWORK_MAC_ADDRESS },
{ "subnetaddress", NETWORK_SUBNET_MASK }, //subnetaddress is misleading/wrong. should be deprecated. use subnetmask in stead
{ "subnetmask", NETWORK_SUBNET_MASK },
{ "gatewayaddress", NETWORK_GATEWAY_ADDRESS },
{ "dns1address", NETWORK_DNS1_ADDRESS },
{ "dns2address", NETWORK_DNS2_ADDRESS },
{ "dhcpaddress", NETWORK_DHCP_ADDRESS }};
const infomap musicpartymode[] = {{ "enabled", MUSICPM_ENABLED },
{ "songsplayed", MUSICPM_SONGSPLAYED },
{ "matchingsongs", MUSICPM_MATCHINGSONGS },
{ "matchingsongspicked", MUSICPM_MATCHINGSONGSPICKED },
{ "matchingsongsleft", MUSICPM_MATCHINGSONGSLEFT },
{ "relaxedsongspicked",MUSICPM_RELAXEDSONGSPICKED },
{ "randomsongspicked", MUSICPM_RANDOMSONGSPICKED }};
const infomap audioscrobbler[] = {{ "enabled", AUDIOSCROBBLER_ENABLED },
{ "connectstate", AUDIOSCROBBLER_CONN_STATE }, //labels from here
{ "submitinterval", AUDIOSCROBBLER_SUBMIT_INT },
{ "filescached", AUDIOSCROBBLER_FILES_CACHED },
{ "submitstate", AUDIOSCROBBLER_SUBMIT_STATE }};
const infomap lastfm[] = {{ "radioplaying", LASTFM_RADIOPLAYING },
{ "canlove", LASTFM_CANLOVE},
{ "canban", LASTFM_CANBAN}};
const infomap musicplayer[] = {{ "title", MUSICPLAYER_TITLE },
{ "album", MUSICPLAYER_ALBUM },
{ "artist", MUSICPLAYER_ARTIST },
{ "albumartist", MUSICPLAYER_ALBUM_ARTIST },
{ "year", MUSICPLAYER_YEAR },
{ "genre", MUSICPLAYER_GENRE },
{ "duration", MUSICPLAYER_DURATION },
{ "tracknumber", MUSICPLAYER_TRACK_NUMBER },
{ "cover", MUSICPLAYER_COVER },
{ "bitrate", MUSICPLAYER_BITRATE },
{ "playlistlength", MUSICPLAYER_PLAYLISTLEN },
{ "playlistposition", MUSICPLAYER_PLAYLISTPOS },
{ "channels", MUSICPLAYER_CHANNELS },
{ "bitspersample", MUSICPLAYER_BITSPERSAMPLE },
{ "samplerate", MUSICPLAYER_SAMPLERATE },
{ "codec", MUSICPLAYER_CODEC },
{ "discnumber", MUSICPLAYER_DISC_NUMBER },
{ "rating", MUSICPLAYER_RATING },
{ "comment", MUSICPLAYER_COMMENT },
{ "lyrics", MUSICPLAYER_LYRICS },
{ "playlistplaying", MUSICPLAYER_PLAYLISTPLAYING },
{ "exists", MUSICPLAYER_EXISTS },
{ "hasprevious", MUSICPLAYER_HASPREVIOUS },
{ "hasnext", MUSICPLAYER_HASNEXT },
{ "playcount", MUSICPLAYER_PLAYCOUNT },
{ "lastplayed", MUSICPLAYER_LASTPLAYED }};
const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE },
{ "genre", VIDEOPLAYER_GENRE },
{ "country", VIDEOPLAYER_COUNTRY },
{ "originaltitle", VIDEOPLAYER_ORIGINALTITLE },
{ "director", VIDEOPLAYER_DIRECTOR },
{ "year", VIDEOPLAYER_YEAR },
{ "cover", VIDEOPLAYER_COVER },
{ "usingoverlays", VIDEOPLAYER_USING_OVERLAYS },
{ "isfullscreen", VIDEOPLAYER_ISFULLSCREEN },
{ "hasmenu", VIDEOPLAYER_HASMENU },
{ "playlistlength", VIDEOPLAYER_PLAYLISTLEN },
{ "playlistposition", VIDEOPLAYER_PLAYLISTPOS },
{ "plot", VIDEOPLAYER_PLOT },
{ "plotoutline", VIDEOPLAYER_PLOT_OUTLINE },
{ "episode", VIDEOPLAYER_EPISODE },
{ "season", VIDEOPLAYER_SEASON },
{ "rating", VIDEOPLAYER_RATING },
{ "ratingandvotes", VIDEOPLAYER_RATING_AND_VOTES },
{ "tvshowtitle", VIDEOPLAYER_TVSHOW },
{ "premiered", VIDEOPLAYER_PREMIERED },
{ "studio", VIDEOPLAYER_STUDIO },
{ "mpaa", VIDEOPLAYER_MPAA },
{ "top250", VIDEOPLAYER_TOP250 },
{ "cast", VIDEOPLAYER_CAST },
{ "castandrole", VIDEOPLAYER_CAST_AND_ROLE },
{ "artist", VIDEOPLAYER_ARTIST },
{ "album", VIDEOPLAYER_ALBUM },
{ "writer", VIDEOPLAYER_WRITER },
{ "tagline", VIDEOPLAYER_TAGLINE },
{ "hasinfo", VIDEOPLAYER_HAS_INFO },
{ "trailer", VIDEOPLAYER_TRAILER },
{ "videocodec", VIDEOPLAYER_VIDEO_CODEC },
{ "videoresolution", VIDEOPLAYER_VIDEO_RESOLUTION },
{ "videoaspect", VIDEOPLAYER_VIDEO_ASPECT },
{ "audiocodec", VIDEOPLAYER_AUDIO_CODEC },
{ "audiochannels", VIDEOPLAYER_AUDIO_CHANNELS },
{ "hasteletext", VIDEOPLAYER_HASTELETEXT },
{ "lastplayed", VIDEOPLAYER_LASTPLAYED },
{ "playcount", VIDEOPLAYER_PLAYCOUNT },
{ "hassubtitles", VIDEOPLAYER_HASSUBTITLES },
{ "subtitlesenabled", VIDEOPLAYER_SUBTITLESENABLED }};
const infomap mediacontainer[] = {{ "hasfiles", CONTAINER_HASFILES },
{ "hasfolders", CONTAINER_HASFOLDERS },
{ "isstacked", CONTAINER_STACKED },
{ "folderthumb", CONTAINER_FOLDERTHUMB },
{ "tvshowthumb", CONTAINER_TVSHOWTHUMB },
{ "seasonthumb", CONTAINER_SEASONTHUMB },
{ "folderpath", CONTAINER_FOLDERPATH },
{ "foldername", CONTAINER_FOLDERNAME },
{ "pluginname", CONTAINER_PLUGINNAME },
{ "viewmode", CONTAINER_VIEWMODE },
{ "totaltime", CONTAINER_TOTALTIME },
{ "hasthumb", CONTAINER_HAS_THUMB },
{ "sortmethod", CONTAINER_SORT_METHOD },
{ "showplot", CONTAINER_SHOWPLOT }};
const infomap container_bools[] ={{ "onnext", CONTAINER_MOVE_NEXT },
{ "onprevious", CONTAINER_MOVE_PREVIOUS },
{ "onscrollnext", CONTAINER_SCROLL_NEXT },
{ "onscrollprevious", CONTAINER_SCROLL_PREVIOUS },
{ "numpages", CONTAINER_NUM_PAGES },
{ "numitems", CONTAINER_NUM_ITEMS },
{ "currentpage", CONTAINER_CURRENT_PAGE },
{ "scrolling", CONTAINER_SCROLLING },
{ "hasnext", CONTAINER_HAS_NEXT },
{ "hasprevious", CONTAINER_HAS_PREVIOUS }};
const infomap container_ints[] = {{ "row", CONTAINER_ROW },
{ "column", CONTAINER_COLUMN },
{ "position", CONTAINER_POSITION },
{ "subitem", CONTAINER_SUBITEM },
{ "hasfocus", CONTAINER_HAS_FOCUS }};
const infomap container_str[] = {{ "property", CONTAINER_PROPERTY },
{ "content", CONTAINER_CONTENT }};
const infomap listitem_labels[]= {{ "thumb", LISTITEM_THUMB },
{ "icon", LISTITEM_ICON },
{ "actualicon", LISTITEM_ACTUAL_ICON },
{ "overlay", LISTITEM_OVERLAY },
{ "label", LISTITEM_LABEL },
{ "label2", LISTITEM_LABEL2 },
{ "title", LISTITEM_TITLE },
{ "tracknumber", LISTITEM_TRACKNUMBER },
{ "artist", LISTITEM_ARTIST },
{ "album", LISTITEM_ALBUM },
{ "albumartist", LISTITEM_ALBUM_ARTIST },
{ "year", LISTITEM_YEAR },
{ "genre", LISTITEM_GENRE },
{ "director", LISTITEM_DIRECTOR },
{ "filename", LISTITEM_FILENAME },
{ "filenameandpath", LISTITEM_FILENAME_AND_PATH },
{ "fileextension", LISTITEM_FILE_EXTENSION },
{ "date", LISTITEM_DATE },
{ "size", LISTITEM_SIZE },
{ "rating", LISTITEM_RATING },
{ "ratingandvotes", LISTITEM_RATING_AND_VOTES },
{ "programcount", LISTITEM_PROGRAM_COUNT },
{ "duration", LISTITEM_DURATION },
{ "isselected", LISTITEM_ISSELECTED },
{ "isplaying", LISTITEM_ISPLAYING },
{ "plot", LISTITEM_PLOT },
{ "plotoutline", LISTITEM_PLOT_OUTLINE },
{ "episode", LISTITEM_EPISODE },
{ "season", LISTITEM_SEASON },
{ "tvshowtitle", LISTITEM_TVSHOW },
{ "premiered", LISTITEM_PREMIERED },
{ "comment", LISTITEM_COMMENT },
{ "path", LISTITEM_PATH },
{ "foldername", LISTITEM_FOLDERNAME },
{ "folderpath", LISTITEM_FOLDERPATH },
{ "picturepath", LISTITEM_PICTURE_PATH },
{ "pictureresolution",LISTITEM_PICTURE_RESOLUTION },
{ "picturedatetime", LISTITEM_PICTURE_DATETIME },
{ "picturecomment", LISTITEM_PICTURE_COMMENT },
{ "picturecaption", LISTITEM_PICTURE_CAPTION },
{ "picturedesc", LISTITEM_PICTURE_DESC },
{ "picturekeywords", LISTITEM_PICTURE_KEYWORDS },
{ "picturecammake", LISTITEM_PICTURE_CAM_MAKE },
{ "picturecammodel", LISTITEM_PICTURE_CAM_MODEL },
{ "pictureaperture", LISTITEM_PICTURE_APERTURE },
{ "picturefocallen", LISTITEM_PICTURE_FOCAL_LEN },
{ "picturefocusdist", LISTITEM_PICTURE_FOCUS_DIST },
{ "pictureexpmode", LISTITEM_PICTURE_EXP_MODE },
{ "pictureexptime", LISTITEM_PICTURE_EXP_TIME },
{ "pictureiso", LISTITEM_PICTURE_ISO },
{ "picturegpslat", LISTITEM_PICTURE_GPS_LAT },
{ "picturegpslon", LISTITEM_PICTURE_GPS_LON },
{ "picturegpsalt", LISTITEM_PICTURE_GPS_ALT },
{ "studio", LISTITEM_STUDIO },
{ "country", LISTITEM_COUNTRY },
{ "mpaa", LISTITEM_MPAA },
{ "cast", LISTITEM_CAST },
{ "castandrole", LISTITEM_CAST_AND_ROLE },
{ "writer", LISTITEM_WRITER },
{ "tagline", LISTITEM_TAGLINE },
{ "top250", LISTITEM_TOP250 },
{ "trailer", LISTITEM_TRAILER },
{ "starrating", LISTITEM_STAR_RATING },
{ "sortletter", LISTITEM_SORT_LETTER },
{ "videocodec", LISTITEM_VIDEO_CODEC },
{ "videoresolution", LISTITEM_VIDEO_RESOLUTION },
{ "videoaspect", LISTITEM_VIDEO_ASPECT },
{ "audiocodec", LISTITEM_AUDIO_CODEC },
{ "audiochannels", LISTITEM_AUDIO_CHANNELS },
{ "audiolanguage", LISTITEM_AUDIO_LANGUAGE },
{ "subtitlelanguage", LISTITEM_SUBTITLE_LANGUAGE },
{ "isresumable", LISTITEM_IS_RESUMABLE},
{ "percentplayed", LISTITEM_PERCENT_PLAYED},
{ "isfolder", LISTITEM_IS_FOLDER },
{ "originaltitle", LISTITEM_ORIGINALTITLE },
{ "lastplayed", LISTITEM_LASTPLAYED },
{ "playcount", LISTITEM_PLAYCOUNT },
{ "discnumber", LISTITEM_DISC_NUMBER },
{ "dateadded", LISTITEM_DATE_ADDED },
{ "dbtype", LISTITEM_DBTYPE },
{ "dbid", LISTITEM_DBID }};
const infomap visualisation[] = {{ "locked", VISUALISATION_LOCKED },
{ "preset", VISUALISATION_PRESET },
{ "name", VISUALISATION_NAME },
{ "enabled", VISUALISATION_ENABLED }};
const infomap fanart_labels[] = {{ "color1", FANART_COLOR1 },
{ "color2", FANART_COLOR2 },
{ "color3", FANART_COLOR3 },
{ "image", FANART_IMAGE }};
const infomap skin_labels[] = {{ "currenttheme", SKIN_THEME },
{ "currentcolourtheme",SKIN_COLOUR_THEME },
{"hasvideooverlay", SKIN_HAS_VIDEO_OVERLAY},
{"hasmusicoverlay", SKIN_HAS_MUSIC_OVERLAY}};
const infomap window_bools[] = {{ "ismedia", WINDOW_IS_MEDIA },
{ "isactive", WINDOW_IS_ACTIVE },
{ "istopmost", WINDOW_IS_TOPMOST },
{ "isvisible", WINDOW_IS_VISIBLE },
{ "previous", WINDOW_PREVIOUS },
{ "next", WINDOW_NEXT }};
const infomap control_labels[] = {{ "hasfocus", CONTROL_HAS_FOCUS },
{ "isvisible", CONTROL_IS_VISIBLE },
{ "isenabled", CONTROL_IS_ENABLED },
{ "getlabel", CONTROL_GET_LABEL }};
const infomap playlist[] = {{ "length", PLAYLIST_LENGTH },
{ "position", PLAYLIST_POSITION },
{ "random", PLAYLIST_RANDOM },
{ "repeat", PLAYLIST_REPEAT },
{ "israndom", PLAYLIST_ISRANDOM },
{ "isrepeat", PLAYLIST_ISREPEAT },
{ "isrepeatone", PLAYLIST_ISREPEATONE }};
const infomap slideshow[] = {{ "ispaused", SLIDESHOW_ISPAUSED },
{ "isactive", SLIDESHOW_ISACTIVE },
{ "israndom", SLIDESHOW_ISRANDOM }};
const int picture_slide_map[] = {/* LISTITEM_PICTURE_RESOLUTION => */ SLIDE_RESOLUTION,
/* LISTITEM_PICTURE_DATETIME => */ SLIDE_EXIF_DATE_TIME,
/* LISTITEM_PICTURE_COMMENT => */ SLIDE_COMMENT,
/* LISTITEM_PICTURE_CAPTION => */ SLIDE_IPTC_CAPTION,
/* LISTITEM_PICTURE_DESC => */ SLIDE_EXIF_DESCRIPTION,
/* LISTITEM_PICTURE_KEYWORDS => */ SLIDE_IPTC_KEYWORDS,
/* LISTITEM_PICTURE_CAM_MAKE => */ SLIDE_EXIF_CAMERA_MAKE,
/* LISTITEM_PICTURE_CAM_MODEL => */ SLIDE_EXIF_CAMERA_MODEL,
/* LISTITEM_PICTURE_APERTURE => */ SLIDE_EXIF_APERTURE,
/* LISTITEM_PICTURE_FOCAL_LEN => */ SLIDE_EXIF_FOCAL_LENGTH,
/* LISTITEM_PICTURE_FOCUS_DIST => */ SLIDE_EXIF_FOCUS_DIST,
/* LISTITEM_PICTURE_EXP_MODE => */ SLIDE_EXIF_EXPOSURE_MODE,
/* LISTITEM_PICTURE_EXP_TIME => */ SLIDE_EXIF_EXPOSURE_TIME,
/* LISTITEM_PICTURE_ISO => */ SLIDE_EXIF_ISO_EQUIV,
/* LISTITEM_PICTURE_GPS_LAT => */ SLIDE_EXIF_GPS_LATITUDE,
/* LISTITEM_PICTURE_GPS_LON => */ SLIDE_EXIF_GPS_LONGITUDE,
/* LISTITEM_PICTURE_GPS_ALT => */ SLIDE_EXIF_GPS_ALTITUDE };
CGUIInfoManager::Property::Property(const CStdString &property, const CStdString &parameters)
: name(property)
{
CUtil::SplitParams(parameters, params);
}
const CStdString &CGUIInfoManager::Property::param(unsigned int n /* = 0 */) const
{
if (n < params.size())
return params[n];
return StringUtils::EmptyString;
}
unsigned int CGUIInfoManager::Property::num_params() const
{
return params.size();
}
void CGUIInfoManager::SplitInfoString(const CStdString &infoString, vector<Property> &info)
{
// our string is of the form:
// category[(params)][.info(params).info2(params)] ...
// so we need to split on . while taking into account of () pairs
unsigned int parentheses = 0;
CStdString property;
CStdString param;
for (size_t i = 0; i < infoString.size(); ++i)
{
if (infoString[i] == '(')
{
if (!parentheses++)
continue;
}
else if (infoString[i] == ')')
{
if (!parentheses)
CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
else if (!--parentheses)
continue;
}
else if (infoString[i] == '.' && !parentheses)
{
if (!property.IsEmpty()) // add our property and parameters
info.push_back(Property(property.ToLower(), param));
property.clear();
param.clear();
continue;
}
if (parentheses)
param += infoString[i];
else
property += infoString[i];
}
if (parentheses)
CLog::Log(LOGERROR, "unmatched parentheses in %s", infoString.c_str());
if (!property.IsEmpty())
info.push_back(Property(property.ToLower(), param));
}
/// \brief Translates a string as given by the skin into an int that we use for more
/// efficient retrieval of data.
int CGUIInfoManager::TranslateSingleString(const CStdString &strCondition)
{
// trim whitespace, and convert to lowercase
CStdString strTest = strCondition;
strTest.TrimLeft(" \t\r\n");
strTest.TrimRight(" \t\r\n");
vector< Property> info;
SplitInfoString(strTest, info);
if (info.empty())
return 0;
const Property &cat = info[0];
if (info.size() == 1)
{ // single category
if (cat.name == "false" || cat.name == "no" || cat.name == "off")
return SYSTEM_ALWAYS_FALSE;
else if (cat.name == "true" || cat.name == "yes" || cat.name == "on")
return SYSTEM_ALWAYS_TRUE;
if (cat.name == "isempty" && cat.num_params() == 1)
return AddMultiInfo(GUIInfo(STRING_IS_EMPTY, TranslateSingleString(cat.param())));
else if (cat.name == "stringcompare" && cat.num_params() == 2)
{
int info = TranslateSingleString(cat.param(0));
int info2 = TranslateSingleString(cat.param(1));
if (info2 > 0)
return AddMultiInfo(GUIInfo(STRING_COMPARE, info, -info2));
// pipe our original string through the localize parsing then make it lowercase (picks up $LBRACKET etc.)
CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)).ToLower();
int compareString = ConditionalStringParameter(label);
return AddMultiInfo(GUIInfo(STRING_COMPARE, info, compareString));
}
else if (cat.name == "integergreaterthan" && cat.num_params() == 2)
{
int info = TranslateSingleString(cat.param(0));
int compareInt = atoi(cat.param(1).c_str());
return AddMultiInfo(GUIInfo(INTEGER_GREATER_THAN, info, compareInt));
}
else if (cat.name == "substring" && cat.num_params() >= 2)
{
int info = TranslateSingleString(cat.param(0));
CStdString label = CGUIInfoLabel::GetLabel(cat.param(1)).ToLower();
int compareString = ConditionalStringParameter(label);
if (cat.num_params() > 2)
{
if (cat.param(2).CompareNoCase("left") == 0)
return AddMultiInfo(GUIInfo(STRING_STR_LEFT, info, compareString));
else if (cat.param(2).CompareNoCase("right") == 0)
return AddMultiInfo(GUIInfo(STRING_STR_RIGHT, info, compareString));
}
return AddMultiInfo(GUIInfo(STRING_STR, info, compareString));
}
}
else if (info.size() == 2)
{
const Property &prop = info[1];
if (cat.name == "player")
{
for (size_t i = 0; i < sizeof(player_labels) / sizeof(infomap); i++)
{
if (prop.name == player_labels[i].str)
return player_labels[i].val;
}
for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++)
{
if (prop.name == player_times[i].str)
return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
}
if (prop.num_params() == 1)
{
for (size_t i = 0; i < sizeof(player_param) / sizeof(infomap); i++)
{
if (prop.name == player_param[i].str)
return AddMultiInfo(GUIInfo(player_param[i].val, ConditionalStringParameter(prop.param())));
}
}
}
else if (cat.name == "weather")
{
for (size_t i = 0; i < sizeof(weather) / sizeof(infomap); i++)
{
if (prop.name == weather[i].str)
return weather[i].val;
}
}
else if (cat.name == "lcd")
{
for (size_t i = 0; i < sizeof(lcd_labels) / sizeof(infomap); i++)
{
if (prop.name == lcd_labels[i].str)
return lcd_labels[i].val;
}
}
else if (cat.name == "network")
{
for (size_t i = 0; i < sizeof(network_labels) / sizeof(infomap); i++)
{
if (prop.name == network_labels[i].str)
return network_labels[i].val;
}
}
else if (cat.name == "musicpartymode")
{
for (size_t i = 0; i < sizeof(musicpartymode) / sizeof(infomap); i++)
{
if (prop.name == musicpartymode[i].str)
return musicpartymode[i].val;
}
}
else if (cat.name == "audioscrobbler")
{
for (size_t i = 0; i < sizeof(audioscrobbler) / sizeof(infomap); i++)
{
if (prop.name == audioscrobbler[i].str)
return audioscrobbler[i].val;
}
}
else if (cat.name == "lastfm")
{
for (size_t i = 0; i < sizeof(lastfm) / sizeof(infomap); i++)
{
if (prop.name == lastfm[i].str)
return lastfm[i].val;
}
}
else if (cat.name == "system")
{
for (size_t i = 0; i < sizeof(system_labels) / sizeof(infomap); i++)
{
if (prop.name == system_labels[i].str)
return system_labels[i].val;
}
if (prop.num_params() == 1)
{
const CStdString &param = prop.param();
for (size_t i = 0; i < sizeof(system_param) / sizeof(infomap); i++)
{
if (prop.name == system_param[i].str)
return AddMultiInfo(GUIInfo(system_param[i].val, ConditionalStringParameter(param)));
}
if (prop.name == "memory")
{
if (param == "free") return SYSTEM_FREE_MEMORY;
else if (param == "free.percent") return SYSTEM_FREE_MEMORY_PERCENT;
else if (param == "used") return SYSTEM_USED_MEMORY;
else if (param == "used.percent") return SYSTEM_USED_MEMORY_PERCENT;
else if (param == "total") return SYSTEM_TOTAL_MEMORY;
}
else if (prop.name == "addontitle")
{
int infoLabel = TranslateSingleString(param);
if (infoLabel > 0)
return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, infoLabel, 0));
CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
return AddMultiInfo(GUIInfo(SYSTEM_ADDON_TITLE, ConditionalStringParameter(label), 1));
}
else if (prop.name == "addonicon")
{
int infoLabel = TranslateSingleString(param);
if (infoLabel > 0)
return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, infoLabel, 0));
CStdString label = CGUIInfoLabel::GetLabel(param).ToLower();
return AddMultiInfo(GUIInfo(SYSTEM_ADDON_ICON, ConditionalStringParameter(label), 1));
}
else if (prop.name == "idletime")
return AddMultiInfo(GUIInfo(SYSTEM_IDLE_TIME, atoi(param.c_str())));
}
if (prop.name == "alarmlessorequal" && prop.num_params() == 2)
return AddMultiInfo(GUIInfo(SYSTEM_ALARM_LESS_OR_EQUAL, ConditionalStringParameter(prop.param(0)), ConditionalStringParameter(prop.param(1))));
else if (prop.name == "date")
{
if (prop.num_params() == 2)
return AddMultiInfo(GUIInfo(SYSTEM_DATE, StringUtils::DateStringToYYYYMMDD(prop.param(0)) % 10000, StringUtils::DateStringToYYYYMMDD(prop.param(1)) % 10000));
else if (prop.num_params() == 1)
{
int dateformat = StringUtils::DateStringToYYYYMMDD(prop.param(0));
if (dateformat <= 0) // not concrete date
return AddMultiInfo(GUIInfo(SYSTEM_DATE, ConditionalStringParameter(prop.param(0), true), -1));
else
return AddMultiInfo(GUIInfo(SYSTEM_DATE, dateformat % 10000));
}
return SYSTEM_DATE;
}
else if (prop.name == "time")
{
if (prop.num_params() == 0)
return AddMultiInfo(GUIInfo(SYSTEM_TIME, TIME_FORMAT_GUESS));
if (prop.num_params() == 1)
{
TIME_FORMAT timeFormat = TranslateTimeFormat(prop.param(0));
if (timeFormat == TIME_FORMAT_GUESS)
return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0))));
return AddMultiInfo(GUIInfo(SYSTEM_TIME, timeFormat));
}
else
return AddMultiInfo(GUIInfo(SYSTEM_TIME, StringUtils::TimeStringToSeconds(prop.param(0)), StringUtils::TimeStringToSeconds(prop.param(1))));
}
}
else if (cat.name == "library")
{
if (prop.name == "isscanning") return LIBRARY_IS_SCANNING;
else if (prop.name == "isscanningvideo") return LIBRARY_IS_SCANNING_VIDEO; // TODO: change to IsScanning(Video)
else if (prop.name == "isscanningmusic") return LIBRARY_IS_SCANNING_MUSIC;
else if (prop.name == "hascontent" && prop.num_params())
{
CStdString cat = prop.param(0); cat.ToLower();
if (cat == "music") return LIBRARY_HAS_MUSIC;
else if (cat == "video") return LIBRARY_HAS_VIDEO;
else if (cat == "movies") return LIBRARY_HAS_MOVIES;
else if (cat == "tvshows") return LIBRARY_HAS_TVSHOWS;
else if (cat == "musicvideos") return LIBRARY_HAS_MUSICVIDEOS;
else if (cat == "moviesets") return LIBRARY_HAS_MOVIE_SETS;
}
}
else if (cat.name == "musicplayer")
{
for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
{
if (prop.name == player_times[i].str)
return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
}
if (prop.name == "property")
return AddListItemProp(prop.param(), MUSICPLAYER_PROPERTY_OFFSET);
return TranslateMusicPlayerString(prop.name);
}
else if (cat.name == "videoplayer")
{
for (size_t i = 0; i < sizeof(player_times) / sizeof(infomap); i++) // TODO: remove these, they're repeats
{
if (prop.name == player_times[i].str)
return AddMultiInfo(GUIInfo(player_times[i].val, TranslateTimeFormat(prop.param())));
}
if (prop.name == "content" && prop.num_params())
return AddMultiInfo(GUIInfo(VIDEOPLAYER_CONTENT, ConditionalStringParameter(prop.param()), 0));
for (size_t i = 0; i < sizeof(videoplayer) / sizeof(infomap); i++)
{
if (prop.name == videoplayer[i].str)
return videoplayer[i].val;
}
}
else if (cat.name == "slideshow")
{
for (size_t i = 0; i < sizeof(slideshow) / sizeof(infomap); i++)
{
if (prop.name == slideshow[i].str)
return slideshow[i].val;
}
return CPictureInfoTag::TranslateString(prop.name);
}
else if (cat.name == "container")
{
for (size_t i = 0; i < sizeof(mediacontainer) / sizeof(infomap); i++) // these ones don't have or need an id
{
if (prop.name == mediacontainer[i].str)
return mediacontainer[i].val;
}
int id = atoi(cat.param().c_str());
for (size_t i = 0; i < sizeof(container_bools) / sizeof(infomap); i++) // these ones can have an id (but don't need to?)
{
if (prop.name == container_bools[i].str)
return id ? AddMultiInfo(GUIInfo(container_bools[i].val, id)) : container_bools[i].val;
}
for (size_t i = 0; i < sizeof(container_ints) / sizeof(infomap); i++) // these ones can have an int param on the property
{
if (prop.name == container_ints[i].str)
return AddMultiInfo(GUIInfo(container_ints[i].val, id, atoi(prop.param().c_str())));
}
for (size_t i = 0; i < sizeof(container_str) / sizeof(infomap); i++) // these ones have a string param on the property
{
if (prop.name == container_str[i].str)
return AddMultiInfo(GUIInfo(container_str[i].val, id, ConditionalStringParameter(prop.param())));
}
if (prop.name == "sortdirection")
{
SortOrder order = SortOrderNone;
if (prop.param().Equals("ascending"))
order = SortOrderAscending;
else if (prop.param().Equals("descending"))
order = SortOrderDescending;
return AddMultiInfo(GUIInfo(CONTAINER_SORT_DIRECTION, order));
}
else if (prop.name == "sort")
{
SORT_METHOD sort = SORT_METHOD_NONE;
if (prop.param().Equals("songrating")) sort = SORT_METHOD_SONG_RATING;
if (sort != SORT_METHOD_NONE)
return AddMultiInfo(GUIInfo(CONTAINER_SORT_METHOD, sort));
}
}
else if (cat.name == "listitem")
{
int offset = atoi(cat.param().c_str());
int ret = TranslateListItem(prop);
if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_WRAP));
return ret;
}
else if (cat.name == "listitemposition")
{
int offset = atoi(cat.param().c_str());
int ret = TranslateListItem(prop);
if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
return AddMultiInfo(GUIInfo(ret, 0, offset, INFOFLAG_LISTITEM_POSITION));
return ret;
}
else if (cat.name == "listitemnowrap")
{
int offset = atoi(cat.param().c_str());
int ret = TranslateListItem(prop);
if (offset || ret == LISTITEM_ISSELECTED || ret == LISTITEM_ISPLAYING || ret == LISTITEM_IS_FOLDER)
return AddMultiInfo(GUIInfo(ret, 0, offset));
return ret;
}
else if (cat.name == "visualisation")
{
for (size_t i = 0; i < sizeof(visualisation) / sizeof(infomap); i++)
{
if (prop.name == visualisation[i].str)
return visualisation[i].val;
}
}
else if (cat.name == "fanart")
{
for (size_t i = 0; i < sizeof(fanart_labels) / sizeof(infomap); i++)
{
if (prop.name == fanart_labels[i].str)
return fanart_labels[i].val;
}
}
else if (cat.name == "skin")
{
for (size_t i = 0; i < sizeof(skin_labels) / sizeof(infomap); i++)
{
if (prop.name == skin_labels[i].str)
return skin_labels[i].val;
}
if (prop.num_params())
{
if (prop.name == "string")
{
if (prop.num_params() == 2)
return AddMultiInfo(GUIInfo(SKIN_STRING, g_settings.TranslateSkinString(prop.param(0)), ConditionalStringParameter(prop.param(1))));
else
return AddMultiInfo(GUIInfo(SKIN_STRING, g_settings.TranslateSkinString(prop.param(0))));
}
if (prop.name == "hassetting")
return AddMultiInfo(GUIInfo(SKIN_BOOL, g_settings.TranslateSkinBool(prop.param(0))));
else if (prop.name == "hastheme")
return AddMultiInfo(GUIInfo(SKIN_HAS_THEME, ConditionalStringParameter(prop.param(0))));
}
}
else if (cat.name == "window")
{
if (prop.name == "property" && prop.num_params() == 1)
{ // TODO: this doesn't support foo.xml
int winID = cat.param().IsEmpty() ? 0 : CButtonTranslator::TranslateWindow(cat.param());
if (winID != WINDOW_INVALID)
return AddMultiInfo(GUIInfo(WINDOW_PROPERTY, winID, ConditionalStringParameter(prop.param())));
}
for (size_t i = 0; i < sizeof(window_bools) / sizeof(infomap); i++)
{
if (prop.name == window_bools[i].str)
{ // TODO: The parameter for these should really be on the first not the second property
if (prop.param().Find("xml") >= 0)
return AddMultiInfo(GUIInfo(window_bools[i].val, 0, ConditionalStringParameter(prop.param())));
int winID = prop.param().IsEmpty() ? 0 : CButtonTranslator::TranslateWindow(prop.param());
if (winID != WINDOW_INVALID)
return AddMultiInfo(GUIInfo(window_bools[i].val, winID, 0));
return 0;
}
}
}
else if (cat.name == "control")
{
for (size_t i = 0; i < sizeof(control_labels) / sizeof(infomap); i++)
{
if (prop.name == control_labels[i].str)
{ // TODO: The parameter for these should really be on the first not the second property
int controlID = atoi(prop.param().c_str());
if (controlID)
return AddMultiInfo(GUIInfo(control_labels[i].val, controlID, 0));
return 0;
}
}
}
else if (cat.name == "controlgroup" && prop.name == "hasfocus")
{
int groupID = atoi(cat.param().c_str());
if (groupID)
return AddMultiInfo(GUIInfo(CONTROL_GROUP_HAS_FOCUS, groupID, atoi(prop.param(0).c_str())));
}
else if (cat.name == "playlist")
{
for (size_t i = 0; i < sizeof(playlist) / sizeof(infomap); i++)
{
if (prop.name == playlist[i].str)
return playlist[i].val;
}
}
}
else if (info.size() == 3)
{
if (info[0].name == "system" && info[1].name == "platform")
{ // TODO: replace with a single system.platform
CStdString platform = info[2].name;
if (platform == "linux") return SYSTEM_PLATFORM_LINUX;
else if (platform == "windows") return SYSTEM_PLATFORM_WINDOWS;
else if (platform == "darwin") return SYSTEM_PLATFORM_DARWIN;
else if (platform == "osx") return SYSTEM_PLATFORM_DARWIN_OSX;
else if (platform == "ios") return SYSTEM_PLATFORM_DARWIN_IOS;
else if (platform == "atv2") return SYSTEM_PLATFORM_DARWIN_ATV2;
}
if (info[0].name == "musicplayer")
{ // TODO: these two don't allow duration(foo) and also don't allow more than this number of levels...
if (info[1].name == "position")
{
int position = atoi(info[1].param().c_str());
int value = TranslateMusicPlayerString(info[2].name); // musicplayer.position(foo).bar
return AddMultiInfo(GUIInfo(value, 0, position));
}
else if (info[1].name == "offset")
{
int position = atoi(info[1].param().c_str());
int value = TranslateMusicPlayerString(info[2].name); // musicplayer.offset(foo).bar
return AddMultiInfo(GUIInfo(value, 1, position));
}
}
else if (info[0].name == "container")
{
int id = atoi(info[0].param().c_str());
int offset = atoi(info[1].param().c_str());
if (info[1].name == "listitemnowrap")
return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset));
else if (info[1].name == "listitemposition")
return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_POSITION));
else if (info[1].name == "listitem")
return AddMultiInfo(GUIInfo(TranslateListItem(info[2]), id, offset, INFOFLAG_LISTITEM_WRAP));
}
}
return 0;
}
int CGUIInfoManager::TranslateListItem(const Property &info)
{
for (size_t i = 0; i < sizeof(listitem_labels) / sizeof(infomap); i++) // these ones don't have or need an id
{
if (info.name == listitem_labels[i].str)
return listitem_labels[i].val;
}
if (info.name == "property" && info.num_params() == 1)
return AddListItemProp(info.param());
return 0;
}
int CGUIInfoManager::TranslateMusicPlayerString(const CStdString &info) const
{
for (size_t i = 0; i < sizeof(musicplayer) / sizeof(infomap); i++)
{
if (info == musicplayer[i].str)
return musicplayer[i].val;
}
return 0;
}
TIME_FORMAT CGUIInfoManager::TranslateTimeFormat(const CStdString &format)
{
if (format.IsEmpty()) return TIME_FORMAT_GUESS;
else if (format.Equals("hh")) return TIME_FORMAT_HH;
else if (format.Equals("mm")) return TIME_FORMAT_MM;
else if (format.Equals("ss")) return TIME_FORMAT_SS;
else if (format.Equals("hh:mm")) return TIME_FORMAT_HH_MM;
else if (format.Equals("mm:ss")) return TIME_FORMAT_MM_SS;
else if (format.Equals("hh:mm:ss")) return TIME_FORMAT_HH_MM_SS;
else if (format.Equals("h")) return TIME_FORMAT_H;
else if (format.Equals("h:mm:ss")) return TIME_FORMAT_H_MM_SS;
else if (format.Equals("xx")) return TIME_FORMAT_XX;
return TIME_FORMAT_GUESS;
}
CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fallback)
{
if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
return GetSkinVariableString(info, false);
CStdString strLabel;
if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow);
if (info >= SLIDE_INFO_START && info <= SLIDE_INFO_END)
return GetPictureLabel(info);
if (info >= LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET &&
info - (LISTITEM_PROPERTY_START+MUSICPLAYER_PROPERTY_OFFSET) < (int)m_listitemProperties.size())
{ // grab the property
if (!m_currentFile)
return "";
CStdString property = m_listitemProperties[info - LISTITEM_PROPERTY_START-MUSICPLAYER_PROPERTY_OFFSET];
return m_currentFile->GetProperty(property).asString();
}
if (info >= LISTITEM_START && info <= LISTITEM_END)
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS); // true for has list items
if (window)
{
CFileItemPtr item = window->GetCurrentListItem();
strLabel = GetItemLabel(item.get(), info, fallback);
}
return strLabel;
}
switch (info)
{
case WEATHER_CONDITIONS:
strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_COND);
strLabel = strLabel.Trim();
break;
case WEATHER_TEMPERATURE:
strLabel.Format("%s%s", g_weatherManager.GetInfo(WEATHER_LABEL_CURRENT_TEMP), g_langInfo.GetTempUnitString().c_str());
break;
case WEATHER_LOCATION:
strLabel = g_weatherManager.GetInfo(WEATHER_LABEL_LOCATION);
break;
case WEATHER_FANART_CODE:
strLabel = URIUtils::GetFileName(g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON));
URIUtils::RemoveExtension(strLabel);
break;
case WEATHER_PLUGIN:
strLabel = g_guiSettings.GetString("weather.addon");
break;
case SYSTEM_DATE:
strLabel = GetDate();
break;
case LCD_DATE:
strLabel = GetDate(true);
break;
case SYSTEM_FPS:
strLabel.Format("%02.2f", m_fps);
break;
case PLAYER_VOLUME:
strLabel.Format("%2.1f dB", CAEUtil::PercentToGain(g_settings.m_fVolumeLevel));
break;
case PLAYER_SUBTITLE_DELAY:
strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_SubtitleDelay);
break;
case PLAYER_AUDIO_DELAY:
strLabel.Format("%2.3f s", g_settings.m_currentVideoSettings.m_AudioDelay);
break;
case PLAYER_CHAPTER:
if(g_application.IsPlaying() && g_application.m_pPlayer)
strLabel.Format("%02d", g_application.m_pPlayer->GetChapter());
break;
case PLAYER_CHAPTERCOUNT:
if(g_application.IsPlaying() && g_application.m_pPlayer)
strLabel.Format("%02d", g_application.m_pPlayer->GetChapterCount());
break;
case PLAYER_CHAPTERNAME:
if(g_application.IsPlaying() && g_application.m_pPlayer)
g_application.m_pPlayer->GetChapterName(strLabel);
break;
case PLAYER_CACHELEVEL:
{
int iLevel = 0;
if(g_application.IsPlaying() && GetInt(iLevel, PLAYER_CACHELEVEL) && iLevel >= 0)
strLabel.Format("%i", iLevel);
}
break;
case PLAYER_TIME:
if(g_application.IsPlaying() && g_application.m_pPlayer)
strLabel = GetCurrentPlayTime(TIME_FORMAT_HH_MM);
break;
case PLAYER_DURATION:
if(g_application.IsPlaying() && g_application.m_pPlayer)
strLabel = GetDuration(TIME_FORMAT_HH_MM);
break;
case PLAYER_PATH:
case PLAYER_FILEPATH:
if (m_currentFile)
{
if (m_currentFile->HasMusicInfoTag())
strLabel = m_currentFile->GetMusicInfoTag()->GetURL();
else if (m_currentFile->HasVideoInfoTag())
strLabel = m_currentFile->GetVideoInfoTag()->m_strFileNameAndPath;
if (strLabel.IsEmpty())
strLabel = m_currentFile->GetPath();
}
if (info == PLAYER_PATH)
{
// do this twice since we want the path outside the archive if this
// is to be of use.
if (URIUtils::IsInArchive(strLabel))
strLabel = URIUtils::GetParentPath(strLabel);
strLabel = URIUtils::GetParentPath(strLabel);
}
break;
case MUSICPLAYER_TITLE:
case MUSICPLAYER_ALBUM:
case MUSICPLAYER_ARTIST:
case MUSICPLAYER_ALBUM_ARTIST:
case MUSICPLAYER_GENRE:
case MUSICPLAYER_YEAR:
case MUSICPLAYER_TRACK_NUMBER:
case MUSICPLAYER_BITRATE:
case MUSICPLAYER_PLAYLISTLEN:
case MUSICPLAYER_PLAYLISTPOS:
case MUSICPLAYER_CHANNELS:
case MUSICPLAYER_BITSPERSAMPLE:
case MUSICPLAYER_SAMPLERATE:
case MUSICPLAYER_CODEC:
case MUSICPLAYER_DISC_NUMBER:
case MUSICPLAYER_RATING:
case MUSICPLAYER_COMMENT:
case MUSICPLAYER_LYRICS:
case MUSICPLAYER_PLAYCOUNT:
case MUSICPLAYER_LASTPLAYED:
strLabel = GetMusicLabel(info);
break;
case VIDEOPLAYER_TITLE:
case VIDEOPLAYER_ORIGINALTITLE:
case VIDEOPLAYER_GENRE:
case VIDEOPLAYER_DIRECTOR:
case VIDEOPLAYER_YEAR:
case VIDEOPLAYER_PLAYLISTLEN:
case VIDEOPLAYER_PLAYLISTPOS:
case VIDEOPLAYER_PLOT:
case VIDEOPLAYER_PLOT_OUTLINE:
case VIDEOPLAYER_EPISODE:
case VIDEOPLAYER_SEASON:
case VIDEOPLAYER_RATING:
case VIDEOPLAYER_RATING_AND_VOTES:
case VIDEOPLAYER_TVSHOW:
case VIDEOPLAYER_PREMIERED:
case VIDEOPLAYER_STUDIO:
case VIDEOPLAYER_COUNTRY:
case VIDEOPLAYER_MPAA:
case VIDEOPLAYER_TOP250:
case VIDEOPLAYER_CAST:
case VIDEOPLAYER_CAST_AND_ROLE:
case VIDEOPLAYER_ARTIST:
case VIDEOPLAYER_ALBUM:
case VIDEOPLAYER_WRITER:
case VIDEOPLAYER_TAGLINE:
case VIDEOPLAYER_TRAILER:
case VIDEOPLAYER_PLAYCOUNT:
case VIDEOPLAYER_LASTPLAYED:
strLabel = GetVideoLabel(info);
break;
case VIDEOPLAYER_VIDEO_CODEC:
if(g_application.IsPlaying() && g_application.m_pPlayer)
strLabel = g_application.m_pPlayer->GetVideoCodecName();
break;
case VIDEOPLAYER_VIDEO_RESOLUTION:
if(g_application.IsPlaying() && g_application.m_pPlayer)
return CStreamDetails::VideoDimsToResolutionDescription(g_application.m_pPlayer->GetPictureWidth(), g_application.m_pPlayer->GetPictureHeight());
break;
case VIDEOPLAYER_AUDIO_CODEC:
if(g_application.IsPlaying() && g_application.m_pPlayer)
strLabel = g_application.m_pPlayer->GetAudioCodecName();
break;
case VIDEOPLAYER_VIDEO_ASPECT:
if (g_application.IsPlaying() && g_application.m_pPlayer)
{
float aspect;
g_application.m_pPlayer->GetVideoAspectRatio(aspect);
strLabel = CStreamDetails::VideoAspectToAspectDescription(aspect);
}
break;
case VIDEOPLAYER_AUDIO_CHANNELS:
if(g_application.IsPlaying() && g_application.m_pPlayer)
strLabel.Format("%i", g_application.m_pPlayer->GetChannels());
break;
case PLAYLIST_LENGTH:
case PLAYLIST_POSITION:
case PLAYLIST_RANDOM:
case PLAYLIST_REPEAT:
strLabel = GetPlaylistLabel(info);
break;
case MUSICPM_SONGSPLAYED:
case MUSICPM_MATCHINGSONGS:
case MUSICPM_MATCHINGSONGSPICKED:
case MUSICPM_MATCHINGSONGSLEFT:
case MUSICPM_RELAXEDSONGSPICKED:
case MUSICPM_RANDOMSONGSPICKED:
strLabel = GetMusicPartyModeLabel(info);
break;
case SYSTEM_FREE_SPACE:
case SYSTEM_USED_SPACE:
case SYSTEM_TOTAL_SPACE:
case SYSTEM_FREE_SPACE_PERCENT:
case SYSTEM_USED_SPACE_PERCENT:
return g_sysinfo.GetHddSpaceInfo(info);
break;
case SYSTEM_CPU_TEMPERATURE:
case SYSTEM_GPU_TEMPERATURE:
case SYSTEM_FAN_SPEED:
case LCD_CPU_TEMPERATURE:
case LCD_GPU_TEMPERATURE:
case LCD_FAN_SPEED:
case SYSTEM_CPU_USAGE:
return GetSystemHeatInfo(info);
break;
case SYSTEM_VIDEO_ENCODER_INFO:
case NETWORK_MAC_ADDRESS:
case SYSTEM_KERNEL_VERSION:
case SYSTEM_CPUFREQUENCY:
case SYSTEM_INTERNET_STATE:
case SYSTEM_UPTIME:
case SYSTEM_TOTALUPTIME:
case SYSTEM_BATTERY_LEVEL:
return g_sysinfo.GetInfo(info);
break;
case SYSTEM_SCREEN_RESOLUTION:
if(g_Windowing.IsFullScreen())
strLabel.Format("%ix%i@%.2fHz - %s (%02.2f fps)",
g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iWidth,
g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iHeight,
g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].fRefreshRate,
g_localizeStrings.Get(244), GetFPS());
else
strLabel.Format("%ix%i - %s (%02.2f fps)",
g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iWidth,
g_settings.m_ResInfo[g_guiSettings.m_LookAndFeelResolution].iHeight,
g_localizeStrings.Get(242), GetFPS());
return strLabel;
break;
case CONTAINER_FOLDERPATH:
case CONTAINER_FOLDERNAME:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
{
if (info==CONTAINER_FOLDERNAME)
strLabel = ((CGUIMediaWindow*)window)->CurrentDirectory().GetLabel();
else
strLabel = CURL(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath()).GetWithoutUserDetails();
}
break;
}
case CONTAINER_PLUGINNAME:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
{
CURL url(((CGUIMediaWindow*)window)->CurrentDirectory().GetPath());
if (url.GetProtocol().Equals("plugin"))
{
strLabel = url.GetFileName();
URIUtils::RemoveSlashAtEnd(strLabel);
}
}
break;
}
case CONTAINER_VIEWMODE:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
{
const CGUIControl *control = window->GetControl(window->GetViewContainerID());
if (control && control->IsContainer())
strLabel = ((CGUIBaseContainer *)control)->GetLabel();
}
break;
}
case CONTAINER_SORT_METHOD:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
{
const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
if (viewState)
strLabel = g_localizeStrings.Get(viewState->GetSortMethodLabel());
}
}
break;
case CONTAINER_NUM_PAGES:
case CONTAINER_NUM_ITEMS:
case CONTAINER_CURRENT_PAGE:
return GetMultiInfoLabel(GUIInfo(info), contextWindow);
break;
case CONTAINER_SHOWPLOT:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("showplot").asString();
}
break;
case CONTAINER_TOTALTIME:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
{
const CFileItemList& items=((CGUIMediaWindow *)window)->CurrentDirectory();
int duration=0;
for (int i=0;i<items.Size();++i)
{
CFileItemPtr item=items.Get(i);
if (item->HasMusicInfoTag())
duration += item->GetMusicInfoTag()->GetDuration();
else if (item->HasVideoInfoTag())
duration += item->GetVideoInfoTag()->m_streamDetails.GetVideoDuration();
}
if (duration > 0)
return StringUtils::SecondsToTimeString(duration);
}
}
break;
case SYSTEM_BUILD_VERSION:
strLabel = GetVersion();
break;
case SYSTEM_BUILD_DATE:
strLabel = GetBuild();
break;
case SYSTEM_FREE_MEMORY:
case SYSTEM_FREE_MEMORY_PERCENT:
case SYSTEM_USED_MEMORY:
case SYSTEM_USED_MEMORY_PERCENT:
case SYSTEM_TOTAL_MEMORY:
{
MEMORYSTATUSEX stat;
stat.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&stat);
int iMemPercentFree = 100 - ((int)( 100.0f* (stat.ullTotalPhys - stat.ullAvailPhys)/stat.ullTotalPhys + 0.5f ));
int iMemPercentUsed = 100 - iMemPercentFree;
if (info == SYSTEM_FREE_MEMORY)
strLabel.Format("%luMB", (ULONG)(stat.ullAvailPhys/MB));
else if (info == SYSTEM_FREE_MEMORY_PERCENT)
strLabel.Format("%i%%", iMemPercentFree);
else if (info == SYSTEM_USED_MEMORY)
strLabel.Format("%luMB", (ULONG)((stat.ullTotalPhys - stat.ullAvailPhys)/MB));
else if (info == SYSTEM_USED_MEMORY_PERCENT)
strLabel.Format("%i%%", iMemPercentUsed);
else if (info == SYSTEM_TOTAL_MEMORY)
strLabel.Format("%luMB", (ULONG)(stat.ullTotalPhys/MB));
}
break;
case SYSTEM_SCREEN_MODE:
strLabel = g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].strMode;
break;
case SYSTEM_SCREEN_WIDTH:
strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iWidth);
break;
case SYSTEM_SCREEN_HEIGHT:
strLabel.Format("%i", g_settings.m_ResInfo[g_graphicsContext.GetVideoResolution()].iHeight);
break;
case SYSTEM_CURRENT_WINDOW:
return g_localizeStrings.Get(g_windowManager.GetFocusedWindow());
break;
case SYSTEM_CURRENT_CONTROL:
{
CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetFocusedWindow());
if (window)
{
CGUIControl *control = window->GetFocusedControl();
if (control)
strLabel = control->GetDescription();
}
}
break;
#ifdef HAS_DVD_DRIVE
case SYSTEM_DVD_LABEL:
strLabel = g_mediaManager.GetDiskLabel();
break;
#endif
case SYSTEM_ALARM_POS:
if (g_alarmClock.GetRemaining("shutdowntimer") == 0.f)
strLabel = "";
else
{
double fTime = g_alarmClock.GetRemaining("shutdowntimer");
if (fTime > 60.f)
strLabel.Format(g_localizeStrings.Get(13213).c_str(),g_alarmClock.GetRemaining("shutdowntimer")/60.f);
else
strLabel.Format(g_localizeStrings.Get(13214).c_str(),g_alarmClock.GetRemaining("shutdowntimer"));
}
break;
case SYSTEM_PROFILENAME:
strLabel = g_settings.GetCurrentProfile().getName();
break;
case SYSTEM_PROFILECOUNT:
strLabel.Format("%i", g_settings.GetNumProfiles());
break;
case SYSTEM_LANGUAGE:
strLabel = g_guiSettings.GetString("locale.language");
break;
case SYSTEM_TEMPERATURE_UNITS:
strLabel = g_langInfo.GetTempUnitString();
break;
case SYSTEM_PROGRESS_BAR:
{
int percent;
if (GetInt(percent, SYSTEM_PROGRESS_BAR) && percent > 0)
strLabel.Format("%i", percent);
}
break;
case SYSTEM_FRIENDLY_NAME:
{
CStdString friendlyName = g_guiSettings.GetString("services.devicename");
if (friendlyName.Equals("XBMC"))
strLabel.Format("%s (%s)", friendlyName.c_str(), g_application.getNetwork().GetHostName().c_str());
else
strLabel = friendlyName;
}
break;
case LCD_PLAY_ICON:
{
int iPlaySpeed = g_application.GetPlaySpeed();
if (g_application.IsPaused())
strLabel.Format("\7");
else if (iPlaySpeed < 1)
strLabel.Format("\3:%ix", iPlaySpeed);
else if (iPlaySpeed > 1)
strLabel.Format("\4:%ix", iPlaySpeed);
else
strLabel.Format("\5");
}
break;
case LCD_TIME_21:
case LCD_TIME_22:
case LCD_TIME_W21:
case LCD_TIME_W22:
case LCD_TIME_41:
case LCD_TIME_42:
case LCD_TIME_43:
case LCD_TIME_44:
//alternatively, set strLabel
return GetLcdTime( info );
break;
case SKIN_THEME:
strLabel = g_guiSettings.GetString("lookandfeel.skintheme");
break;
case SKIN_COLOUR_THEME:
strLabel = g_guiSettings.GetString("lookandfeel.skincolors");
break;
#ifdef HAS_LCD
case LCD_PROGRESS_BAR:
if (g_lcd && g_lcd->IsConnected()) strLabel = g_lcd->GetProgressBar(g_application.GetTime(), g_application.GetTotalTime());
break;
#endif
case NETWORK_IP_ADDRESS:
{
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
if (iface)
return iface->GetCurrentIPAddress();
}
break;
case NETWORK_SUBNET_MASK:
{
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
if (iface)
return iface->GetCurrentNetmask();
}
break;
case NETWORK_GATEWAY_ADDRESS:
{
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
if (iface)
return iface->GetCurrentDefaultGateway();
}
break;
case NETWORK_DNS1_ADDRESS:
{
vector<CStdString> nss = g_application.getNetwork().GetNameServers();
if (nss.size() >= 1)
return nss[0];
}
break;
case NETWORK_DNS2_ADDRESS:
{
vector<CStdString> nss = g_application.getNetwork().GetNameServers();
if (nss.size() >= 2)
return nss[1];
}
break;
case NETWORK_DHCP_ADDRESS:
{
CStdString dhcpserver;
return dhcpserver;
}
break;
case NETWORK_LINK_STATE:
{
CStdString linkStatus = g_localizeStrings.Get(151);
linkStatus += " ";
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
if (iface && iface->IsConnected())
linkStatus += g_localizeStrings.Get(15207);
else
linkStatus += g_localizeStrings.Get(15208);
return linkStatus;
}
break;
case AUDIOSCROBBLER_CONN_STATE:
case AUDIOSCROBBLER_SUBMIT_INT:
case AUDIOSCROBBLER_FILES_CACHED:
case AUDIOSCROBBLER_SUBMIT_STATE:
strLabel=GetAudioScrobblerLabel(info);
break;
case VISUALISATION_PRESET:
{
CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
g_windowManager.SendMessage(msg);
if (msg.GetPointer())
{
CVisualisation* viz = NULL;
viz = (CVisualisation*)msg.GetPointer();
if (viz)
{
strLabel = viz->GetPresetName();
URIUtils::RemoveExtension(strLabel);
}
}
}
break;
case VISUALISATION_NAME:
{
AddonPtr addon;
strLabel = g_guiSettings.GetString("musicplayer.visualisation");
if (CAddonMgr::Get().GetAddon(strLabel,addon) && addon)
strLabel = addon->Name();
}
break;
case FANART_COLOR1:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color1").asString();
}
break;
case FANART_COLOR2:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color2").asString();
}
break;
case FANART_COLOR3:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_color3").asString();
}
break;
case FANART_IMAGE:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("fanart_image").asString();
}
break;
case SYSTEM_RENDER_VENDOR:
strLabel = g_Windowing.GetRenderVendor();
break;
case SYSTEM_RENDER_RENDERER:
strLabel = g_Windowing.GetRenderRenderer();
break;
case SYSTEM_RENDER_VERSION:
strLabel = g_Windowing.GetRenderVersionString();
break;
}
return strLabel;
}
// tries to get a integer value for use in progressbars/sliders and such
bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUIListItem *item /* = NULL */) const
{
if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
return GetMultiInfoInt(value, m_multiInfo[info - MULTI_INFO_START], contextWindow);
if (info >= LISTITEM_START && info <= LISTITEM_END)
return GetItemInt(value, item, info);
value = 0;
switch( info )
{
case PLAYER_VOLUME:
value = g_application.GetVolume();
return true;
case PLAYER_SUBTITLE_DELAY:
value = g_application.GetSubtitleDelay();
return true;
case PLAYER_AUDIO_DELAY:
value = g_application.GetAudioDelay();
return true;
case PLAYER_PROGRESS:
case PLAYER_PROGRESS_CACHE:
case PLAYER_SEEKBAR:
case PLAYER_CACHELEVEL:
case PLAYER_CHAPTER:
case PLAYER_CHAPTERCOUNT:
{
if( g_application.IsPlaying() && g_application.m_pPlayer)
{
switch( info )
{
case PLAYER_PROGRESS:
value = (int)(g_application.GetPercentage());
break;
case PLAYER_PROGRESS_CACHE:
value = (int)(g_application.GetCachePercentage());
break;
case PLAYER_SEEKBAR:
value = (int)g_application.GetSeekHandler()->GetPercent();
break;
case PLAYER_CACHELEVEL:
value = (int)(g_application.m_pPlayer->GetCacheLevel());
break;
case PLAYER_CHAPTER:
value = g_application.m_pPlayer->GetChapter();
break;
case PLAYER_CHAPTERCOUNT:
value = g_application.m_pPlayer->GetChapterCount();
break;
}
}
}
return true;
case SYSTEM_FREE_MEMORY:
case SYSTEM_USED_MEMORY:
{
MEMORYSTATUSEX stat;
stat.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&stat);
int memPercentUsed = (int)( 100.0f* (stat.ullTotalPhys - stat.ullAvailPhys)/stat.ullTotalPhys + 0.5f );
if (info == SYSTEM_FREE_MEMORY)
value = 100 - memPercentUsed;
else
value = memPercentUsed;
return true;
}
case SYSTEM_PROGRESS_BAR:
{
CGUIDialogProgress *bar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (bar && bar->IsDialogRunning())
value = bar->GetPercentage();
return true;
}
case SYSTEM_FREE_SPACE:
case SYSTEM_USED_SPACE:
{
g_sysinfo.GetHddSpaceInfo(value, info, true);
return true;
}
case SYSTEM_CPU_USAGE:
value = g_cpuInfo.getUsedPercentage();
return true;
case SYSTEM_BATTERY_LEVEL:
value = g_powerManager.BatteryLevel();
return true;
}
return false;
}
unsigned int CGUIInfoManager::Register(const CStdString &expression, int context)
{
CStdString condition(CGUIInfoLabel::ReplaceLocalize(expression));
condition.TrimLeft(" \t\r\n");
condition.TrimRight(" \t\r\n");
if (condition.IsEmpty())
return 0;
CSingleLock lock(m_critInfo);
// do we have the boolean expression already registered?
InfoBool test(condition, context);
for (unsigned int i = 0; i < m_bools.size(); ++i)
{
if (*m_bools[i] == test)
return i+1;
}
if (condition.find_first_of("|+[]!") != condition.npos)
m_bools.push_back(new InfoExpression(condition, context));
else
m_bools.push_back(new InfoSingle(condition, context));
return m_bools.size();
}
bool CGUIInfoManager::EvaluateBool(const CStdString &expression, int contextWindow)
{
bool result = false;
unsigned int info = Register(expression, contextWindow);
if (info)
result = GetBoolValue(info);
return result;
}
/*
TODO: what to do with item-based infobools...
these crop up:
1. if condition is between LISTITEM_START and LISTITEM_END
2. if condition is STRING_IS_EMPTY, STRING_COMPARE, STRING_STR, INTEGER_GREATER_THAN and the
corresponding label is between LISTITEM_START and LISTITEM_END
In both cases they shouldn't be in our cache as they depend on items outside of our control atm.
We only pass a listitem object in for controls inside a listitemlayout, so I think it's probably OK
to not cache these, as they're "pushed" out anyway.
The problem is how do we avoid these? The only thing we have to go on is the expression here, so I
guess what we have to do is call through via Update. One thing we don't handle, however, is that the
majority of conditions (even inside lists) don't depend on the listitem at all.
Advantage is that we know this at creation time I think, so could perhaps signal it in IsDirty()?
*/
bool CGUIInfoManager::GetBoolValue(unsigned int expression, const CGUIListItem *item)
{
if (expression && --expression < m_bools.size())
return m_bools[expression]->Get(m_updateTime, item);
return false;
}
// checks the condition and returns it as necessary. Currently used
// for toggle button controls and visibility of images.
bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListItem *item)
{
bool bReturn = false;
int condition = abs(condition1);
if (item && condition >= LISTITEM_START && condition < LISTITEM_END)
bReturn = GetItemBool(item, condition);
// Ethernet Link state checking
// Will check if the Xbox has a Ethernet Link connection! [Cable in!]
// This can used for the skinner to switch off Network or Inter required functions
else if ( condition == SYSTEM_ALWAYS_TRUE)
bReturn = true;
else if (condition == SYSTEM_ALWAYS_FALSE)
bReturn = false;
else if (condition == SYSTEM_ETHERNET_LINK_ACTIVE)
bReturn = true;
else if (condition == WINDOW_IS_MEDIA)
{ // note: This doesn't return true for dialogs (content, favourites, login, videoinfo)
CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
bReturn = (pWindow && pWindow->IsMediaWindow());
}
else if (condition == PLAYER_MUTED)
bReturn = g_settings.m_bMute;
else if (condition >= LIBRARY_HAS_MUSIC && condition <= LIBRARY_HAS_MUSICVIDEOS)
bReturn = GetLibraryBool(condition);
else if (condition == LIBRARY_IS_SCANNING)
{
if (g_application.IsMusicScanning() || g_application.IsVideoScanning())
bReturn = true;
else
bReturn = false;
}
else if (condition == LIBRARY_IS_SCANNING_VIDEO)
{
bReturn = g_application.IsVideoScanning();
}
else if (condition == LIBRARY_IS_SCANNING_MUSIC)
{
bReturn = g_application.IsMusicScanning();
}
else if (condition == SYSTEM_PLATFORM_LINUX)
#if defined(_LINUX) && !defined(TARGET_DARWIN)
bReturn = true;
#else
bReturn = false;
#endif
else if (condition == SYSTEM_PLATFORM_WINDOWS)
#ifdef WIN32
bReturn = true;
#else
bReturn = false;
#endif
else if (condition == SYSTEM_PLATFORM_DARWIN)
#ifdef TARGET_DARWIN
bReturn = true;
#else
bReturn = false;
#endif
else if (condition == SYSTEM_PLATFORM_DARWIN_OSX)
#ifdef TARGET_DARWIN_OSX
bReturn = true;
#else
bReturn = false;
#endif
else if (condition == SYSTEM_PLATFORM_DARWIN_IOS)
#ifdef TARGET_DARWIN_IOS
bReturn = true;
#else
bReturn = false;
#endif
else if (condition == SYSTEM_PLATFORM_DARWIN_ATV2)
#ifdef TARGET_DARWIN_IOS_ATV2
bReturn = true;
#else
bReturn = false;
#endif
else if (condition == SYSTEM_MEDIA_DVD)
bReturn = g_mediaManager.IsDiscInDrive();
#ifdef HAS_DVD_DRIVE
else if (condition == SYSTEM_DVDREADY)
bReturn = g_mediaManager.GetDriveStatus() != DRIVE_NOT_READY;
else if (condition == SYSTEM_TRAYOPEN)
bReturn = g_mediaManager.GetDriveStatus() == DRIVE_OPEN;
#endif
else if (condition == SYSTEM_CAN_POWERDOWN)
bReturn = g_powerManager.CanPowerdown();
else if (condition == SYSTEM_CAN_SUSPEND)
bReturn = g_powerManager.CanSuspend();
else if (condition == SYSTEM_CAN_HIBERNATE)
bReturn = g_powerManager.CanHibernate();
else if (condition == SYSTEM_CAN_REBOOT)
bReturn = g_powerManager.CanReboot();
else if (condition == SYSTEM_SCREENSAVER_ACTIVE)
bReturn = g_application.IsInScreenSaver();
else if (condition == PLAYER_SHOWINFO)
bReturn = m_playerShowInfo;
else if (condition == PLAYER_SHOWCODEC)
bReturn = m_playerShowCodec;
else if (condition >= MULTI_INFO_START && condition <= MULTI_INFO_END)
{
return GetMultiInfoBool(m_multiInfo[condition - MULTI_INFO_START], contextWindow, item);
}
else if (condition == SYSTEM_HASLOCKS)
bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE;
else if (condition == SYSTEM_HAS_PVR)
bReturn = false;
else if (condition == SYSTEM_ISMASTER)
bReturn = g_settings.GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser;
else if (condition == SYSTEM_ISFULLSCREEN)
bReturn = g_Windowing.IsFullScreen();
else if (condition == SYSTEM_ISSTANDALONE)
bReturn = g_application.IsStandAlone();
else if (condition == SYSTEM_LOGGEDON)
bReturn = !(g_windowManager.GetActiveWindow() == WINDOW_LOGIN_SCREEN);
else if (condition == SYSTEM_SHOW_EXIT_BUTTON)
bReturn = g_advancedSettings.m_showExitButton;
else if (condition == SYSTEM_HAS_LOGINSCREEN)
bReturn = g_settings.UsingLoginScreen();
else if (condition == WEATHER_IS_FETCHED)
bReturn = g_weatherManager.IsFetched();
else if (condition == SYSTEM_INTERNET_STATE)
{
g_sysinfo.GetInfo(condition);
bReturn = g_sysinfo.HasInternet();
}
else if (condition == SKIN_HAS_VIDEO_OVERLAY)
{
bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingVideo();
}
else if (condition == SKIN_HAS_MUSIC_OVERLAY)
{
bReturn = g_windowManager.IsOverlayAllowed() && g_application.IsPlayingAudio();
}
else if (condition == CONTAINER_HASFILES || condition == CONTAINER_HASFOLDERS)
{
CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (pWindow)
{
const CFileItemList& items=((CGUIMediaWindow*)pWindow)->CurrentDirectory();
for (int i=0;i<items.Size();++i)
{
CFileItemPtr item=items.Get(i);
if (!item->m_bIsFolder && condition == CONTAINER_HASFILES)
{
bReturn=true;
break;
}
else if (item->m_bIsFolder && !item->IsParentFolder() && condition == CONTAINER_HASFOLDERS)
{
bReturn=true;
break;
}
}
}
}
else if (condition == CONTAINER_STACKED)
{
CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (pWindow)
bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().GetProperty("isstacked").asBoolean();
}
else if (condition == CONTAINER_HAS_THUMB)
{
CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (pWindow)
bReturn = ((CGUIMediaWindow*)pWindow)->CurrentDirectory().HasThumbnail();
}
else if (condition == CONTAINER_HAS_NEXT || condition == CONTAINER_HAS_PREVIOUS || condition == CONTAINER_SCROLLING)
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
{
const CGUIControl* control = window->GetControl(window->GetViewContainerID());
if (control)
bReturn = control->GetCondition(condition, 0);
}
}
else if (condition == VIDEOPLAYER_HAS_INFO)
bReturn = (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->IsEmpty());
else if (condition >= CONTAINER_SCROLL_PREVIOUS && condition <= CONTAINER_SCROLL_NEXT)
{
// no parameters, so we assume it's just requested for a media window. It therefore
// can only happen if the list has focus.
CGUIWindow *pWindow = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (pWindow)
{
map<int,int>::const_iterator it = m_containerMoves.find(pWindow->GetViewContainerID());
if (it != m_containerMoves.end())
{
if (condition > CONTAINER_STATIC) // moving up
bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
else
bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
}
}
}
else if (condition == SLIDESHOW_ISPAUSED)
{
CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
bReturn = (slideShow && slideShow->IsPaused());
}
else if (condition == SLIDESHOW_ISRANDOM)
{
CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
bReturn = (slideShow && slideShow->IsShuffled());
}
else if (condition == SLIDESHOW_ISACTIVE)
{
CGUIWindowSlideShow *slideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
bReturn = (slideShow && slideShow->InSlideShow());
}
else if (g_application.IsPlaying())
{
switch (condition)
{
case PLAYER_HAS_MEDIA:
bReturn = true;
break;
case PLAYER_HAS_AUDIO:
bReturn = g_application.IsPlayingAudio();
break;
case PLAYER_HAS_VIDEO:
bReturn = g_application.IsPlayingVideo();
break;
case PLAYER_PLAYING:
bReturn = !g_application.IsPaused() && (g_application.GetPlaySpeed() == 1);
break;
case PLAYER_PAUSED:
bReturn = g_application.IsPaused();
break;
case PLAYER_REWINDING:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() < 1;
break;
case PLAYER_FORWARDING:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() > 1;
break;
case PLAYER_REWINDING_2x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -2;
break;
case PLAYER_REWINDING_4x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -4;
break;
case PLAYER_REWINDING_8x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -8;
break;
case PLAYER_REWINDING_16x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -16;
break;
case PLAYER_REWINDING_32x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == -32;
break;
case PLAYER_FORWARDING_2x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 2;
break;
case PLAYER_FORWARDING_4x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 4;
break;
case PLAYER_FORWARDING_8x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 8;
break;
case PLAYER_FORWARDING_16x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 16;
break;
case PLAYER_FORWARDING_32x:
bReturn = !g_application.IsPaused() && g_application.GetPlaySpeed() == 32;
break;
case PLAYER_CAN_RECORD:
bReturn = g_application.m_pPlayer->CanRecord();
break;
case PLAYER_RECORDING:
bReturn = g_application.m_pPlayer->IsRecording();
break;
case PLAYER_DISPLAY_AFTER_SEEK:
bReturn = GetDisplayAfterSeek();
break;
case PLAYER_CACHING:
bReturn = g_application.m_pPlayer->IsCaching();
break;
case PLAYER_SEEKBAR:
{
CGUIDialog *seekBar = (CGUIDialog*)g_windowManager.GetWindow(WINDOW_DIALOG_SEEK_BAR);
bReturn = seekBar ? seekBar->IsDialogRunning() : false;
}
break;
case PLAYER_SEEKING:
bReturn = m_playerSeeking;
break;
case PLAYER_SHOWTIME:
bReturn = m_playerShowTime;
break;
case PLAYER_PASSTHROUGH:
bReturn = g_application.m_pPlayer && g_application.m_pPlayer->IsPassthrough();
break;
case MUSICPM_ENABLED:
bReturn = g_partyModeManager.IsEnabled();
break;
case AUDIOSCROBBLER_ENABLED:
bReturn = CLastFmManager::GetInstance()->IsLastFmEnabled();
break;
case LASTFM_RADIOPLAYING:
bReturn = CLastFmManager::GetInstance()->IsRadioEnabled();
break;
case LASTFM_CANLOVE:
bReturn = CLastFmManager::GetInstance()->CanLove();
break;
case LASTFM_CANBAN:
bReturn = CLastFmManager::GetInstance()->CanBan();
break;
case MUSICPLAYER_HASPREVIOUS:
{
// requires current playlist be PLAYLIST_MUSIC
bReturn = false;
if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
bReturn = (g_playlistPlayer.GetCurrentSong() > 0); // not first song
}
break;
case MUSICPLAYER_HASNEXT:
{
// requires current playlist be PLAYLIST_MUSIC
bReturn = false;
if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
bReturn = (g_playlistPlayer.GetCurrentSong() < (g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size() - 1)); // not last song
}
break;
case MUSICPLAYER_PLAYLISTPLAYING:
{
bReturn = false;
if (g_application.IsPlayingAudio() && g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
bReturn = true;
}
break;
case VIDEOPLAYER_USING_OVERLAYS:
bReturn = (g_guiSettings.GetInt("videoplayer.rendermethod") == RENDER_OVERLAYS);
break;
case VIDEOPLAYER_ISFULLSCREEN:
bReturn = g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO;
break;
case VIDEOPLAYER_HASMENU:
bReturn = g_application.m_pPlayer->HasMenu();
break;
case PLAYLIST_ISRANDOM:
bReturn = g_playlistPlayer.IsShuffled(g_playlistPlayer.GetCurrentPlaylist());
break;
case PLAYLIST_ISREPEAT:
bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ALL;
break;
case PLAYLIST_ISREPEATONE:
bReturn = g_playlistPlayer.GetRepeat(g_playlistPlayer.GetCurrentPlaylist()) == PLAYLIST::REPEAT_ONE;
break;
case PLAYER_HASDURATION:
bReturn = g_application.GetTotalTime() > 0;
break;
case VIDEOPLAYER_HASTELETEXT:
if (g_application.m_pPlayer->GetTeletextCache())
bReturn = true;
break;
case VIDEOPLAYER_HASSUBTITLES:
bReturn = g_application.m_pPlayer->GetSubtitleCount() > 0;
break;
case VIDEOPLAYER_SUBTITLESENABLED:
bReturn = g_application.m_pPlayer->GetSubtitleVisible();
break;
case VISUALISATION_LOCKED:
{
CGUIMessage msg(GUI_MSG_GET_VISUALISATION, 0, 0);
g_windowManager.SendMessage(msg);
if (msg.GetPointer())
{
CVisualisation *pVis = (CVisualisation *)msg.GetPointer();
bReturn = pVis->IsLocked();
}
}
break;
case VISUALISATION_ENABLED:
bReturn = !g_guiSettings.GetString("musicplayer.visualisation").IsEmpty();
break;
default: // default, use integer value different from 0 as true
{
int val;
bReturn = GetInt(val, condition) && val != 0;
}
}
}
if (condition1 < 0)
bReturn = !bReturn;
return bReturn;
}
/// \brief Examines the multi information sent and returns true or false accordingly.
bool CGUIInfoManager::GetMultiInfoBool(const GUIInfo &info, int contextWindow, const CGUIListItem *item)
{
bool bReturn = false;
int condition = abs(info.m_info);
if (condition >= LISTITEM_START && condition <= LISTITEM_END)
{
if (!item)
{
CGUIWindow *window = NULL;
int data1 = info.GetData1();
if (!data1) // No container specified, so we lookup the current view container
{
window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
if (window && window->IsMediaWindow())
data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
}
if (!window) // If we don't have a window already (from lookup above), get one
window = GetWindowWithCondition(contextWindow, 0);
if (window)
{
const CGUIControl *control = window->GetControl(data1);
if (control && control->IsContainer())
item = ((CGUIBaseContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()).get();
}
}
if (item) // If we got a valid item, do the lookup
bReturn = GetItemBool(item, condition); // Image prioritizes images over labels (in the case of music item ratings for instance)
}
else
{
switch (condition)
{
case SKIN_BOOL:
{
bReturn = g_settings.GetSkinBool(info.GetData1());
}
break;
case SKIN_STRING:
{
if (info.GetData2())
bReturn = g_settings.GetSkinString(info.GetData1()).Equals(m_stringParameters[info.GetData2()]);
else
bReturn = !g_settings.GetSkinString(info.GetData1()).IsEmpty();
}
break;
case SKIN_HAS_THEME:
{
CStdString theme = g_guiSettings.GetString("lookandfeel.skintheme");
theme.ToLower();
URIUtils::RemoveExtension(theme);
bReturn = theme.Equals(m_stringParameters[info.GetData1()]);
}
break;
case STRING_IS_EMPTY:
// note: Get*Image() falls back to Get*Label(), so this should cover all of them
if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).IsEmpty();
else
bReturn = GetImage(info.GetData1(), contextWindow).IsEmpty();
break;
case STRING_COMPARE:
{
CStdString compare;
if (info.GetData2() < 0) // info labels are stored with negative numbers
{
int info2 = -info.GetData2();
if (item && item->IsFileItem() && info2 >= LISTITEM_START && info2 < LISTITEM_END)
compare = GetItemImage((const CFileItem *)item, info2);
else
compare = GetImage(info2, contextWindow);
}
else if (info.GetData2() < (int)m_stringParameters.size())
{ // conditional string
compare = m_stringParameters[info.GetData2()];
}
if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
bReturn = GetItemImage((const CFileItem *)item, info.GetData1()).Equals(compare);
else
bReturn = GetImage(info.GetData1(), contextWindow).Equals(compare);
}
break;
case INTEGER_GREATER_THAN:
{
int integer;
if (GetInt(integer, info.GetData1(), contextWindow, item))
bReturn = integer > info.GetData2();
else
{
CStdString value;
if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
value = GetItemImage((const CFileItem *)item, info.GetData1());
else
value = GetImage(info.GetData1(), contextWindow);
// Handle the case when a value contains time separator (:). This makes IntegerGreaterThan
// useful for Player.Time* members without adding a separate set of members returning time in seconds
if ( value.find_first_of( ':' ) != value.npos )
bReturn = StringUtils::TimeStringToSeconds( value ) > info.GetData2();
else
bReturn = atoi( value.c_str() ) > info.GetData2();
}
}
break;
case STRING_STR:
case STRING_STR_LEFT:
case STRING_STR_RIGHT:
{
CStdString compare = m_stringParameters[info.GetData2()];
// our compare string is already in lowercase, so lower case our label as well
// as CStdString::Find() is case sensitive
CStdString label;
if (item && item->IsFileItem() && info.GetData1() >= LISTITEM_START && info.GetData1() < LISTITEM_END)
label = GetItemImage((const CFileItem *)item, info.GetData1()).ToLower();
else
label = GetImage(info.GetData1(), contextWindow).ToLower();
if (condition == STRING_STR_LEFT)
bReturn = label.Find(compare) == 0;
else if (condition == STRING_STR_RIGHT)
bReturn = label.Find(compare) == (int)(label.size()-compare.size());
else
bReturn = label.Find(compare) > -1;
}
break;
case SYSTEM_ALARM_LESS_OR_EQUAL:
{
int time = lrint(g_alarmClock.GetRemaining(m_stringParameters[info.GetData1()]));
int timeCompare = atoi(m_stringParameters[info.GetData2()]);
if (time > 0)
bReturn = timeCompare >= time;
else
bReturn = false;
}
break;
case SYSTEM_IDLE_TIME:
bReturn = g_application.GlobalIdleTime() >= (int)info.GetData1();
break;
case CONTROL_GROUP_HAS_FOCUS:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
if (window)
bReturn = window->ControlGroupHasFocus(info.GetData1(), info.GetData2());
}
break;
case CONTROL_IS_VISIBLE:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
if (window)
{
// Note: This'll only work for unique id's
const CGUIControl *control = window->GetControl(info.GetData1());
if (control)
bReturn = control->IsVisible();
}
}
break;
case CONTROL_IS_ENABLED:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
if (window)
{
// Note: This'll only work for unique id's
const CGUIControl *control = window->GetControl(info.GetData1());
if (control)
bReturn = !control->IsDisabled();
}
}
break;
case CONTROL_HAS_FOCUS:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
if (window)
bReturn = (window->GetFocusedControlID() == (int)info.GetData1());
}
break;
case WINDOW_NEXT:
if (info.GetData1())
bReturn = ((int)info.GetData1() == m_nextWindowID);
else
{
CGUIWindow *window = g_windowManager.GetWindow(m_nextWindowID);
if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
bReturn = true;
}
break;
case WINDOW_PREVIOUS:
if (info.GetData1())
bReturn = ((int)info.GetData1() == m_prevWindowID);
else
{
CGUIWindow *window = g_windowManager.GetWindow(m_prevWindowID);
if (window && URIUtils::GetFileName(window->GetProperty("xmlfile").asString()).Equals(m_stringParameters[info.GetData2()]))
bReturn = true;
}
break;
case WINDOW_IS_VISIBLE:
if (info.GetData1())
bReturn = g_windowManager.IsWindowVisible(info.GetData1());
else
bReturn = g_windowManager.IsWindowVisible(m_stringParameters[info.GetData2()]);
break;
case WINDOW_IS_TOPMOST:
if (info.GetData1())
bReturn = g_windowManager.IsWindowTopMost(info.GetData1());
else
bReturn = g_windowManager.IsWindowTopMost(m_stringParameters[info.GetData2()]);
break;
case WINDOW_IS_ACTIVE:
if (info.GetData1())
bReturn = g_windowManager.IsWindowActive(info.GetData1());
else
bReturn = g_windowManager.IsWindowActive(m_stringParameters[info.GetData2()]);
break;
case SYSTEM_HAS_ALARM:
bReturn = g_alarmClock.HasAlarm(m_stringParameters[info.GetData1()]);
break;
case SYSTEM_GET_BOOL:
bReturn = g_guiSettings.GetBool(m_stringParameters[info.GetData1()]);
break;
case SYSTEM_HAS_CORE_ID:
bReturn = g_cpuInfo.HasCoreId(info.GetData1());
break;
case SYSTEM_SETTING:
{
if ( m_stringParameters[info.GetData1()].Equals("hidewatched") )
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
bReturn = g_settings.GetWatchMode(((CGUIMediaWindow *)window)->CurrentDirectory().GetContent()) == VIDEO_SHOW_UNWATCHED;
}
}
break;
case SYSTEM_HAS_ADDON:
{
AddonPtr addon;
bReturn = CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon) && addon;
break;
}
case CONTAINER_SCROLL_PREVIOUS:
case CONTAINER_MOVE_PREVIOUS:
case CONTAINER_MOVE_NEXT:
case CONTAINER_SCROLL_NEXT:
{
map<int,int>::const_iterator it = m_containerMoves.find(info.GetData1());
if (it != m_containerMoves.end())
{
if (condition > CONTAINER_STATIC) // moving up
bReturn = it->second >= std::max(condition - CONTAINER_STATIC, 1);
else
bReturn = it->second <= std::min(condition - CONTAINER_STATIC, -1);
}
}
break;
case CONTAINER_CONTENT:
{
CStdString content;
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
if (window)
{
if (window->GetID() == WINDOW_DIALOG_MUSIC_INFO)
content = ((CGUIDialogMusicInfo *)window)->CurrentDirectory().GetContent();
else if (window->GetID() == WINDOW_DIALOG_VIDEO_INFO)
content = ((CGUIDialogVideoInfo *)window)->CurrentDirectory().GetContent();
}
if (content.IsEmpty())
{
window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
content = ((CGUIMediaWindow *)window)->CurrentDirectory().GetContent();
}
bReturn = m_stringParameters[info.GetData2()].Equals(content);
}
break;
case CONTAINER_ROW:
case CONTAINER_COLUMN:
case CONTAINER_POSITION:
case CONTAINER_HAS_NEXT:
case CONTAINER_HAS_PREVIOUS:
case CONTAINER_SCROLLING:
case CONTAINER_SUBITEM:
{
const CGUIControl *control = NULL;
if (info.GetData1())
{ // container specified
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
if (window)
control = window->GetControl(info.GetData1());
}
else
{ // no container specified - assume a mediawindow
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
control = window->GetControl(window->GetViewContainerID());
}
if (control)
bReturn = control->GetCondition(condition, info.GetData2());
}
break;
case CONTAINER_HAS_FOCUS:
{ // grab our container
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
if (window)
{
const CGUIControl *control = window->GetControl(info.GetData1());
if (control && control->IsContainer())
{
CFileItemPtr item = boost::static_pointer_cast<CFileItem>(((CGUIBaseContainer *)control)->GetListItem(0));
if (item && item->m_iprogramCount == info.GetData2()) // programcount used to store item id
bReturn = true;
}
}
break;
}
case VIDEOPLAYER_CONTENT:
{
CStdString strContent="movies";
if (!m_currentFile->HasVideoInfoTag() || m_currentFile->GetVideoInfoTag()->IsEmpty())
strContent = "files";
if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_iSeason > -1) // episode
strContent = "episodes";
if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_artist.empty())
strContent = "musicvideos";
if (m_currentFile->HasVideoInfoTag() && m_currentFile->GetVideoInfoTag()->m_strStatus == "livetv")
strContent = "livetv";
bReturn = m_stringParameters[info.GetData1()].Equals(strContent);
}
break;
case CONTAINER_SORT_METHOD:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
{
const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
if (viewState)
bReturn = ((unsigned int)viewState->GetSortMethod() == info.GetData1());
}
break;
}
case CONTAINER_SORT_DIRECTION:
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
{
const CGUIViewState *viewState = ((CGUIMediaWindow*)window)->GetViewState();
if (viewState)
bReturn = ((unsigned int)viewState->GetDisplaySortOrder() == info.GetData1());
}
break;
}
case SYSTEM_DATE:
{
if (info.GetData2() == -1) // info doesn't contain valid startDate
return false;
CDateTime date = CDateTime::GetCurrentDateTime();
int currentDate = date.GetMonth()*100+date.GetDay();
int startDate = info.GetData1();
int stopDate = info.GetData2();
if (stopDate < startDate)
bReturn = currentDate >= startDate || currentDate < stopDate;
else
bReturn = currentDate >= startDate && currentDate < stopDate;
}
break;
case SYSTEM_TIME:
{
CDateTime time=CDateTime::GetCurrentDateTime();
int currentTime = time.GetMinuteOfDay();
int startTime = info.GetData1();
int stopTime = info.GetData2();
if (stopTime < startTime)
bReturn = currentTime >= startTime || currentTime < stopTime;
else
bReturn = currentTime >= startTime && currentTime < stopTime;
}
break;
case MUSICPLAYER_EXISTS:
{
int index = info.GetData2();
if (info.GetData1() == 1)
{ // relative index
if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
return false;
index += g_playlistPlayer.GetCurrentSong();
}
if (index >= 0 && index < g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC).size())
return true;
return false;
}
break;
}
}
return (info.m_info < 0) ? !bReturn : bReturn;
}
bool CGUIInfoManager::GetMultiInfoInt(int &value, const GUIInfo &info, int contextWindow) const
{
if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
{
CFileItemPtr item;
CGUIWindow *window = NULL;
int data1 = info.GetData1();
if (!data1) // No container specified, so we lookup the current view container
{
window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
if (window && window->IsMediaWindow())
data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
}
if (!window) // If we don't have a window already (from lookup above), get one
window = GetWindowWithCondition(contextWindow, 0);
if (window)
{
const CGUIControl *control = window->GetControl(data1);
if (control && control->IsContainer())
item = boost::static_pointer_cast<CFileItem>(((CGUIBaseContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
}
if (item) // If we got a valid item, do the lookup
return GetItemInt(value, item.get(), info.m_info);
}
return 0;
}
/// \brief Examines the multi information sent and returns the string as appropriate
CStdString CGUIInfoManager::GetMultiInfoLabel(const GUIInfo &info, int contextWindow, CStdString *fallback)
{
if (info.m_info == SKIN_STRING)
{
return g_settings.GetSkinString(info.GetData1());
}
else if (info.m_info == SKIN_BOOL)
{
bool bInfo = g_settings.GetSkinBool(info.GetData1());
if (bInfo)
return g_localizeStrings.Get(20122);
}
if (info.m_info >= LISTITEM_START && info.m_info <= LISTITEM_END)
{
CFileItemPtr item;
CGUIWindow *window = NULL;
int data1 = info.GetData1();
if (!data1) // No container specified, so we lookup the current view container
{
window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
if (window && window->IsMediaWindow())
data1 = ((CGUIMediaWindow*)(window))->GetViewContainerID();
}
if (!window) // If we don't have a window already (from lookup above), get one
window = GetWindowWithCondition(contextWindow, 0);
if (window)
{
const CGUIControl *control = window->GetControl(data1);
if (control && control->IsContainer())
item = boost::static_pointer_cast<CFileItem>(((CGUIBaseContainer *)control)->GetListItem(info.GetData2(), info.GetInfoFlag()));
}
if (item) // If we got a valid item, do the lookup
return GetItemImage(item.get(), info.m_info, fallback); // Image prioritizes images over labels (in the case of music item ratings for instance)
}
else if (info.m_info == PLAYER_TIME)
{
return GetCurrentPlayTime((TIME_FORMAT)info.GetData1());
}
else if (info.m_info == PLAYER_TIME_REMAINING)
{
return GetCurrentPlayTimeRemaining((TIME_FORMAT)info.GetData1());
}
else if (info.m_info == PLAYER_FINISH_TIME)
{
CDateTime time = CDateTime::GetCurrentDateTime();
time += CDateTimeSpan(0, 0, 0, GetPlayTimeRemaining());
return LocalizeTime(time, (TIME_FORMAT)info.GetData1());
}
else if (info.m_info == PLAYER_TIME_SPEED)
{
CStdString strTime;
if (g_application.GetPlaySpeed() != 1)
strTime.Format("%s (%ix)", GetCurrentPlayTime((TIME_FORMAT)info.GetData1()).c_str(), g_application.GetPlaySpeed());
else
strTime = GetCurrentPlayTime();
return strTime;
}
else if (info.m_info == PLAYER_DURATION)
{
return GetDuration((TIME_FORMAT)info.GetData1());
}
else if (info.m_info == PLAYER_SEEKTIME)
{
return GetCurrentSeekTime((TIME_FORMAT)info.GetData1());
}
else if (info.m_info == PLAYER_SEEKOFFSET)
{
CStdString seekOffset = StringUtils::SecondsToTimeString(abs(m_seekOffset), (TIME_FORMAT)info.GetData1());
if (m_seekOffset < 0)
return "-" + seekOffset;
if (m_seekOffset > 0)
return "+" + seekOffset;
}
else if (info.m_info == PLAYER_ITEM_PROPERTY)
{
return m_currentFile->GetProperty(m_stringParameters[info.GetData1()]).asString();
}
else if (info.m_info == SYSTEM_TIME)
{
return GetTime((TIME_FORMAT)info.GetData1());
}
else if (info.m_info == SYSTEM_DATE)
{
CDateTime time=CDateTime::GetCurrentDateTime();
return time.GetAsLocalizedDate(m_stringParameters[info.GetData1()],false);
}
else if (info.m_info == CONTAINER_NUM_PAGES || info.m_info == CONTAINER_CURRENT_PAGE ||
info.m_info == CONTAINER_NUM_ITEMS || info.m_info == CONTAINER_POSITION)
{
const CGUIControl *control = NULL;
if (info.GetData1())
{ // container specified
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
if (window)
control = window->GetControl(info.GetData1());
}
else
{ // no container specified - assume a mediawindow
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
control = window->GetControl(window->GetViewContainerID());
}
if (control)
{
if (control->IsContainer())
return ((CGUIBaseContainer *)control)->GetLabel(info.m_info);
else if (control->GetControlType() == CGUIControl::GUICONTROL_TEXTBOX)
return ((CGUITextBox *)control)->GetLabel(info.m_info);
}
}
else if (info.m_info == SYSTEM_GET_CORE_USAGE)
{
CStdString strCpu;
strCpu.Format("%4.2f", g_cpuInfo.GetCoreInfo(atoi(m_stringParameters[info.GetData1()].c_str())).m_fPct);
return strCpu;
}
else if (info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST)
return GetMusicPlaylistInfo(info);
else if (info.m_info == CONTAINER_PROPERTY)
{
CGUIWindow *window = NULL;
if (info.GetData1())
{ // container specified
window = GetWindowWithCondition(contextWindow, 0);
}
else
{ // no container specified - assume a mediawindow
window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
}
if (window)
return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty(m_stringParameters[info.GetData2()]).asString();
}
else if (info.m_info == CONTROL_GET_LABEL)
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, 0);
if (window)
{
const CGUIControl *control = window->GetControl(info.GetData1());
if (control)
return control->GetDescription();
}
}
else if (info.m_info == WINDOW_PROPERTY)
{
CGUIWindow *window = NULL;
if (info.GetData1())
{ // window specified
window = g_windowManager.GetWindow(info.GetData1());//GetWindowWithCondition(contextWindow, 0);
}
else
{ // no window specified - assume active
window = GetWindowWithCondition(contextWindow, 0);
}
if (window)
return window->GetProperty(m_stringParameters[info.GetData2()]).asString();
}
else if (info.m_info == SYSTEM_ADDON_TITLE ||
info.m_info == SYSTEM_ADDON_ICON)
{
// This logic does not check/care whether an addon has been disabled/marked as broken,
// it simply retrieves it's name or icon that means if an addon is placed on the home screen it
// will stay there even if it's disabled/marked as broken. This might need to be changed/fixed
// in the future.
AddonPtr addon;
if (info.GetData2() == 0)
CAddonMgr::Get().GetAddon(const_cast<CGUIInfoManager*>(this)->GetLabel(info.GetData1(), contextWindow),addon,ADDON_UNKNOWN,false);
else
CAddonMgr::Get().GetAddon(m_stringParameters[info.GetData1()],addon,ADDON_UNKNOWN,false);
if (addon && info.m_info == SYSTEM_ADDON_TITLE)
return addon->Name();
if (addon && info.m_info == SYSTEM_ADDON_ICON)
return addon->Icon();
}
return StringUtils::EmptyString;
}
/// \brief Obtains the filename of the image to show from whichever subsystem is needed
CStdString CGUIInfoManager::GetImage(int info, int contextWindow, CStdString *fallback)
{
if (info >= CONDITIONAL_LABEL_START && info <= CONDITIONAL_LABEL_END)
return GetSkinVariableString(info, true);
if (info >= MULTI_INFO_START && info <= MULTI_INFO_END)
{
return GetMultiInfoLabel(m_multiInfo[info - MULTI_INFO_START], contextWindow, fallback);
}
else if (info == WEATHER_CONDITIONS)
return g_weatherManager.GetInfo(WEATHER_IMAGE_CURRENT_ICON);
else if (info == SYSTEM_PROFILETHUMB)
{
CStdString thumb = g_settings.GetCurrentProfile().getThumb();
if (thumb.IsEmpty())
thumb = "unknown-user.png";
return thumb;
}
else if (info == MUSICPLAYER_COVER)
{
if (!g_application.IsPlayingAudio()) return "";
if (fallback)
*fallback = "DefaultAlbumCover.png";
return m_currentFile->HasThumbnail() ? m_currentFile->GetThumbnailImage() : "DefaultAlbumCover.png";
}
else if (info == MUSICPLAYER_RATING)
{
if (!g_application.IsPlayingAudio()) return "";
return GetItemImage(m_currentFile, LISTITEM_RATING);
}
else if (info == PLAYER_STAR_RATING)
{
if (!g_application.IsPlaying()) return "";
return GetItemImage(m_currentFile, LISTITEM_STAR_RATING);
}
else if (info == VIDEOPLAYER_COVER)
{
if (!g_application.IsPlayingVideo()) return "";
if (fallback)
*fallback = "DefaultVideoCover.png";
if(m_currentMovieThumb.IsEmpty())
return m_currentFile->HasThumbnail() ? m_currentFile->GetThumbnailImage() : "DefaultVideoCover.png";
else return m_currentMovieThumb;
}
else if (info == CONTAINER_FOLDERTHUMB)
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
return GetItemImage(&const_cast<CFileItemList&>(((CGUIMediaWindow*)window)->CurrentDirectory()), LISTITEM_THUMB, fallback);
}
else if (info == CONTAINER_TVSHOWTHUMB)
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("tvshowthumb").asString();
}
else if (info == CONTAINER_SEASONTHUMB)
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_IS_MEDIA_WINDOW);
if (window)
return ((CGUIMediaWindow *)window)->CurrentDirectory().GetProperty("seasonthumb").asString();
}
else if (info == LISTITEM_THUMB || info == LISTITEM_ICON || info == LISTITEM_ACTUAL_ICON ||
info == LISTITEM_OVERLAY || info == LISTITEM_RATING || info == LISTITEM_STAR_RATING)
{
CGUIWindow *window = GetWindowWithCondition(contextWindow, WINDOW_CONDITION_HAS_LIST_ITEMS);
if (window)
{
CFileItemPtr item = window->GetCurrentListItem();
if (item)
return GetItemImage(item.get(), info, fallback);
}
}
return GetLabel(info, contextWindow, fallback);
}
CStdString CGUIInfoManager::GetDate(bool bNumbersOnly)
{
CDateTime time=CDateTime::GetCurrentDateTime();
return time.GetAsLocalizedDate(!bNumbersOnly);
}
CStdString CGUIInfoManager::GetTime(TIME_FORMAT format) const
{
CDateTime time=CDateTime::GetCurrentDateTime();
return LocalizeTime(time, format);
}
CStdString CGUIInfoManager::GetLcdTime( int _eInfo ) const
{
CDateTime time=CDateTime::GetCurrentDateTime();
CStdString strLcdTime;
#ifdef HAS_LCD
UINT nCharset;
UINT nLine;
CStdString strTimeMarker;
nCharset = 0;
nLine = 0;
switch ( _eInfo )
{
case LCD_TIME_21:
nCharset = 1; // CUSTOM_CHARSET_SMALLCHAR;
nLine = 0;
strTimeMarker = ".";
break;
case LCD_TIME_22:
nCharset = 1; // CUSTOM_CHARSET_SMALLCHAR;
nLine = 1;
strTimeMarker = ".";
break;
case LCD_TIME_W21:
nCharset = 2; // CUSTOM_CHARSET_MEDIUMCHAR;
nLine = 0;
strTimeMarker = ".";
break;
case LCD_TIME_W22:
nCharset = 2; // CUSTOM_CHARSET_MEDIUMCHAR;
nLine = 1;
strTimeMarker = ".";
break;
case LCD_TIME_41:
nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
nLine = 0;
strTimeMarker = " ";
break;
case LCD_TIME_42:
nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
nLine = 1;
strTimeMarker = "o";
break;
case LCD_TIME_43:
nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
nLine = 2;
strTimeMarker = "o";
break;
case LCD_TIME_44:
nCharset = 3; // CUSTOM_CHARSET_BIGCHAR;
nLine = 3;
strTimeMarker = " ";
break;
}
strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetHour() , nLine, 2, 2, true );
strLcdTime += strTimeMarker;
strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetMinute(), nLine, 2, 2, false );
strLcdTime += strTimeMarker;
strLcdTime += g_lcd->GetBigDigit( nCharset, time.GetSecond(), nLine, 2, 2, false );
#endif
return strLcdTime;
}
CStdString CGUIInfoManager::LocalizeTime(const CDateTime &time, TIME_FORMAT format) const
{
const CStdString timeFormat = g_langInfo.GetTimeFormat();
bool use12hourclock = timeFormat.Find('h') != -1;
switch (format)
{
case TIME_FORMAT_GUESS:
return time.GetAsLocalizedTime("", false);
case TIME_FORMAT_SS:
return time.GetAsLocalizedTime("ss", true);
case TIME_FORMAT_MM:
return time.GetAsLocalizedTime("mm", true);
case TIME_FORMAT_MM_SS:
return time.GetAsLocalizedTime("mm:ss", true);
case TIME_FORMAT_HH: // this forces it to a 12 hour clock
return time.GetAsLocalizedTime(use12hourclock ? "h" : "HH", false);
case TIME_FORMAT_HH_MM:
return time.GetAsLocalizedTime(use12hourclock ? "h:mm" : "HH:mm", false);
case TIME_FORMAT_HH_MM_XX:
return time.GetAsLocalizedTime(use12hourclock ? "h:mm xx" : "HH:mm", false);
case TIME_FORMAT_HH_MM_SS:
return time.GetAsLocalizedTime("", true);
case TIME_FORMAT_H:
return time.GetAsLocalizedTime("h", false);
case TIME_FORMAT_H_MM_SS:
return time.GetAsLocalizedTime("h:mm:ss", true);
case TIME_FORMAT_XX:
return use12hourclock ? time.GetAsLocalizedTime("xx", false) : "";
default:
break;
}
return time.GetAsLocalizedTime("", false);
}
CStdString CGUIInfoManager::GetDuration(TIME_FORMAT format) const
{
if (g_application.IsPlayingAudio() && m_currentFile->HasMusicInfoTag())
{
const CMusicInfoTag& tag = *m_currentFile->GetMusicInfoTag();
if (tag.GetDuration() > 0)
return StringUtils::SecondsToTimeString(tag.GetDuration(), format);
}
if (g_application.IsPlayingVideo() && !m_currentMovieDuration.IsEmpty())
return m_currentMovieDuration; // for tuxbox
unsigned int iTotal = (unsigned int)g_application.GetTotalTime();
if (iTotal > 0)
return StringUtils::SecondsToTimeString(iTotal, format);
return "";
}
CStdString CGUIInfoManager::GetMusicPartyModeLabel(int item)
{
// get song counts
if (item >= MUSICPM_SONGSPLAYED && item <= MUSICPM_RANDOMSONGSPICKED)
{
int iSongs = -1;
switch (item)
{
case MUSICPM_SONGSPLAYED:
{
iSongs = g_partyModeManager.GetSongsPlayed();
break;
}
case MUSICPM_MATCHINGSONGS:
{
iSongs = g_partyModeManager.GetMatchingSongs();
break;
}
case MUSICPM_MATCHINGSONGSPICKED:
{
iSongs = g_partyModeManager.GetMatchingSongsPicked();
break;
}
case MUSICPM_MATCHINGSONGSLEFT:
{
iSongs = g_partyModeManager.GetMatchingSongsLeft();
break;
}
case MUSICPM_RELAXEDSONGSPICKED:
{
iSongs = g_partyModeManager.GetRelaxedSongs();
break;
}
case MUSICPM_RANDOMSONGSPICKED:
{
iSongs = g_partyModeManager.GetRandomSongs();
break;
}
}
if (iSongs < 0)
return "";
CStdString strLabel;
strLabel.Format("%i", iSongs);
return strLabel;
}
return "";
}
const CStdString CGUIInfoManager::GetMusicPlaylistInfo(const GUIInfo& info)
{
PLAYLIST::CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
if (playlist.size() < 1)
return "";
int index = info.GetData2();
if (info.GetData1() == 1)
{ // relative index (requires current playlist is PLAYLIST_MUSIC)
if (g_playlistPlayer.GetCurrentPlaylist() != PLAYLIST_MUSIC)
return "";
index = g_playlistPlayer.GetNextSong(index);
}
if (index < 0 || index >= playlist.size())
return "";
CFileItemPtr playlistItem = playlist[index];
if (!playlistItem->GetMusicInfoTag()->Loaded())
{
playlistItem->LoadMusicTag();
playlistItem->GetMusicInfoTag()->SetLoaded();
}
// try to set a thumbnail
if (!playlistItem->HasThumbnail())
{
CMusicThumbLoader::FillThumb(*playlistItem);
// still no thumb? then just the set the default cover TODO: remove me?
if (!playlistItem->HasThumbnail())
playlistItem->SetThumbnailImage("DefaultAlbumCover.png");
}
if (info.m_info == MUSICPLAYER_PLAYLISTPOS)
{
CStdString strPosition = "";
strPosition.Format("%i", index + 1);
return strPosition;
}
else if (info.m_info == MUSICPLAYER_COVER)
return playlistItem->GetThumbnailImage();
return GetMusicTagLabel(info.m_info, playlistItem.get());
}
CStdString CGUIInfoManager::GetPlaylistLabel(int item) const
{
if (!g_application.IsPlaying()) return "";
int iPlaylist = g_playlistPlayer.GetCurrentPlaylist();
switch (item)
{
case PLAYLIST_LENGTH:
{
CStdString strLength = "";
strLength.Format("%i", g_playlistPlayer.GetPlaylist(iPlaylist).size());
return strLength;
}
case PLAYLIST_POSITION:
{
CStdString strPosition = "";
strPosition.Format("%i", g_playlistPlayer.GetCurrentSong() + 1);
return strPosition;
}
case PLAYLIST_RANDOM:
{
if (g_playlistPlayer.IsShuffled(iPlaylist))
return g_localizeStrings.Get(590); // 590: Random
else
return g_localizeStrings.Get(591); // 591: Off
}
case PLAYLIST_REPEAT:
{
PLAYLIST::REPEAT_STATE state = g_playlistPlayer.GetRepeat(iPlaylist);
if (state == PLAYLIST::REPEAT_ONE)
return g_localizeStrings.Get(592); // 592: One
else if (state == PLAYLIST::REPEAT_ALL)
return g_localizeStrings.Get(593); // 593: All
else
return g_localizeStrings.Get(594); // 594: Off
}
}
return "";
}
CStdString CGUIInfoManager::GetMusicLabel(int item)
{
if (!g_application.IsPlayingAudio() || !m_currentFile->HasMusicInfoTag()) return "";
switch (item)
{
case MUSICPLAYER_PLAYLISTLEN:
{
if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
return GetPlaylistLabel(PLAYLIST_LENGTH);
}
break;
case MUSICPLAYER_PLAYLISTPOS:
{
if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_MUSIC)
return GetPlaylistLabel(PLAYLIST_POSITION);
}
break;
case MUSICPLAYER_BITRATE:
{
float fTimeSpan = (float)(CTimeUtils::GetFrameTime() - m_lastMusicBitrateTime);
if (fTimeSpan >= 500.0f)
{
m_MusicBitrate = g_application.m_pPlayer->GetAudioBitrate();
m_lastMusicBitrateTime = CTimeUtils::GetFrameTime();
}
CStdString strBitrate = "";
if (m_MusicBitrate > 0)
strBitrate.Format("%i", MathUtils::round_int((double)m_MusicBitrate / 1000.0));
return strBitrate;
}
break;
case MUSICPLAYER_CHANNELS:
{
CStdString strChannels = "";
if (g_application.m_pPlayer->GetChannels() > 0)
{
strChannels.Format("%i", g_application.m_pPlayer->GetChannels());
}
return strChannels;
}
break;
case MUSICPLAYER_BITSPERSAMPLE:
{
CStdString strBitsPerSample = "";
if (g_application.m_pPlayer->GetBitsPerSample() > 0)
{
strBitsPerSample.Format("%i", g_application.m_pPlayer->GetBitsPerSample());
}
return strBitsPerSample;
}
break;
case MUSICPLAYER_SAMPLERATE:
{
CStdString strSampleRate = "";
if (g_application.m_pPlayer->GetSampleRate() > 0)
{
strSampleRate.Format("%.5g", ((double)g_application.m_pPlayer->GetSampleRate() / 1000.0));
}
return strSampleRate;
}
break;
case MUSICPLAYER_CODEC:
{
CStdString strCodec;
strCodec.Format("%s", g_application.m_pPlayer->GetAudioCodecName().c_str());
return strCodec;
}
break;
case MUSICPLAYER_LYRICS:
return GetItemLabel(m_currentFile, AddListItemProp("lyrics"));
}
return GetMusicTagLabel(item, m_currentFile);
}
CStdString CGUIInfoManager::GetMusicTagLabel(int info, const CFileItem *item)
{
if (!item->HasMusicInfoTag()) return "";
const CMusicInfoTag &tag = *item->GetMusicInfoTag();
switch (info)
{
case MUSICPLAYER_TITLE:
if (tag.GetTitle().size()) { return tag.GetTitle(); }
break;
case MUSICPLAYER_ALBUM:
if (tag.GetAlbum().size()) { return tag.GetAlbum(); }
break;
case MUSICPLAYER_ARTIST:
if (tag.GetArtist().size()) { return StringUtils::Join(tag.GetArtist(), g_advancedSettings.m_musicItemSeparator); }
break;
case MUSICPLAYER_ALBUM_ARTIST:
if (tag.GetAlbumArtist().size()) { return StringUtils::Join(tag.GetAlbumArtist(), g_advancedSettings.m_musicItemSeparator); }
break;
case MUSICPLAYER_YEAR:
if (tag.GetYear()) { return tag.GetYearString(); }
break;
case MUSICPLAYER_GENRE:
if (tag.GetGenre().size()) { return StringUtils::Join(tag.GetGenre(), g_advancedSettings.m_musicItemSeparator); }
break;
case MUSICPLAYER_LYRICS:
if (tag.GetLyrics().size()) { return tag.GetLyrics(); }
break;
case MUSICPLAYER_TRACK_NUMBER:
{
CStdString strTrack;
if (tag.Loaded() && tag.GetTrackNumber() > 0)
{
strTrack.Format("%02i", tag.GetTrackNumber());
return strTrack;
}
}
break;
case MUSICPLAYER_DISC_NUMBER:
return GetItemLabel(item, LISTITEM_DISC_NUMBER);
case MUSICPLAYER_RATING:
return GetItemLabel(item, LISTITEM_RATING);
case MUSICPLAYER_COMMENT:
return GetItemLabel(item, LISTITEM_COMMENT);
case MUSICPLAYER_DURATION:
return GetItemLabel(item, LISTITEM_DURATION);
case MUSICPLAYER_PLAYCOUNT:
return GetItemLabel(item, LISTITEM_PLAYCOUNT);
case MUSICPLAYER_LASTPLAYED:
return GetItemLabel(item, LISTITEM_LASTPLAYED);
}
return "";
}
CStdString CGUIInfoManager::GetVideoLabel(int item)
{
if (!g_application.IsPlayingVideo())
return "";
if (item == VIDEOPLAYER_TITLE)
{
if (m_currentFile->HasVideoInfoTag() && !m_currentFile->GetVideoInfoTag()->m_strTitle.IsEmpty())
return m_currentFile->GetVideoInfoTag()->m_strTitle;
// don't have the title, so use dvdplayer, label, or drop down to title from path
if (!g_application.m_pPlayer->GetPlayingTitle().IsEmpty())
return g_application.m_pPlayer->GetPlayingTitle();
if (!m_currentFile->GetLabel().IsEmpty())
return m_currentFile->GetLabel();
return CUtil::GetTitleFromPath(m_currentFile->GetPath());
}
else if (item == VIDEOPLAYER_PLAYLISTLEN)
{
if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
return GetPlaylistLabel(PLAYLIST_LENGTH);
}
else if (item == VIDEOPLAYER_PLAYLISTPOS)
{
if (g_playlistPlayer.GetCurrentPlaylist() == PLAYLIST_VIDEO)
return GetPlaylistLabel(PLAYLIST_POSITION);
}
else if (m_currentFile->HasVideoInfoTag())
{
switch (item)
{
case VIDEOPLAYER_ORIGINALTITLE:
return m_currentFile->GetVideoInfoTag()->m_strOriginalTitle;
break;
case VIDEOPLAYER_GENRE:
return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_genre, g_advancedSettings.m_videoItemSeparator);
break;
case VIDEOPLAYER_DIRECTOR:
return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
break;
case VIDEOPLAYER_RATING:
{
CStdString strRating;
if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
strRating.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
return strRating;
}
break;
case VIDEOPLAYER_RATING_AND_VOTES:
{
CStdString strRatingAndVotes;
if (m_currentFile->GetVideoInfoTag()->m_fRating > 0.f)
{
if (m_currentFile->GetVideoInfoTag()->m_strVotes.IsEmpty())
strRatingAndVotes.Format("%.1f", m_currentFile->GetVideoInfoTag()->m_fRating);
else
strRatingAndVotes.Format("%.1f (%s %s)", m_currentFile->GetVideoInfoTag()->m_fRating, m_currentFile->GetVideoInfoTag()->m_strVotes, g_localizeStrings.Get(20350));
}
return strRatingAndVotes;
}
break;
case VIDEOPLAYER_YEAR:
{
CStdString strYear;
if (m_currentFile->GetVideoInfoTag()->m_iYear > 0)
strYear.Format("%i", m_currentFile->GetVideoInfoTag()->m_iYear);
return strYear;
}
break;
case VIDEOPLAYER_PREMIERED:
{
CDateTime dateTime;
if (m_currentFile->GetVideoInfoTag()->m_firstAired.IsValid())
dateTime = m_currentFile->GetVideoInfoTag()->m_firstAired;
else if (m_currentFile->GetVideoInfoTag()->m_premiered.IsValid())
dateTime = m_currentFile->GetVideoInfoTag()->m_premiered;
if (dateTime.IsValid())
return dateTime.GetAsLocalizedDate();
break;
}
break;
case VIDEOPLAYER_PLOT:
return m_currentFile->GetVideoInfoTag()->m_strPlot;
case VIDEOPLAYER_TRAILER:
return m_currentFile->GetVideoInfoTag()->m_strTrailer;
case VIDEOPLAYER_PLOT_OUTLINE:
return m_currentFile->GetVideoInfoTag()->m_strPlotOutline;
case VIDEOPLAYER_EPISODE:
{
CStdString strEpisode;
if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortEpisode > 0)
strEpisode.Format("S%i", m_currentFile->GetVideoInfoTag()->m_iSpecialSortEpisode);
else if(m_currentFile->GetVideoInfoTag()->m_iEpisode > 0)
strEpisode.Format("%i", m_currentFile->GetVideoInfoTag()->m_iEpisode);
return strEpisode;
}
break;
case VIDEOPLAYER_SEASON:
{
CStdString strSeason;
if (m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason > 0)
strSeason.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSpecialSortSeason);
else if(m_currentFile->GetVideoInfoTag()->m_iSeason > 0)
strSeason.Format("%i", m_currentFile->GetVideoInfoTag()->m_iSeason);
return strSeason;
}
break;
case VIDEOPLAYER_TVSHOW:
return m_currentFile->GetVideoInfoTag()->m_strShowTitle;
case VIDEOPLAYER_STUDIO:
return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_studio, g_advancedSettings.m_videoItemSeparator);
case VIDEOPLAYER_COUNTRY:
return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_country, g_advancedSettings.m_videoItemSeparator);
case VIDEOPLAYER_MPAA:
return m_currentFile->GetVideoInfoTag()->m_strMPAARating;
case VIDEOPLAYER_TOP250:
{
CStdString strTop250;
if (m_currentFile->GetVideoInfoTag()->m_iTop250 > 0)
strTop250.Format("%i", m_currentFile->GetVideoInfoTag()->m_iTop250);
return strTop250;
}
break;
case VIDEOPLAYER_CAST:
return m_currentFile->GetVideoInfoTag()->GetCast();
case VIDEOPLAYER_CAST_AND_ROLE:
return m_currentFile->GetVideoInfoTag()->GetCast(true);
case VIDEOPLAYER_ARTIST:
return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator);
case VIDEOPLAYER_ALBUM:
return m_currentFile->GetVideoInfoTag()->m_strAlbum;
case VIDEOPLAYER_WRITER:
return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_writingCredits, g_advancedSettings.m_videoItemSeparator);
case VIDEOPLAYER_TAGLINE:
return m_currentFile->GetVideoInfoTag()->m_strTagLine;
case VIDEOPLAYER_LASTPLAYED:
{
if (m_currentFile->GetVideoInfoTag()->m_lastPlayed.IsValid())
return m_currentFile->GetVideoInfoTag()->m_lastPlayed.GetAsLocalizedDateTime();
break;
}
case VIDEOPLAYER_PLAYCOUNT:
{
CStdString strPlayCount;
if (m_currentFile->GetVideoInfoTag()->m_playCount > 0)
strPlayCount.Format("%i", m_currentFile->GetVideoInfoTag()->m_playCount);
return strPlayCount;
}
}
}
return "";
}
int64_t CGUIInfoManager::GetPlayTime() const
{
if (g_application.IsPlaying())
{
int64_t lPTS = (int6