mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	* Allow build, if no grabbers are enabled * Align available functions to right Qt version * Update to next development version * Align available functions to right Qt version * fix workflows (apt/nightly) * Disable QNetworkConfigurationManager deprecation warnings * Initial go on Smart Pointers * Add Deallocation * Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9) * Cluster Build Variables * Hyperion Light * Address build warnings * Hyperion Light - UI * Update Protobuf to latest master * Removed compiler warnings * Added restart ability to systray * Correct Protobuf * Ignore 'no-return' warning on protobuf build * hyperion-remote: Fix auto discovery of hyperion server * Fix Qt version override * Update changelog * Remove Grabber Components, if no Grabber exists * Standalone Grabber - Fix fps default * Remote Control - Have Source Selction accrosswhole screen * Enable Blackborder detection only, if relevant input sources available * Enable Blackborder detection only, if relevant input sources available * Remote UI - rearrange containers * - QT5/6 path for arm64 added - Remove ZLib Dependency - Fix macOS bundle info details - Cleanup Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com> Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
		
			
				
	
	
		
			141 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			141 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Python includes
 | |
| #include <Python.h>
 | |
| 
 | |
| #include "utils/SysInfo.h"
 | |
| #include "utils/FileUtils.h"
 | |
| 
 | |
| #include <QHostInfo>
 | |
| #include <QSysInfo>
 | |
| #include <QRegularExpression>
 | |
| #include <QRegularExpressionMatch>
 | |
| 
 | |
| #include <iostream>
 | |
| 
 | |
| #ifdef _WIN32
 | |
| #include <shlobj_core.h>
 | |
| #endif
 | |
| 
 | |
| std::unique_ptr<SysInfo> SysInfo::_instance = nullptr;
 | |
| 
 | |
| SysInfo::SysInfo()
 | |
| 	: QObject()
 | |
| {
 | |
| 	_sysinfo.kernelType = QSysInfo::kernelType();
 | |
| 	_sysinfo.kernelVersion = QSysInfo::kernelVersion();
 | |
| 	_sysinfo.architecture = QSysInfo::currentCpuArchitecture();
 | |
| 	_sysinfo.wordSize = QString::number(QSysInfo::WordSize);
 | |
| 	_sysinfo.productType = QSysInfo::productType();
 | |
| 	_sysinfo.productVersion = QSysInfo::productVersion();
 | |
| 	_sysinfo.prettyName = QSysInfo::prettyProductName();
 | |
| 	_sysinfo.hostName = QHostInfo::localHostName();
 | |
| 	_sysinfo.domainName = QHostInfo::localDomainName();
 | |
| 	_sysinfo.isUserAdmin = isUserAdmin();
 | |
| 	getCPUInfo();
 | |
| 	_sysinfo.qtVersion = QT_VERSION_STR;
 | |
| 	_sysinfo.pyVersion = PY_VERSION;
 | |
| }
 | |
| 
 | |
| SysInfo::HyperionSysInfo SysInfo::get()
 | |
| {
 | |
| 	if (SysInfo::_instance == nullptr)
 | |
| 		SysInfo::_instance = std::unique_ptr<SysInfo>(new SysInfo());
 | |
| 
 | |
| 	return SysInfo::_instance->_sysinfo;
 | |
| }
 | |
| 
 | |
| void SysInfo::getCPUInfo()
 | |
| {
 | |
| 	QString cpuInfo;
 | |
| 	if (FileUtils::readFile("/proc/cpuinfo", cpuInfo, Logger::getInstance("DAEMON"), true))
 | |
| 	{
 | |
| 		QRegularExpression regEx("^model\\s*:\\s(.*)", QRegularExpression::CaseInsensitiveOption | QRegularExpression::MultilineOption);
 | |
| 		QRegularExpressionMatch match;
 | |
| 
 | |
| 		match = regEx.match(cpuInfo);
 | |
| 		if (match.hasMatch())
 | |
| 		{
 | |
| 			_sysinfo.cpuModelType = match.captured(1);
 | |
| 		}
 | |
| 
 | |
| 		regEx.setPattern("^model name\\s*:\\s(.*)");
 | |
| 		match = regEx.match(cpuInfo);
 | |
| 		if (match.hasMatch())
 | |
| 		{
 | |
| 			_sysinfo.cpuModelName = match.captured(1);
 | |
| 		}
 | |
| 
 | |
| 		regEx.setPattern("^hardware\\s*:\\s(.*)");
 | |
| 		match = regEx.match(cpuInfo);
 | |
| 		if (match.hasMatch())
 | |
| 		{
 | |
| 			_sysinfo.cpuHardware = match.captured(1);
 | |
| 		}
 | |
| 
 | |
| 		regEx.setPattern("^revision\\s*:\\s(.*)");
 | |
| 		match = regEx.match(cpuInfo);
 | |
| 		if (match.hasMatch())
 | |
| 		{
 | |
| 			_sysinfo.cpuRevision = match.captured(1);
 | |
| 		}
 | |
| 
 | |
| 		regEx.setPattern("^revision\\s*:\\s(.*)");
 | |
| 		match = regEx.match(cpuInfo);
 | |
| 		if (match.hasMatch())
 | |
| 		{
 | |
| 			_sysinfo.cpuRevision = match.captured(1);
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| QString SysInfo::userName()
 | |
| {
 | |
| #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
 | |
| 	#if defined (WIN32)
 | |
| 		return qEnvironmentVariable("USERNAME");
 | |
| 	#else
 | |
| 		return qEnvironmentVariable("USER");
 | |
| 	#endif
 | |
| #else
 | |
| 	#if defined (WIN32)
 | |
| 		return getenv("USERNAME");
 | |
| 	#else
 | |
| 		return getenv("USER");
 | |
| 	#endif
 | |
| #endif
 | |
| }
 | |
| 
 | |
| bool SysInfo::isUserAdmin()
 | |
| {
 | |
| 	bool isAdmin{ false };
 | |
| 
 | |
| #ifdef _WIN32
 | |
| 	BOOL b;
 | |
| 	SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
 | |
| 	PSID AdministratorsGroup;
 | |
| 	b = AllocateAndInitializeSid(
 | |
| 		&NtAuthority,
 | |
| 		2,
 | |
| 		SECURITY_BUILTIN_DOMAIN_RID,
 | |
| 		DOMAIN_ALIAS_RID_ADMINS,
 | |
| 		0, 0, 0, 0, 0, 0,
 | |
| 		&AdministratorsGroup);
 | |
| 	if (b)
 | |
| 	{
 | |
| 		if (!CheckTokenMembership(NULL, AdministratorsGroup, &b))
 | |
| 		{
 | |
| 			b = false;
 | |
| 		}
 | |
| 		FreeSid(AdministratorsGroup);
 | |
| 	}
 | |
| 	// TRUE - User has Administrators local group.
 | |
| 	// FALSE - User does not have Administrators local group.
 | |
| 	isAdmin = b;
 | |
| #else
 | |
| 	if (getuid() == 0U)
 | |
| 	{
 | |
| 		isAdmin = true;
 | |
| 	}
 | |
| #endif
 | |
| 	return isAdmin;
 | |
| }
 |