NOISSUE simplify system detection and user agent handling

Now it only checks OS kernel name/version.
User agent is 'MultiMC5/$version'.
Kernel info is passed through custom dimensions in analytics.
This commit is contained in:
Petr Mrázek 2016-11-26 02:18:05 +01:00
parent d5fdc23eb2
commit 55541c387c
6 changed files with 34 additions and 142 deletions

View File

@ -1017,6 +1017,9 @@ MainWindow* MultiMC::showMainWindow(bool minimized)
customValues["cd2"] = m_settings->get("JavaArchitecture");
customValues["cd3"] = Sys::isSystem64bit() ? "64":"32";
customValues["cd4"] = Sys::isCPU64bit() ? "64":"32";
auto kernelInfo = Sys::getKernelInfo();
customValues["cd5"] = kernelInfo.kernelName;
customValues["cd6"] = kernelInfo.kernelVersion;
m_analytics->sendScreenView("Main Window", customValues);
}
return m_mainWindow;

View File

@ -3,11 +3,13 @@
namespace Sys
{
/**
* Get operation system name and version.
* @return os A QString with the name and version of the operating system.
*/
QString getSystemInfo();
struct KernelInfo
{
QString kernelName;
QString kernelVersion;
};
KernelInfo getKernelInfo();
uint64_t getSystemRam();

View File

@ -106,9 +106,7 @@ QString GAnalyticsWorker::getScreenResolution()
*/
QString GAnalyticsWorker::getUserAgent()
{
QString system = Sys::getSystemInfo();
return QString("%1/%2 (%3)").arg(m_appName).arg(m_appVersion).arg(system);
return QString("%1/%2").arg(m_appName).arg(m_appVersion);
}
/**

View File

@ -1,121 +1,16 @@
#include "sys.h"
// FIXME: replace with our version...
QString Sys::getSystemInfo()
#include <sys/utsname.h>
Sys::KernelInfo Sys::getKernelInfo()
{
QSysInfo::MacVersion version = QSysInfo::macVersion();
QString os;
switch (version)
{
case QSysInfo::MV_9:
os = "Macintosh; Mac OS 9";
break;
case QSysInfo::MV_10_0:
os = "Macintosh; Mac OS 10.0";
break;
case QSysInfo::MV_10_1:
os = "Macintosh; Mac OS 10.1";
break;
case QSysInfo::MV_10_2:
os = "Macintosh; Mac OS 10.2";
break;
case QSysInfo::MV_10_3:
os = "Macintosh; Mac OS 10.3";
break;
case QSysInfo::MV_10_4:
os = "Macintosh; Mac OS 10.4";
break;
case QSysInfo::MV_10_5:
os = "Macintosh; Mac OS 10.5";
break;
case QSysInfo::MV_10_6:
os = "Macintosh; Mac OS 10.6";
break;
case QSysInfo::MV_10_7:
os = "Macintosh; Mac OS 10.7";
break;
case QSysInfo::MV_10_8:
os = "Macintosh; Mac OS 10.8";
break;
case QSysInfo::MV_10_9:
os = "Macintosh; Mac OS 10.9";
break;
case QSysInfo::MV_10_10:
os = "Macintosh; Mac OS 10.10";
break;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
case QSysInfo::MV_10_11:
os = "Macintosh; Mac OS 10.11";
break;
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
case QSysInfo::MV_10_12:
os = "Macintosh; Mac OS 10.12";
break;
#endif
case QSysInfo::MV_Unknown:
os = "Macintosh; Mac OS unknown";
break;
case QSysInfo::MV_IOS_5_0:
os = "iPhone; iOS 5.0";
break;
case QSysInfo::MV_IOS_5_1:
os = "iPhone; iOS 5.1";
break;
case QSysInfo::MV_IOS_6_0:
os = "iPhone; iOS 6.0";
break;
case QSysInfo::MV_IOS_6_1:
os = "iPhone; iOS 6.1";
break;
case QSysInfo::MV_IOS_7_0:
os = "iPhone; iOS 7.0";
break;
case QSysInfo::MV_IOS_7_1:
os = "iPhone; iOS 7.1";
break;
case QSysInfo::MV_IOS_8_0:
os = "iPhone; iOS 8.0";
break;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
case QSysInfo::MV_IOS_8_1:
os = "iPhone; iOS 8.1";
break;
case QSysInfo::MV_IOS_8_2:
os = "iPhone; iOS 8.2";
break;
case QSysInfo::MV_IOS_8_3:
os = "iPhone; iOS 8.3";
break;
case QSysInfo::MV_IOS_8_4:
os = "iPhone; iOS 8.4";
break;
case QSysInfo::MV_IOS_9_0:
os = "iPhone; iOS 9.0";
break;
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
case QSysInfo::MV_IOS_9_1:
os = "iPhone; iOS 9.1";
break;
case QSysInfo::MV_IOS_9_2:
os = "iPhone; iOS 9.2";
break;
case QSysInfo::MV_IOS_9_3:
os = "iPhone; iOS 9.3";
break;
case QSysInfo::MV_IOS_10_0:
os = "iPhone; iOS 10.0";
break;
#endif
case QSysInfo::MV_IOS:
os = "iPhone; iOS unknown";
break;
default:
os = "Macintosh";
break;
}
return os;
Sys::KernelInfo out;
struct utsname buf;
uname(&buf);
out.kernelName = buf.sysname;
out.kernelVersion = buf.release;
out.kernelBuild = buf.version;
return out;
}
#include <sys/sysctl.h>

View File

@ -3,14 +3,14 @@
#include <sys/utsname.h>
#include <fstream>
QString Sys::getSystemInfo()
Sys::KernelInfo Sys::getKernelInfo()
{
Sys::KernelInfo out;
struct utsname buf;
uname(&buf);
QString system(buf.sysname);
QString release(buf.release);
return system + "; " + release;
out.kernelName = buf.sysname;
out.kernelVersion = buf.release;
return out;
}
uint64_t Sys::getSystemRam()

View File

@ -2,21 +2,15 @@
#include <windows.h>
QString Sys::getSystemInfo()
Sys::KernelInfo Sys::getKernelInfo()
{
static QString cached;
if(!cached.isNull())
{
return cached;
}
else
{
Sys::KernelInfo out;
out.kernelName = "Windows";
OSVERSIONINFOW osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFOW));
GetVersionExW(&osvi);
cached = QString("Windows %1.%2").arg(osvi.dwMajorVersion).arg(osvi.dwMinorVersion);
return cached;
}
out.kernelVersion = QString("%1.%2").arg(osvi.dwMajorVersion).arg(osvi.dwMinorVersion);
return out;
}
uint64_t Sys::getSystemRam()