diff options
| author | David Skoland <davidskoland@gmail.com> | 2017-01-27 01:24:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-27 01:24:58 +0100 |
| commit | d4ad200b612acb1ed2a74d057efc8c3cbfa07ad2 (patch) | |
| tree | a2b2dbee3b1a3102499b3cb5c6529e6f01655f74 /hardware_functions.cpp | |
| parent | ea9ba4526dc313a61682ec41b3b052019051545e (diff) | |
| parent | 9682087667e2de26e14406efde960b8c7f0c3c98 (diff) | |
Merge pull request #2 from OmniTroid/master
well
Diffstat (limited to 'hardware_functions.cpp')
| -rw-r--r-- | hardware_functions.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/hardware_functions.cpp b/hardware_functions.cpp index ce6e35a6..0b161c3d 100644 --- a/hardware_functions.cpp +++ b/hardware_functions.cpp @@ -1,6 +1,10 @@ #include "hardware_functions.h" +#include <QDebug> + #if (defined (_WIN32) || defined (_WIN64)) +#include <windows.h> + DWORD dwVolSerial; BOOL bIsRetrieved; @@ -11,24 +15,43 @@ QString get_hdid() if (bIsRetrieved) return QString::number(dwVolSerial, 16); else - return "invalid_windows_hd"; //what could possibly go wrong + return "gxsps32sa9fnwic92mfbs0"; //what could possibly go wrong } #elif (defined (LINUX) || defined (__linux__)) +#include <QFile> +#include <QTextStream> + QString get_hdid() { - //T0D0: add linux implementation - return "linux_os_hdid"; + QFile fstab_file("/etc/fstab"); + if (!fstab_file.open(QIODevice::ReadOnly)) + //literally a random string.... what else are we supposed to do? + return "gxcps32sa9fnwic92mfbs0"; + + QTextStream in(&fstab_file); + + while(!in.atEnd()) + { + QString line = in.readLine(); + + if (line.startsWith("UUID")) + { + QStringList line_elements = line.split("="); + + if (line_elements.size() > 1) + return line_elements.at(1).left(23).trimmed(); + } + } + + return "gxcpz32sa9fnwic92mfbs0"; } #else -QString get_hdid() -{ - //T0D0: find a sane way to handle this - return "unknown_os_hdid"; -} +//throwing compile-time errors professionally +fhasdfuifhidfhasjkfasdkfahsdj #endif |
