bool CMusicGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const { switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // MUSICPLAYER_* /////////////////////////////////////////////////////////////////////////////////////////////// case MUSICPLAYER_CONTENT: value = StringUtils::EqualsNoCase(info.GetData3(), "files"); return value; // if no match for this provider, other providers shall be asked. case MUSICPLAYER_HASPREVIOUS: // requires current playlist be PLAYLIST_MUSIC if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_MUSIC) { value = (CServiceBroker::GetPlaylistPlayer().GetCurrentSong() > 0); // not first song return true; } break; case MUSICPLAYER_HASNEXT: // requires current playlist be PLAYLIST_MUSIC if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_MUSIC) { value = (CServiceBroker::GetPlaylistPlayer().GetCurrentSong() < (CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST_MUSIC).size() - 1)); // not last song return true; } break; case MUSICPLAYER_PLAYLISTPLAYING: if (g_application.GetAppPlayer().IsPlayingAudio() && CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_MUSIC) { value = true; return true; } break; case MUSICPLAYER_EXISTS: { int index = info.GetData2(); if (info.GetData1() == 1) { // relative index if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() != PLAYLIST_MUSIC) { value = false; return true; } index += CServiceBroker::GetPlaylistPlayer().GetCurrentSong(); } value = (index >= 0 && index < CServiceBroker::GetPlaylistPlayer().GetPlaylist(PLAYLIST_MUSIC).size()); return true; } /////////////////////////////////////////////////////////////////////////////////////////////// // MUSICPM_* /////////////////////////////////////////////////////////////////////////////////////////////// case MUSICPM_ENABLED: value = g_partyModeManager.IsEnabled(); return true; } return false; }
bool CAddonsGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const { switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // SYSTEM_* /////////////////////////////////////////////////////////////////////////////////////////////// case SYSTEM_HAS_ADDON: { ADDON::AddonPtr addon; value = CServiceBroker::GetAddonMgr().GetAddon(info.GetData3(), addon) && addon; return true; } } return false; }
bool CPlayerGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const { switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // PLAYER_* /////////////////////////////////////////////////////////////////////////////////////////////// case PLAYER_SEEKOFFSET: { std::string seekOffset = StringUtils::SecondsToTimeString(std::abs(m_seekOffset / 1000), static_cast<TIME_FORMAT>(info.GetData1())); if (m_seekOffset < 0) value = "-" + seekOffset; else if (m_seekOffset > 0) value = "+" + seekOffset; return true; } case PLAYER_VOLUME: value = StringUtils::Format("%2.1f dB", CAEUtil::PercentToGain(g_application.GetVolume(false))); return true; case PLAYER_SUBTITLE_DELAY: value = StringUtils::Format("%2.3f s", g_application.GetAppPlayer().GetVideoSettings().m_SubtitleDelay); return true; case PLAYER_AUDIO_DELAY: value = StringUtils::Format("%2.3f s", g_application.GetAppPlayer().GetVideoSettings().m_AudioDelay); return true; case PLAYER_CHAPTER: value = StringUtils::Format("%02d", g_application.GetAppPlayer().GetChapter()); return true; case PLAYER_CHAPTERCOUNT: value = StringUtils::Format("%02d", g_application.GetAppPlayer().GetChapterCount()); return true; case PLAYER_CHAPTERNAME: g_application.GetAppPlayer().GetChapterName(value); return true; case PLAYER_PATH: case PLAYER_FILENAME: case PLAYER_FILEPATH: value = item->GetPath(); if (info.m_info == PLAYER_PATH) { // do this twice since we want the path outside the archive if this // is to be of use. if (URIUtils::IsInArchive(value)) value = URIUtils::GetParentPath(value); value = URIUtils::GetParentPath(value); } else if (info.m_info == PLAYER_FILENAME) value = URIUtils::GetFileName(value); return true; case PLAYER_TITLE: // use label or drop down to title from path value = item->GetLabel(); if (value.empty()) value = CUtil::GetTitleFromPath(item->GetPath()); return true; case PLAYER_PLAYSPEED: { float speed = g_application.GetAppPlayer().GetPlaySpeed(); if (speed == 1.0) speed = g_application.GetAppPlayer().GetPlayTempo(); value = StringUtils::Format("%.2f", speed); return true; } case PLAYER_TIME: value = GetCurrentPlayTime(static_cast<TIME_FORMAT>(info.GetData1())); return true; case PLAYER_START_TIME: { const CDateTime time(g_application.GetAppPlayer().GetStartTime()); value = time.GetAsLocalizedTime(static_cast<TIME_FORMAT>(info.GetData1())); return true; } case PLAYER_DURATION: value = GetDuration(static_cast<TIME_FORMAT>(info.GetData1())); return true; case PLAYER_TIME_REMAINING: value = GetCurrentPlayTimeRemaining(static_cast<TIME_FORMAT>(info.GetData1())); return true; case PLAYER_FINISH_TIME: { CDateTime time(CDateTime::GetCurrentDateTime()); int playTimeRemaining = GetPlayTimeRemaining(); float speed = g_application.GetAppPlayer().GetPlaySpeed(); float tempo = g_application.GetAppPlayer().GetPlayTempo(); if (speed == 1.0) playTimeRemaining /= tempo; time += CDateTimeSpan(0, 0, 0, playTimeRemaining); value = time.GetAsLocalizedTime(static_cast<TIME_FORMAT>(info.GetData1())); return true; } case PLAYER_TIME_SPEED: { float speed = g_application.GetAppPlayer().GetPlaySpeed(); if (speed != 1.0) value = StringUtils::Format("%s (%ix)", GetCurrentPlayTime(static_cast<TIME_FORMAT>(info.GetData1())).c_str(), static_cast<int>(speed)); else value = GetCurrentPlayTime(TIME_FORMAT_GUESS); return true; } case PLAYER_SEEKTIME: value = GetCurrentSeekTime(static_cast<TIME_FORMAT>(info.GetData1())); return true; case PLAYER_SEEKSTEPSIZE: { int seekSize = g_application.GetAppPlayer().GetSeekHandler().GetSeekSize(); std::string strSeekSize = StringUtils::SecondsToTimeString(abs(seekSize), static_cast<TIME_FORMAT>(info.GetData1())); if (seekSize < 0) value = "-" + strSeekSize; if (seekSize > 0) value = "+" + strSeekSize; return true; } case PLAYER_SEEKNUMERIC: value = GetSeekTime(static_cast<TIME_FORMAT>(info.GetData1())); return !value.empty(); case PLAYER_CACHELEVEL: { int iLevel = g_application.GetAppPlayer().GetCacheLevel(); if (iLevel >= 0) { value = StringUtils::Format("%i", iLevel); return true; } break; } case PLAYER_ITEM_ART: value = item->GetArt(info.GetData3()); return true; /////////////////////////////////////////////////////////////////////////////////////////////// // PLAYER_PROCESS_* /////////////////////////////////////////////////////////////////////////////////////////////// case PLAYER_PROCESS_VIDEODECODER: value = CServiceBroker::GetDataCacheCore().GetVideoDecoderName(); return true; case PLAYER_PROCESS_DEINTMETHOD: value = CServiceBroker::GetDataCacheCore().GetVideoDeintMethod(); return true; case PLAYER_PROCESS_PIXELFORMAT: value = CServiceBroker::GetDataCacheCore().GetVideoPixelFormat(); return true; case PLAYER_PROCESS_VIDEOFPS: value = StringUtils::Format("%.3f", CServiceBroker::GetDataCacheCore().GetVideoFps()); return true; case PLAYER_PROCESS_VIDEODAR: value = StringUtils::Format("%.2f", CServiceBroker::GetDataCacheCore().GetVideoDAR()); return true; case PLAYER_PROCESS_VIDEOWIDTH: value = StringUtils::FormatNumber(CServiceBroker::GetDataCacheCore().GetVideoWidth()); return true; case PLAYER_PROCESS_VIDEOHEIGHT: value = StringUtils::FormatNumber(CServiceBroker::GetDataCacheCore().GetVideoHeight()); return true; case PLAYER_PROCESS_AUDIODECODER: value = CServiceBroker::GetDataCacheCore().GetAudioDecoderName(); return true; case PLAYER_PROCESS_AUDIOCHANNELS: value = CServiceBroker::GetDataCacheCore().GetAudioChannels(); return true; case PLAYER_PROCESS_AUDIOSAMPLERATE: value = StringUtils::FormatNumber(CServiceBroker::GetDataCacheCore().GetAudioSampleRate()); return true; case PLAYER_PROCESS_AUDIOBITSPERSAMPLE: value = StringUtils::FormatNumber(CServiceBroker::GetDataCacheCore().GetAudioBitsPerSample()); return true; /////////////////////////////////////////////////////////////////////////////////////////////// // PLAYLIST_* /////////////////////////////////////////////////////////////////////////////////////////////// case PLAYLIST_LENGTH: case PLAYLIST_POSITION: case PLAYLIST_RANDOM: case PLAYLIST_REPEAT: value = GUIINFO::GetPlaylistLabel(info.m_info, info.GetData1()); return true; } return false; }
bool CSystemGUIInfo::GetBool(bool& value, const CGUIListItem *gitem, int contextWindow, const CGUIInfo &info) const { switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // SYSTEM_* /////////////////////////////////////////////////////////////////////////////////////////////// case SYSTEM_ALWAYS_TRUE: value = true; return true; case SYSTEM_ALWAYS_FALSE: value = false; return true; case SYSTEM_ETHERNET_LINK_ACTIVE: // wtf: not implementated - always returns true?! value = true; return true; case SYSTEM_PLATFORM_LINUX: #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) value = true; #else value = false; #endif return true; case SYSTEM_PLATFORM_WINDOWS: #ifdef TARGET_WINDOWS value = true; #else value = false; #endif return true; case SYSTEM_PLATFORM_UWP: #ifdef TARGET_WINDOWS_STORE value = true; #else value = false; #endif return true; case SYSTEM_PLATFORM_DARWIN: #ifdef TARGET_DARWIN value = true; #else value = false; #endif return true; case SYSTEM_PLATFORM_DARWIN_OSX: #ifdef TARGET_DARWIN_OSX value = true; #else value = false; #endif return true; case SYSTEM_PLATFORM_DARWIN_IOS: #ifdef TARGET_DARWIN_IOS value = true; #else value = false; #endif return true; case SYSTEM_PLATFORM_ANDROID: #if defined(TARGET_ANDROID) value = true; #else value = false; #endif return true; case SYSTEM_PLATFORM_LINUX_RASPBERRY_PI: #if defined(TARGET_RASPBERRY_PI) value = true; #else value = false; #endif return true; case SYSTEM_MEDIA_DVD: value = g_mediaManager.IsDiscInDrive(); return true; case SYSTEM_MEDIA_AUDIO_CD: #ifdef HAS_DVD_DRIVE if (g_mediaManager.IsDiscInDrive()) { MEDIA_DETECT::CCdInfo *pCdInfo = g_mediaManager.GetCdInfo(); value = pCdInfo && (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1)); } else #endif { value = false; } return true; #ifdef HAS_DVD_DRIVE case SYSTEM_DVDREADY: value = g_mediaManager.GetDriveStatus() != DRIVE_NOT_READY; return true; case SYSTEM_TRAYOPEN: value = g_mediaManager.GetDriveStatus() == DRIVE_OPEN; return true; #endif case SYSTEM_CAN_POWERDOWN: value = CServiceBroker::GetPowerManager().CanPowerdown(); return true; case SYSTEM_CAN_SUSPEND: value = CServiceBroker::GetPowerManager().CanSuspend(); return true; case SYSTEM_CAN_HIBERNATE: value = CServiceBroker::GetPowerManager().CanHibernate(); return true; case SYSTEM_CAN_REBOOT: value = CServiceBroker::GetPowerManager().CanReboot(); return true; case SYSTEM_SCREENSAVER_ACTIVE: value = g_application.IsInScreenSaver(); return true; case SYSTEM_DPMS_ACTIVE: value = g_application.IsDPMSActive(); return true; case SYSTEM_HASLOCKS: value = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE; return true; case SYSTEM_HAS_PVR: value = true; return true; case SYSTEM_HAS_PVR_ADDON: { ADDON::VECADDONS pvrAddons; ADDON::CBinaryAddonCache &addonCache = CServiceBroker::GetBinaryAddonCache(); addonCache.GetAddons(pvrAddons, ADDON::ADDON_PVRDLL); value = (pvrAddons.size() > 0); return true; } case SYSTEM_HAS_CMS: #if defined(HAS_GL) || defined(HAS_DX) value = true; #else value = false; #endif return true; case SYSTEM_ISMASTER: value = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetMasterProfile().getLockMode() != LOCK_MODE_EVERYONE && g_passwordManager.bMasterUser; return true; case SYSTEM_ISFULLSCREEN: value = CServiceBroker::GetWinSystem()->IsFullScreen(); return true; case SYSTEM_ISSTANDALONE: value = g_application.IsStandAlone(); return true; case SYSTEM_ISINHIBIT: value = g_application.IsIdleShutdownInhibited(); return true; case SYSTEM_HAS_SHUTDOWN: value = (CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNTIME) > 0); return true; case SYSTEM_LOGGEDON: value = !(CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WINDOW_LOGIN_SCREEN); return true; case SYSTEM_SHOW_EXIT_BUTTON: value = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_showExitButton; return true; case SYSTEM_HAS_LOGINSCREEN: value = CServiceBroker::GetSettingsComponent()->GetProfileManager()->UsingLoginScreen(); return true; case SYSTEM_INTERNET_STATE: { g_sysinfo.GetInfo(info.m_info); value = g_sysinfo.HasInternet(); return true; } case SYSTEM_IDLE_TIME: value = g_application.GlobalIdleTime() >= static_cast<int>(info.GetData1()); return true; case SYSTEM_HAS_CORE_ID: value = g_cpuInfo.HasCoreId(info.GetData1()); return true; case SYSTEM_DATE: { if (info.GetData2() == -1) // info doesn't contain valid startDate return false; const CDateTime date = CDateTime::GetCurrentDateTime(); int currentDate = date.GetMonth() * 100 + date.GetDay(); int startDate = info.GetData1(); int stopDate = info.GetData2(); if (stopDate < startDate) value = currentDate >= startDate || currentDate < stopDate; else value = currentDate >= startDate && currentDate < stopDate; return true; } case SYSTEM_TIME: { int currentTime = CDateTime::GetCurrentDateTime().GetMinuteOfDay(); int startTime = info.GetData1(); int stopTime = info.GetData2(); if (stopTime < startTime) value = currentTime >= startTime || currentTime < stopTime; else value = currentTime >= startTime && currentTime < stopTime; return true; } case SYSTEM_ALARM_LESS_OR_EQUAL: { int time = std::lrint(g_alarmClock.GetRemaining(info.GetData3())); int timeCompare = info.GetData2(); if (time > 0) value = timeCompare >= time; else value = false; return true; } case SYSTEM_HAS_ALARM: value = g_alarmClock.HasAlarm(info.GetData3()); return true; case SYSTEM_GET_BOOL: value = CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(info.GetData3()); return true; case SYSTEM_SETTING: { if (StringUtils::EqualsNoCase(info.GetData3(), "hidewatched")) { CGUIMediaWindow* window = GUIINFO::GetMediaWindow(contextWindow); if (window) { value = CMediaSettings::GetInstance().GetWatchedMode(window->CurrentDirectory().GetContent()) == WatchedModeUnwatched; return true; } } break; } } return false; }
bool CSystemGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const { switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // SYSTEM_* /////////////////////////////////////////////////////////////////////////////////////////////// case SYSTEM_TIME: value = CDateTime::GetCurrentDateTime().GetAsLocalizedTime(static_cast<TIME_FORMAT>(info.GetData1())); return true; case SYSTEM_DATE: if (info.GetData3().empty()) value = CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true); else value = CDateTime::GetCurrentDateTime().GetAsLocalizedDate(info.GetData3()); return true; case SYSTEM_FREE_SPACE: case SYSTEM_USED_SPACE: case SYSTEM_TOTAL_SPACE: case SYSTEM_FREE_SPACE_PERCENT: case SYSTEM_USED_SPACE_PERCENT: value = g_sysinfo.GetHddSpaceInfo(info.m_info); return true; case SYSTEM_CPU_TEMPERATURE: case SYSTEM_GPU_TEMPERATURE: case SYSTEM_FAN_SPEED: case SYSTEM_CPU_USAGE: value = GetSystemHeatInfo(info.m_info); return true; case SYSTEM_VIDEO_ENCODER_INFO: case NETWORK_MAC_ADDRESS: case SYSTEM_OS_VERSION_INFO: case SYSTEM_CPUFREQUENCY: case SYSTEM_INTERNET_STATE: case SYSTEM_UPTIME: case SYSTEM_TOTALUPTIME: case SYSTEM_BATTERY_LEVEL: value = g_sysinfo.GetInfo(info.m_info); return true; case SYSTEM_PRIVACY_POLICY: value = g_sysinfo.GetPrivacyPolicy(); return true; case SYSTEM_SCREEN_RESOLUTION: { RESOLUTION_INFO& resInfo = CDisplaySettings::GetInstance().GetCurrentResolutionInfo(); if (CServiceBroker::GetWinSystem()->IsFullScreen()) value = StringUtils::Format("%ix%i@%.2fHz - %s", resInfo.iScreenWidth, resInfo.iScreenHeight, resInfo.fRefreshRate, g_localizeStrings.Get(244).c_str()); else value = StringUtils::Format("%ix%i - %s", resInfo.iScreenWidth, resInfo.iScreenHeight, g_localizeStrings.Get(242).c_str()); return true; } case SYSTEM_BUILD_VERSION_SHORT: value = CSysInfo::GetVersionShort(); return true; case SYSTEM_BUILD_VERSION: value = CSysInfo::GetVersion(); return true; case SYSTEM_BUILD_DATE: value = CSysInfo::GetBuildDate(); return true; 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 - static_cast<int>(100.0f * (stat.ullTotalPhys - stat.ullAvailPhys) / stat.ullTotalPhys + 0.5f); int iMemPercentUsed = 100 - iMemPercentFree; if (info.m_info == SYSTEM_FREE_MEMORY) value = StringUtils::Format("%uMB", static_cast<unsigned int>(stat.ullAvailPhys / MB)); else if (info.m_info == SYSTEM_FREE_MEMORY_PERCENT) value = StringUtils::Format("%i%%", iMemPercentFree); else if (info.m_info == SYSTEM_USED_MEMORY) value = StringUtils::Format("%uMB", static_cast<unsigned int>((stat.ullTotalPhys - stat.ullAvailPhys) / MB)); else if (info.m_info == SYSTEM_USED_MEMORY_PERCENT) value = StringUtils::Format("%i%%", iMemPercentUsed); else if (info.m_info == SYSTEM_TOTAL_MEMORY) value = StringUtils::Format("%uMB", static_cast<unsigned int>(stat.ullTotalPhys / MB)); return true; } case SYSTEM_SCREEN_MODE: value = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo().strMode; return true; case SYSTEM_SCREEN_WIDTH: value = StringUtils::Format("%i", CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo().iScreenWidth); return true; case SYSTEM_SCREEN_HEIGHT: value = StringUtils::Format("%i", CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo().iScreenHeight); return true; case SYSTEM_FPS: value = StringUtils::Format("%02.2f", m_fps); return true; #ifdef HAS_DVD_DRIVE case SYSTEM_DVD_LABEL: value = g_mediaManager.GetDiskLabel(); return true; #endif case SYSTEM_ALARM_POS: if (g_alarmClock.GetRemaining("shutdowntimer") == 0.f) value.clear(); else { double fTime = g_alarmClock.GetRemaining("shutdowntimer"); if (fTime > 60.f) value = StringUtils::Format(g_localizeStrings.Get(13213).c_str(), g_alarmClock.GetRemaining("shutdowntimer")/60.f); else value = StringUtils::Format(g_localizeStrings.Get(13214).c_str(), g_alarmClock.GetRemaining("shutdowntimer")); } return true; case SYSTEM_PROFILENAME: value = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetCurrentProfile().getName(); return true; case SYSTEM_PROFILECOUNT: value = StringUtils::Format("{0}", CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetNumberOfProfiles()); return true; case SYSTEM_PROFILEAUTOLOGIN: { const std::shared_ptr<CProfileManager> profileManager = CServiceBroker::GetSettingsComponent()->GetProfileManager(); int iProfileId = profileManager->GetAutoLoginProfileId(); if ((iProfileId < 0) || !profileManager->GetProfileName(iProfileId, value)) value = g_localizeStrings.Get(37014); // Last used profile return true; } case SYSTEM_PROFILETHUMB: { const std::string& thumb = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetCurrentProfile().getThumb(); value = thumb.empty() ? "DefaultUser.png" : thumb; return true; } case SYSTEM_LANGUAGE: value = g_langInfo.GetEnglishLanguageName(); return true; case SYSTEM_TEMPERATURE_UNITS: value = g_langInfo.GetTemperatureUnitString(); return true; case SYSTEM_FRIENDLY_NAME: value = CSysInfo::GetDeviceName(); return true; case SYSTEM_STEREOSCOPIC_MODE: { int iStereoMode = CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(CSettings::SETTING_VIDEOSCREEN_STEREOSCOPICMODE); value = StringUtils::Format("%i", iStereoMode); return true; } case SYSTEM_GET_CORE_USAGE: value = StringUtils::Format("%4.2f", g_cpuInfo.GetCoreInfo(std::atoi(info.GetData3().c_str())).m_fPct); return true; case SYSTEM_RENDER_VENDOR: value = CServiceBroker::GetRenderSystem()->GetRenderVendor(); return true; case SYSTEM_RENDER_RENDERER: value = CServiceBroker::GetRenderSystem()->GetRenderRenderer(); return true; case SYSTEM_RENDER_VERSION: value = CServiceBroker::GetRenderSystem()->GetRenderVersionString(); return true; /////////////////////////////////////////////////////////////////////////////////////////////// // NETWORK_* /////////////////////////////////////////////////////////////////////////////////////////////// case NETWORK_IP_ADDRESS: { CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface(); if (iface) { value = iface->GetCurrentIPAddress(); return true; } break; } case NETWORK_SUBNET_MASK: { CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface(); if (iface) { value = iface->GetCurrentNetmask(); return true; } break; } case NETWORK_GATEWAY_ADDRESS: { CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface(); if (iface) { value = iface->GetCurrentDefaultGateway(); return true; } break; } case NETWORK_DNS1_ADDRESS: { const std::vector<std::string> nss = CServiceBroker::GetNetwork().GetNameServers(); if (nss.size() >= 1) { value = nss[0]; return true; } break; } case NETWORK_DNS2_ADDRESS: { const std::vector<std::string> nss = CServiceBroker::GetNetwork().GetNameServers(); if (nss.size() >= 2) { value = nss[1]; return true; } break; } case NETWORK_DHCP_ADDRESS: { // wtf? std::string dhcpserver; value = dhcpserver; return true; } case NETWORK_LINK_STATE: { std::string linkStatus = g_localizeStrings.Get(151); linkStatus += " "; CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface(); if (iface && iface->IsConnected()) linkStatus += g_localizeStrings.Get(15207); else linkStatus += g_localizeStrings.Get(15208); value = linkStatus; return true; } } return false; }
bool CAddonsGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const { const std::shared_ptr<const ADDON::IAddon> addonInfo = item->GetAddonInfo(); if (addonInfo) { switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // LISTITEM_* /////////////////////////////////////////////////////////////////////////////////////////////// case LISTITEM_ADDON_NAME: value = addonInfo->Name(); return true; case LISTITEM_ADDON_VERSION: value = addonInfo->Version().asString(); return true; case LISTITEM_ADDON_CREATOR: value = addonInfo->Author(); return true; case LISTITEM_ADDON_SUMMARY: value = addonInfo->Summary(); return true; case LISTITEM_ADDON_DESCRIPTION: value = addonInfo->Description(); return true; case LISTITEM_ADDON_DISCLAIMER: value = addonInfo->Disclaimer(); return true; case LISTITEM_ADDON_NEWS: value = addonInfo->ChangeLog(); return true; case LISTITEM_ADDON_BROKEN: value = addonInfo->Broken(); return true; case LISTITEM_ADDON_TYPE: value = ADDON::CAddonInfo::TranslateType(addonInfo->Type(), true); return true; case LISTITEM_ADDON_INSTALL_DATE: value = addonInfo->InstallDate().GetAsLocalizedDateTime(); return true; case LISTITEM_ADDON_LAST_UPDATED: if (addonInfo->LastUpdated().IsValid()) { value = addonInfo->LastUpdated().GetAsLocalizedDateTime(); return true; } break; case LISTITEM_ADDON_LAST_USED: if (addonInfo->LastUsed().IsValid()) { value = addonInfo->LastUsed().GetAsLocalizedDateTime(); return true; } break; case LISTITEM_ADDON_ORIGIN: { if (item->GetAddonInfo()->Origin() == ADDON::ORIGIN_SYSTEM) { value = g_localizeStrings.Get(24992); return true; } ADDON::AddonPtr origin; if (CServiceBroker::GetAddonMgr().GetAddon(item->GetAddonInfo()->Origin(), origin, ADDON::ADDON_UNKNOWN, false)) { value = origin->Name(); return true; } value = g_localizeStrings.Get(13205); return true; } case LISTITEM_ADDON_SIZE: { uint64_t packageSize = item->GetAddonInfo()->PackageSize(); if (packageSize > 0) { value = StringUtils::FormatFileSize(packageSize); return true; } break; } } } switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // SYSTEM_* /////////////////////////////////////////////////////////////////////////////////////////////// case SYSTEM_ADDON_TITLE: case SYSTEM_ADDON_ICON: case SYSTEM_ADDON_VERSION: { // 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. ADDON::AddonPtr addon; if (!info.GetData3().empty()) { CServiceBroker::GetAddonMgr().GetAddon(info.GetData3(), addon, ADDON::ADDON_UNKNOWN, false); if (!addon) break; if (info.m_info == SYSTEM_ADDON_TITLE) { value = addon->Name(); return true; } if (info.m_info == SYSTEM_ADDON_ICON) { value = addon->Icon(); return true; } if (info.m_info == SYSTEM_ADDON_VERSION) { value = addon->Version().asString(); return true; } } break; } } return false; }
bool CPVRGUIInfo::GetListItemAndPlayerBool(const CFileItem *item, const CGUIInfo &info, bool &bValue) const { switch (info.m_info) { case LISTITEM_ISRECORDING: if (item->IsPVRChannel()) { bValue = item->GetPVRChannelInfoTag()->IsRecording(); return true; } else if (item->IsEPG() || item->IsPVRTimer()) { const CPVRTimerInfoTagPtr timer = CPVRItem(item).GetTimerInfoTag(); if (timer) bValue = timer->IsRecording(); return true; } else if (item->IsPVRRecording()) { bValue = item->GetPVRRecordingInfoTag()->IsInProgress(); return true; } break; case LISTITEM_INPROGRESS: if (item->IsPVRChannel() || item->IsEPG()) { const CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); if (epgTag) bValue = epgTag->IsActive(); return true; } break; case LISTITEM_HASTIMER: if (item->IsPVRChannel() || item->IsEPG()) { const CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); if (epgTag) bValue = epgTag->HasTimer(); return true; } break; case LISTITEM_HASTIMERSCHEDULE: if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer()) { const CPVRTimerInfoTagPtr timer = CPVRItem(item).GetTimerInfoTag(); if (timer) bValue = timer->GetTimerRuleId() != PVR_TIMER_NO_PARENT; return true; } break; case LISTITEM_TIMERISACTIVE: if (item->IsPVRChannel() || item->IsEPG()) { const CPVRTimerInfoTagPtr timer = CPVRItem(item).GetTimerInfoTag(); if (timer) bValue = timer->IsActive(); break; } break; case LISTITEM_TIMERHASCONFLICT: if (item->IsPVRChannel() || item->IsEPG()) { const CPVRTimerInfoTagPtr timer = CPVRItem(item).GetTimerInfoTag(); if (timer) bValue = timer->HasConflict(); return true; } break; case LISTITEM_TIMERHASERROR: if (item->IsPVRChannel() || item->IsEPG()) { const CPVRTimerInfoTagPtr timer = CPVRItem(item).GetTimerInfoTag(); if (timer) bValue = (timer->IsBroken() && !timer->HasConflict()); return true; } break; case LISTITEM_HASRECORDING: if (item->IsPVRChannel() || item->IsEPG()) { const CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); if (epgTag) bValue = epgTag->HasRecording(); return true; } break; case LISTITEM_HAS_EPG: if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer()) { const CPVREpgInfoTagPtr epgTag = CPVRItem(item).GetEpgInfoTag(); bValue = (epgTag != nullptr); return true; } break; case LISTITEM_ISENCRYPTED: if (item->IsPVRChannel() || item->IsEPG()) { const CPVRChannelPtr channel = CPVRItem(item).GetChannel(); if (channel) bValue = channel->IsEncrypted(); return true; } break; case MUSICPLAYER_CONTENT: case VIDEOPLAYER_CONTENT: if (item->IsPVRChannel()) { bValue = StringUtils::EqualsNoCase(info.GetData3(), "livetv"); return bValue; // if no match for this provider, other providers shall be asked. } break; case VIDEOPLAYER_HAS_INFO: if (item->IsPVRChannel()) { bValue = !item->GetPVRChannelInfoTag()->IsEmpty(); return true; } break; case VIDEOPLAYER_HAS_EPG: if (item->IsPVRChannel()) { bValue = (item->GetPVRChannelInfoTag()->GetEPGNow() != nullptr); return true; } break; case VIDEOPLAYER_CAN_RESUME_LIVE_TV: if (item->IsPVRRecording()) { const CPVRRecordingPtr recording = item->GetPVRRecordingInfoTag(); const CPVREpgInfoTagPtr epgTag = CServiceBroker::GetPVRManager().EpgContainer().GetTagById(recording->Channel(), recording->BroadcastUid()); bValue = (epgTag && epgTag->IsActive() && epgTag->Channel()); return true; } break; case PLAYER_IS_CHANNEL_PREVIEW_ACTIVE: if (item->IsPVRChannel()) { if (CServiceBroker::GetPVRManager().GUIActions()->GetChannelNavigator().IsPreviewAndShowInfo()) { bValue = true; } else { bValue = !m_videoInfo.valid; if (bValue && item->GetPVRChannelInfoTag()->IsRadio()) bValue = !m_audioInfo.valid; } return true; } break; } return false; }
bool CMusicGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const { if (info.GetData1() && info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST) return GetPlaylistInfo(value, info); const CMusicInfoTag* tag = item->GetMusicInfoTag(); if (tag) { switch (info.m_info) { ///////////////////////////////////////////////////////////////////////////////////////////// // PLAYER_* / MUSICPLAYER_* / LISTITEM_* ///////////////////////////////////////////////////////////////////////////////////////////// case PLAYER_PATH: case PLAYER_FILENAME: case PLAYER_FILEPATH: value = tag->GetURL(); if (value.empty()) value = item->GetPath(); value = GUIINFO::GetFileInfoLabelValueFromPath(info.m_info, value); return true; case PLAYER_TITLE: value = tag->GetTitle(); return !value.empty(); case MUSICPLAYER_TITLE: value = tag->GetTitle(); if (value.empty()) value = item->GetLabel(); if (value.empty()) value = CUtil::GetTitleFromPath(item->GetPath()); return true; case LISTITEM_TITLE: value = tag->GetTitle(); return true; case MUSICPLAYER_PLAYCOUNT: case LISTITEM_PLAYCOUNT: if (tag->GetPlayCount() > 0) { value = StringUtils::Format("%i", tag->GetPlayCount()); return true; } break; case MUSICPLAYER_LASTPLAYED: case LISTITEM_LASTPLAYED: { const CDateTime dateTime = tag->GetLastPlayed(); if (dateTime.IsValid()) { value = dateTime.GetAsLocalizedDate(); return true; } break; } case MUSICPLAYER_TRACK_NUMBER: case LISTITEM_TRACKNUMBER: if (tag->Loaded() && tag->GetTrackNumber() > 0) { value = StringUtils::Format("%02i", tag->GetTrackNumber()); return true; } break; case MUSICPLAYER_DISC_NUMBER: case LISTITEM_DISC_NUMBER: if (tag->GetDiscNumber() > 0) { value = StringUtils::Format("%i", tag->GetDiscNumber()); return true; } break; case MUSICPLAYER_ARTIST: case LISTITEM_ARTIST: value = tag->GetArtistString(); return true; case MUSICPLAYER_ALBUM_ARTIST: case LISTITEM_ALBUM_ARTIST: value = tag->GetAlbumArtistString(); return true; case MUSICPLAYER_CONTRIBUTORS: case LISTITEM_CONTRIBUTORS: if (tag->HasContributors()) { value = tag->GetContributorsText(); return true; } break; case MUSICPLAYER_CONTRIBUTOR_AND_ROLE: case LISTITEM_CONTRIBUTOR_AND_ROLE: if (tag->HasContributors()) { value = tag->GetContributorsAndRolesText(); return true; } break; case MUSICPLAYER_ALBUM: case LISTITEM_ALBUM: value = tag->GetAlbum(); return true; case MUSICPLAYER_YEAR: case LISTITEM_YEAR: value = tag->GetYearString(); return true; case MUSICPLAYER_GENRE: case LISTITEM_GENRE: value = StringUtils::Join(tag->GetGenre(), CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_musicItemSeparator); return true; case MUSICPLAYER_LYRICS: value = tag->GetLyrics(); return true; case MUSICPLAYER_RATING: case LISTITEM_RATING: { float rating = tag->GetRating(); if (rating > 0.f) { value = StringUtils::FormatNumber(rating); return true; } break; } case MUSICPLAYER_RATING_AND_VOTES: case LISTITEM_RATING_AND_VOTES: { float rating = tag->GetRating(); if (rating > 0.f) { int votes = tag->GetVotes(); if (votes <= 0) value = StringUtils::FormatNumber(rating); else value = StringUtils::Format(g_localizeStrings.Get(20350).c_str(), StringUtils::FormatNumber(rating).c_str(), StringUtils::FormatNumber(votes).c_str()); return true; } break; } case MUSICPLAYER_USER_RATING: case LISTITEM_USER_RATING: if (tag->GetUserrating() > 0) { value = StringUtils::Format("%i", tag->GetUserrating()); return true; } break; case MUSICPLAYER_COMMENT: case LISTITEM_COMMENT: value = tag->GetComment(); return true; case MUSICPLAYER_MOOD: case LISTITEM_MOOD: value = tag->GetMood(); return true; case LISTITEM_DBTYPE: value = tag->GetType(); return true; case MUSICPLAYER_DBID: case LISTITEM_DBID: { int dbId = tag->GetDatabaseId(); if (dbId > -1) { value = StringUtils::Format("%i", dbId); return true; } break; } case PLAYER_DURATION: if (!g_application.GetAppPlayer().IsPlayingAudio()) break; // fall-thru is intended. case MUSICPLAYER_DURATION: case LISTITEM_DURATION: { int iDuration = tag->GetDuration(); if (iDuration > 0) { value = StringUtils::SecondsToTimeString(iDuration, static_cast<TIME_FORMAT>(info.GetData4())); return true; } break; } ///////////////////////////////////////////////////////////////////////////////////////////// // LISTITEM_* ///////////////////////////////////////////////////////////////////////////////////////////// case LISTITEM_PROPERTY: if (StringUtils::StartsWithNoCase(info.GetData3(), "Role.")) { // "Role.xxxx" properties are held in music tag std::string property = info.GetData3(); property.erase(0, 5); //Remove Role. value = tag->GetArtistStringForRole(property); return true; } break; case LISTITEM_VOTES: value = StringUtils::FormatNumber(tag->GetVotes()); return true; case LISTITEM_FILENAME: case LISTITEM_FILE_EXTENSION: if (item->IsMusicDb()) value = URIUtils::GetFileName(tag->GetURL()); else if (item->HasVideoInfoTag()) // special handling for music videos, which have both a videotag and a musictag break; else value = URIUtils::GetFileName(item->GetPath()); if (info.m_info == LISTITEM_FILE_EXTENSION) { std::string strExtension = URIUtils::GetExtension(value); value = StringUtils::TrimLeft(strExtension, "."); } return true; case LISTITEM_FOLDERNAME: case LISTITEM_PATH: if (item->IsMusicDb()) value = URIUtils::GetDirectory(tag->GetURL()); else if (item->HasVideoInfoTag()) // special handling for music videos, which have both a videotag and a musictag break; else URIUtils::GetParentPath(item->GetPath(), value); value = CURL(value).GetWithoutUserDetails(); if (info.m_info == LISTITEM_FOLDERNAME) { URIUtils::RemoveSlashAtEnd(value); value = URIUtils::GetFileName(value); } return true; case LISTITEM_FILENAME_AND_PATH: if (item->IsMusicDb()) value = tag->GetURL(); else if (item->HasVideoInfoTag()) // special handling for music videos, which have both a videotag and a musictag break; else value = item->GetPath(); value = CURL(value).GetWithoutUserDetails(); return true; } } switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // MUSICPLAYER_* /////////////////////////////////////////////////////////////////////////////////////////////// case MUSICPLAYER_PROPERTY: value = item->GetProperty(info.GetData3()).asString(); return true; case MUSICPLAYER_PLAYLISTLEN: if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_MUSIC) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_LENGTH); return true; } break; case MUSICPLAYER_PLAYLISTPOS: if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_MUSIC) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_POSITION); return true; } break; case MUSICPLAYER_COVER: if (g_application.GetAppPlayer().IsPlayingAudio()) { if (fallback) *fallback = "DefaultAlbumCover.png"; value = item->HasArt("thumb") ? item->GetArt("thumb") : "DefaultAlbumCover.png"; return true; } break; case MUSICPLAYER_BITRATE: { int iBitrate = m_audioInfo.bitrate; if (iBitrate > 0) { value = StringUtils::Format("%li", std::lrint(static_cast<double>(iBitrate) / 1000.0)); return true; } break; } case MUSICPLAYER_CHANNELS: { int iChannels = m_audioInfo.channels; if (iChannels > 0) { value = StringUtils::Format("%i", iChannels); return true; } break; } case MUSICPLAYER_BITSPERSAMPLE: { int iBPS = m_audioInfo.bitspersample; if (iBPS > 0) { value = StringUtils::Format("%i", iBPS); return true; } break; } case MUSICPLAYER_SAMPLERATE: { int iSamplerate = m_audioInfo.samplerate; if (iSamplerate > 0) { value = StringUtils::Format("%.5g", static_cast<double>(iSamplerate) / 1000.0); return true; } break; } case MUSICPLAYER_CODEC: value = StringUtils::Format("%s", m_audioInfo.codecName.c_str()); return true; } /////////////////////////////////////////////////////////////////////////////////////////////// // MUSICPM_* /////////////////////////////////////////////////////////////////////////////////////////////// if (GetPartyModeLabel(value, info)) return true; return false; }