Below are example values generated by the current code.
osver: 11.2.1 20D74
osverbose: macOS 11.2
Below are example values generated with this commit applied.
osver: 11.2.1 20D74
osverbose: macOS 11.2.1 20D74
4fc7df5dde greatly improved OSInfo, but didn't take into account that the server passes its own values to OSInfo::fillXml().
As a result, "osver" was set to the same value as "osverbose" with the architecture appended to it.
Since the function is not called often (it's for the public list registration), this commit simply removes the arguments from it.
This originally started as a Linux-only improvement (support for "/etc/os-release"), but it became pretty clear that OSInfo was not in a pretty state.
Please note that the auto-update system is not affected, because it doesn't rely on OSInfo.
The most important change involves the OS name.
Before this commit we had "Win32", "WinX64", "OSX" and "X11". The latter was particularly misleading now that Wayland is a thing.
We now have "Windows", "Linux", "macOS", "FreeBSD", "NetBSD", "OpenBSD", "BSD", "UNIX" and "Unknown".
The second most important change is the way we retrieve the version on OSes other than Windows and macOS.
OSInfo had several methods, but none was aware of "/etc/os-release". We initially wanted to implement a new method, to be used as primary, that gathers info from that file.
However, we later realized we can just use QSysInfo because it does exactly what we planned to do on our own.
The reason why we're retaining our own methods for Windows and macOS is because they're MUCH more descriptive. For example, the build number is not in the strings returned by QSysInfo.
In order to make the code easier to read, the parts that handled versions of Windows we no longer support is removed.
The final change is about the info that is sent to our server.
"is64bit" was set to the correct value on all platforms except for Windows, because IsWow64Process() returns true only when the process is 32 bit and running on a 64 bit OS.
"arch" and "osarch" are introduced and represent the architecture of the program and the OS, respectively. "is64bit" is removed as it's now redundant.
"osverbose" is also introduced and represents the full operating system version.
27471118b5 introduced support for the 4th part (build/tweak) of the version, however:
1. It didn't replace all instances of MUMBLE_VERSION_STRING with MUMBLE_VERSION.
2. It accidentally replaced MUMBLE_VERSION_STRING with MUMBLE_RELEASE_ID in MumbleVersion::get()'s signature.
3. It didn't update the regex expression in MumbleVersion::get() to support 4 digits.
This commit fixes all issues listed above.
In b263b91340 I exchanged QString::sprintf
with QString::asprintf as the former was declared deprecated from Qt 5.5
onwards. I forgot to check the docs though. If I had, I would have
noticed that in contrast to sprintf, asprintf is a static function which
returns the assembled String (sprintf wrote it to the object it was
being called on). Thus I also have to assign the return value of
asprintf to a variable in order to have it have an effect.
This commit adds all the missing includes when the PCH header is not used.
Also, some includes are reordered and/or made consistent (e.g. "#include <QtEndian>" -> "#include <QtCore/QtEndian>").
According to Qt's documentation the PCH header doesn't need to be included.
From https://doc.qt.io/qt-5/qmake-precompiledheaders.html:
"To make your project use precompiled headers, you only need to define the PRECOMPILED_HEADER variable in your project file."
"qmake will handle the rest, to ensure the creation and use of the precompiled header file. You do not need to include the precompiled header file in HEADERS, as qmake will do this if the configuration supports precompiled headers."
Since we now build with a macOS target of 10.8 when
building against Qt 5.10, we get deprecation warnings
when calling gestalt.
The fix, for now, is to ignore deprecation warnings in
OSInfo on macOS.
This should be addressed in a better way in the future.
For that, mumble-voip/mumble#3290 has been filed.
../OSInfo.cpp:74:113: warning: passing NULL to non-pointer argument 3 of 'LONG RegOpenKeyExW(HKEY, LPCWSTR, DWORD, REGSAM, PHKEY)' [-Wconversion-null]
err = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", NULL, KEY_READ, &key);
^
../OSInfo.cpp: In static member function 'static QString OSInfo::getOSVersion()':
../OSInfo.cpp:197:135: warning: format '%d' expects argument of type 'int', but argument 3 has type 'DWORD {aka long unsigned int}' [-Wformat=]
os.sprintf("%d.%d.%d.%d", ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber, (ovi.wProductType == VER_NT_WORKSTATION) ? 1 : 0);
^
../OSInfo.cpp:197:135: warning: format '%d' expects argument of type 'int', but argument 4 has type 'DWORD {aka long unsigned int}' [-Wformat=]
../OSInfo.cpp:197:135: warning: format '%d' expects argument of type 'int', but argument 5 has type 'DWORD {aka long unsigned int}' [-Wformat=]
../OSInfo.cpp: In static member function 'static QString OSInfo::getOSDisplayableVersion()':
../OSInfo.cpp:466:86: warning: format '%d' expects argument of type 'int', but argument 3 has type 'DWORD {aka long unsigned int}' [-Wformat=]
osv.sprintf(" - %d.%d.%d", ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber);
^
../OSInfo.cpp:466:86: warning: format '%d' expects argument of type 'int', but argument 4 has type 'DWORD {aka long unsigned int}' [-Wformat=]
../OSInfo.cpp:466:86: warning: format '%d' expects argument of type 'int', but argument 5 has type 'DWORD {aka long unsigned int}' [-Wformat=]
These strings from the registry are NUL terminated, but in practice, this
isn't guaranteed.
This means that the displayable version string for Windows 10 currently
contains NUL values.
The Mumble client doesn't care, but it isn't very nice. It breaks things
like CVP providers that don't sanitize Murmur's output.
To fix the problem, this change introduces a regString function that
converts a wchar_t string to QString. Any NUL value in the input
string will terminate the string.
Fixesmumble-voip/mumble#2469
This change also removes the architecture
from the OSInfo string, since it is noisy.
The old code would always emit "i386", seemingly
since that's the "lowest" fatch arch that the current
OS X x86_64 kernels will run binaries from.
I tried to update the code, but instead of x86_64, I
got "x86_64h", which is Apple's arch string for
Haswell chips.
I don't think it makes sense anymore to have the
architecture string in the OSInfo on OS X. All
Macs running the modern OSes are x86_64 anyway.
Fixesmumble-voip/mumble#1341
The official name for the server version of Windows 10
is "Windows 10 Server Technical Preview" but since
"Technical Preview" is a detail, I haven't included it.
Closes#1435
The OS string from OSInfo is used in places such as log files, and
in the Server Info and User Info dialogs.
I think it'll be beneficial in the long run to be able to
distinguish an x86 build from an amd64 on in these places.
Technically, the full OSInfo dump has an is64bit flag, but it's not
visible in the aforementioned places - only the OS string is. The
isb64bit flag is only used when submitting usage stats.
This adds a new method, OSInfo::getOSDisplayableVersion(),
which returns a version string that is suitable for displaying
to regular users.
Furthermore, Mumble's User Information dialog and Murmur have been
modified to use this new method when displaying OS version strings
to users.
On Windows, the new method returns the full product version of the
OS, such as "Windows 8 Pro" (as opposed to 6.2.9200, which is the
equivalent result of the getOSVersion() method).
There are places in Mumble where the original "simple" version
string is required for compatibility or aesthetic reasons, such
as statistics and Mumble's HTTP user agent. Those places keep
the older version (by keeping their calls to the original
getOSVersion() instead of switching to the "displayable" variant).
It might seem overkill to jump through hoops to be able to show the
full product version, but it can be helpful for, say, server admins
to have access to the full product version if they need to
troubleshoot issues with their users.