1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#include "GUIWindowSystemInfo.h"
#include "GUIInfoManager.h"
#include "ServiceBroker.h"
#include "guilib/GUIComponent.h"
#include "guilib/GUIMessage.h"
#include "guilib/LocalizeStrings.h"
#include "guilib/WindowIDs.h"
#include "guilib/guiinfo/GUIInfoLabels.h"
#include "pvr/PVRManager.h"
#include "storage/MediaManager.h"
#include "utils/CPUInfo.h"
#include "utils/StringUtils.h"
#include "utils/SystemInfo.h"
#define CONTROL_TB_POLICY 30
#define CONTROL_BT_STORAGE 94
#define CONTROL_BT_DEFAULT 95
#define CONTROL_BT_NETWORK 96
#define CONTROL_BT_VIDEO 97
#define CONTROL_BT_HARDWARE 98
#define CONTROL_BT_PVR 99
#define CONTROL_BT_POLICY 100
#define CONTROL_START CONTROL_BT_STORAGE
#define CONTROL_END CONTROL_BT_POLICY
CGUIWindowSystemInfo::CGUIWindowSystemInfo(void) :
CGUIWindow(WINDOW_SYSTEM_INFORMATION, "SettingsSystemInfo.xml")
{
m_section = CONTROL_BT_DEFAULT;
m_loadType = KEEP_IN_MEMORY;
}
CGUIWindowSystemInfo::~CGUIWindowSystemInfo(void) = default;
bool CGUIWindowSystemInfo::OnMessage(CGUIMessage& message)
{
switch (message.GetMessage())
{
case GUI_MSG_WINDOW_INIT:
{
CGUIWindow::OnMessage(message);
SET_CONTROL_LABEL(52, CSysInfo::GetAppName() + " " + CSysInfo::GetVersion());
SET_CONTROL_LABEL(53, CSysInfo::GetBuildDate());
CONTROL_ENABLE_ON_CONDITION(CONTROL_BT_PVR, CServiceBroker::GetPVRManager().IsStarted());
return true;
}
break;
case GUI_MSG_WINDOW_DEINIT:
{
CGUIWindow::OnMessage(message);
m_diskUsage.clear();
return true;
}
break;
case GUI_MSG_FOCUSED:
{
CGUIWindow::OnMessage(message);
int focusedControl = GetFocusedControlID();
if (m_section != focusedControl && focusedControl >= CONTROL_START && focusedControl <= CONTROL_END)
{
ResetLabels();
m_section = focusedControl;
}
if (m_section >= CONTROL_BT_STORAGE && m_section <= CONTROL_BT_PVR)
SET_CONTROL_HIDDEN(CONTROL_TB_POLICY);
else if (m_section == CONTROL_BT_POLICY)
{
SET_CONTROL_LABEL(CONTROL_TB_POLICY, CServiceBroker::GetGUI()->GetInfoManager().GetLabel(
SYSTEM_PRIVACY_POLICY, INFO::DEFAULT_CONTEXT));
SET_CONTROL_VISIBLE(CONTROL_TB_POLICY);
}
return true;
}
break;
}
return CGUIWindow::OnMessage(message);
}
void CGUIWindowSystemInfo::FrameMove()
{
int i = 2;
if (m_section == CONTROL_BT_DEFAULT)
{
SET_CONTROL_LABEL(40, g_localizeStrings.Get(20154));
SetControlLabel(i++, "{}: {}", 158, SYSTEM_FREE_MEMORY);
SetControlLabel(i++, "{}: {}", 150, NETWORK_IP_ADDRESS);
SetControlLabel(i++, "{} {}", 13287, SYSTEM_SCREEN_RESOLUTION);
SetControlLabel(i++, "{} {}", 13283, SYSTEM_OS_VERSION_INFO);
SetControlLabel(i++, "{}: {}", 12390, SYSTEM_UPTIME);
SetControlLabel(i++, "{}: {}", 12394, SYSTEM_TOTALUPTIME);
SetControlLabel(i++, "{}: {}", 12395, SYSTEM_BATTERY_LEVEL);
}
else if (m_section == CONTROL_BT_STORAGE)
{
SET_CONTROL_LABEL(40, g_localizeStrings.Get(20155));
if (m_diskUsage.empty())
m_diskUsage = CServiceBroker::GetMediaManager().GetDiskUsage();
for (size_t d = 0; d < m_diskUsage.size(); d++)
{
SET_CONTROL_LABEL(i++, m_diskUsage[d]);
}
}
else if (m_section == CONTROL_BT_NETWORK)
{
SET_CONTROL_LABEL(40,g_localizeStrings.Get(20158));
SET_CONTROL_LABEL(i++, CServiceBroker::GetGUI()->GetInfoManager().GetLabel(
NETWORK_LINK_STATE, INFO::DEFAULT_CONTEXT));
SetControlLabel(i++, "{}: {}", 149, NETWORK_MAC_ADDRESS);
SetControlLabel(i++, "{}: {}", 150, NETWORK_IP_ADDRESS);
SetControlLabel(i++, "{}: {}", 13159, NETWORK_SUBNET_MASK);
SetControlLabel(i++, "{}: {}", 13160, NETWORK_GATEWAY_ADDRESS);
SetControlLabel(i++, "{}: {}", 13161, NETWORK_DNS1_ADDRESS);
SetControlLabel(i++, "{}: {}", 20307, NETWORK_DNS2_ADDRESS);
SetControlLabel(i++, "{} {}", 13295, SYSTEM_INTERNET_STATE);
}
else if (m_section == CONTROL_BT_VIDEO)
{
SET_CONTROL_LABEL(40,g_localizeStrings.Get(20159));
SET_CONTROL_LABEL(i++, CServiceBroker::GetGUI()->GetInfoManager().GetLabel(
SYSTEM_VIDEO_ENCODER_INFO, INFO::DEFAULT_CONTEXT));
SetControlLabel(i++, "{} {}", 13287, SYSTEM_SCREEN_RESOLUTION);
auto renderingSystem = CServiceBroker::GetRenderSystem();
if (renderingSystem)
{
static std::string vendor = renderingSystem->GetRenderVendor();
if (!vendor.empty())
SET_CONTROL_LABEL(i++, StringUtils::Format("{} {}", g_localizeStrings.Get(22007), vendor));
#if defined(HAS_DX)
int renderVersionLabel = 22024;
#else
int renderVersionLabel = 22009;
#endif
static std::string version = renderingSystem->GetRenderVersionString();
if (!version.empty())
SET_CONTROL_LABEL(
i++, StringUtils::Format("{} {}", g_localizeStrings.Get(renderVersionLabel), version));
}
auto windowSystem = CServiceBroker::GetWinSystem();
if (windowSystem)
{
static std::string platform = windowSystem->GetName();
if (platform != "platform default")
SET_CONTROL_LABEL(i++,
StringUtils::Format("{} {}", g_localizeStrings.Get(39153), platform));
}
SetControlLabel(i++, "{} {}", 22010, SYSTEM_GPU_TEMPERATURE);
const std::string hdrTypes = CServiceBroker::GetGUI()->GetInfoManager().GetLabel(
SYSTEM_SUPPORTED_HDR_TYPES, INFO::DEFAULT_CONTEXT);
SET_CONTROL_LABEL(
i++, StringUtils::Format("{}: {}", g_localizeStrings.Get(39174),
hdrTypes.empty() ? g_localizeStrings.Get(231) : hdrTypes));
}
else if (m_section == CONTROL_BT_HARDWARE)
{
SET_CONTROL_LABEL(40,g_localizeStrings.Get(20160));
auto cpuInfo = CServiceBroker::GetCPUInfo();
if (cpuInfo)
{
static std::string model = cpuInfo->GetCPUModel();
if (!model.empty())
SET_CONTROL_LABEL(i++, "CPU: " + model);
static std::string mips = cpuInfo->GetCPUBogoMips();
if (!mips.empty())
SET_CONTROL_LABEL(i++, "BogoMips: " + mips);
static std::string soc = cpuInfo->GetCPUSoC();
if (!soc.empty())
SET_CONTROL_LABEL(i++, "SoC: " + soc);
static std::string hardware = cpuInfo->GetCPUHardware();
if (!hardware.empty())
SET_CONTROL_LABEL(i++, "Hardware: " + hardware);
static std::string revision = cpuInfo->GetCPURevision();
if (!revision.empty())
SET_CONTROL_LABEL(i++, "Revision: " + revision);
static std::string serial = cpuInfo->GetCPUSerial();
if (!serial.empty())
SET_CONTROL_LABEL(i++, "Serial: " + serial);
// temperature can't really be conditional because of localization units
SetControlLabel(i++, "{} {}", 22011, SYSTEM_CPU_TEMPERATURE);
// we can check if the cpufrequency is not 0 (default if not implemented)
// but we have to call through CGUIInfoManager -> CSystemGUIInfo -> CSysInfo
// to limit the frequency of updates
static float cpuFreq = cpuInfo->GetCPUFrequency();
if (cpuFreq > 0)
SetControlLabel(i++, "{} {}", 13284, SYSTEM_CPUFREQUENCY);
}
}
else if (m_section == CONTROL_BT_PVR)
{
SET_CONTROL_LABEL(40, g_localizeStrings.Get(19166));
int i = 2;
SetControlLabel(i++, "{}: {}", 19120, PVR_BACKEND_NUMBER);
i++; // empty line
SetControlLabel(i++, "{}: {}", 19012, PVR_BACKEND_NAME);
SetControlLabel(i++, "{}: {}", 19114, PVR_BACKEND_VERSION);
SetControlLabel(i++, "{}: {}", 19115, PVR_BACKEND_HOST);
SetControlLabel(i++, "{}: {}", 19116, PVR_BACKEND_DISKSPACE);
SetControlLabel(i++, "{}: {}", 19334, PVR_BACKEND_PROVIDERS);
SetControlLabel(i++, "{}: {}", 19042, PVR_BACKEND_CHANNEL_GROUPS);
SetControlLabel(i++, "{}: {}", 19019, PVR_BACKEND_CHANNELS);
SetControlLabel(i++, "{}: {}", 19163, PVR_BACKEND_RECORDINGS);
SetControlLabel(i++, "{}: {}", 19168,
PVR_BACKEND_DELETED_RECORDINGS); // Deleted and recoverable recordings
SetControlLabel(i++, "{}: {}", 19025, PVR_BACKEND_TIMERS);
}
else if (m_section == CONTROL_BT_POLICY)
{
SET_CONTROL_LABEL(40, g_localizeStrings.Get(12389));
}
CGUIWindow::FrameMove();
}
void CGUIWindowSystemInfo::ResetLabels()
{
for (int i = 2; i < 13; i++)
{
SET_CONTROL_LABEL(i, "");
}
SET_CONTROL_LABEL(CONTROL_TB_POLICY, "");
}
void CGUIWindowSystemInfo::SetControlLabel(int id, const char *format, int label, int info)
{
std::string tmpStr = StringUtils::Format(
format, g_localizeStrings.Get(label),
CServiceBroker::GetGUI()->GetInfoManager().GetLabel(info, INFO::DEFAULT_CONTEXT));
SET_CONTROL_LABEL(id, tmpStr);
}
|