aboutsummaryrefslogtreecommitdiff
path: root/src/hardware_functions.cpp
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2020-05-22 01:18:24 +0300
committerCrystalwarrior <varsash@gmail.com>2020-05-22 01:18:24 +0300
commitc8e12558cdd3fd0769b81679ad09edf1f29b780f (patch)
tree7dae2225e574c3ee55d6b82a1d2f399db4ace5c0 /src/hardware_functions.cpp
parentdfac0652c8eb9bd48ceea7ae755e9c2f7e5cb1a2 (diff)
Clang-ify the code with this styling using Visual Studio Code:
{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Stroustrup, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All } (this is the Visual Studio preset with only "BreakBeforeBraces" changed from Allman to Stroustrup)
Diffstat (limited to 'src/hardware_functions.cpp')
-rw-r--r--src/hardware_functions.cpp75
1 files changed, 36 insertions, 39 deletions
diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp
index bd6a6c3c..21d72ece 100644
--- a/src/hardware_functions.cpp
+++ b/src/hardware_functions.cpp
@@ -2,7 +2,7 @@
#include <QDebug>
-#if (defined (_WIN32) || defined (_WIN64))
+#if (defined(_WIN32) || defined(_WIN64))
#include <windows.h>
static DWORD dwVolSerial;
@@ -10,43 +10,41 @@ static BOOL bIsRetrieved;
QString get_hdid()
{
- bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial, nullptr, nullptr, nullptr, 0);
-
- if (bIsRetrieved)
- return QString::number(dwVolSerial, 16);
- else
- //a totally random string
- //what could possibly go wrong
- return "gxsps32sa9fnwic92mfbs0";
+ bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial, nullptr, nullptr, nullptr, 0);
+
+ if (bIsRetrieved)
+ return QString::number(dwVolSerial, 16);
+ else
+ //a totally random string
+ //what could possibly go wrong
+ return "gxsps32sa9fnwic92mfbs0";
}
-#elif (defined (LINUX) || defined (__linux__))
+#elif (defined(LINUX) || defined(__linux__))
#include <QFile>
#include <QTextStream>
QString get_hdid()
{
- QFile fstab_file("/etc/fstab");
- if (!fstab_file.open(QIODevice::ReadOnly))
- return "gxcps32sa9fnwic92mfbs0";
+ QFile fstab_file("/etc/fstab");
+ if (!fstab_file.open(QIODevice::ReadOnly))
+ return "gxcps32sa9fnwic92mfbs0";
- QTextStream in(&fstab_file);
+ QTextStream in(&fstab_file);
- while(!in.atEnd())
- {
- QString line = in.readLine();
+ while (!in.atEnd()) {
+ QString line = in.readLine();
- if (line.startsWith("UUID"))
- {
- QStringList line_elements = line.split("=");
+ if (line.startsWith("UUID")) {
+ QStringList line_elements = line.split("=");
- if (line_elements.size() > 1)
- return line_elements.at(1).left(23).trimmed();
+ if (line_elements.size() > 1)
+ return line_elements.at(1).left(23).trimmed();
+ }
}
- }
- return "gxcpz32sa9fnwic92mfbs0";
+ return "gxcpz32sa9fnwic92mfbs0";
}
#elif defined __APPLE__
@@ -56,25 +54,24 @@ QString get_hdid()
QString get_hdid()
{
CFStringRef serial;
- char buffer[64] = {0};
- QString hdid;
- io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
+ char buffer[64] = {0};
+ QString hdid;
+ io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
IOServiceMatching("IOPlatformExpertDevice"));
- if (platformExpert)
- {
- CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert,
+ if (platformExpert) {
+ CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert,
CFSTR(kIOPlatformSerialNumberKey),
kCFAllocatorDefault, 0);
- if (serialNumberAsCFString) {
- serial = (CFStringRef)serialNumberAsCFString;
- }
- if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) {
- hdid = buffer;
- }
-
- IOObjectRelease(platformExpert);
+ if (serialNumberAsCFString) {
+ serial = (CFStringRef)serialNumberAsCFString;
+ }
+ if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) {
+ hdid = buffer;
}
- return hdid;
+
+ IOObjectRelease(platformExpert);
+ }
+ return hdid;
}
#else