aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-01-23 12:21:58 +0100
committerDavid Skoland <davidskoland@gmail.com>2017-01-23 12:21:58 +0100
commit9ba9987d1fae9de120ee19ac93655efe9ed6566b (patch)
tree016190f6157cbb0bff5dfce17a6195155d851118
parent7b7315005329266c26facb1885dc6483c081fabb (diff)
added cleaner frame for cross-platform hdid implementation
-rw-r--r--Attorney_Online_remake.pro4
-rw-r--r--hardware_functions.cpp34
-rw-r--r--hardware_functions.h (renamed from win32_functions.h)3
-rw-r--r--packet_distribution.cpp6
-rw-r--r--win32_functions.cpp15
5 files changed, 40 insertions, 22 deletions
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index fe41bc27..1b2a1a22 100644
--- a/Attorney_Online_remake.pro
+++ b/Attorney_Online_remake.pro
@@ -30,7 +30,7 @@ SOURCES += main.cpp\
encryption_functions.cpp \
courtroom.cpp \
aocharbutton.cpp \
- win32_functions.cpp
+ hardware_functions.cpp
HEADERS += lobby.h \
text_file_functions.h \
@@ -48,4 +48,4 @@ HEADERS += lobby.h \
encryption_functions.h \
courtroom.h \
aocharbutton.h \
- win32_functions.h
+ hardware_functions.h
diff --git a/hardware_functions.cpp b/hardware_functions.cpp
new file mode 100644
index 00000000..ce6e35a6
--- /dev/null
+++ b/hardware_functions.cpp
@@ -0,0 +1,34 @@
+#include "hardware_functions.h"
+
+#if (defined (_WIN32) || defined (_WIN64))
+DWORD dwVolSerial;
+BOOL bIsRetrieved;
+
+QString get_hdid()
+{
+ bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL);
+
+ if (bIsRetrieved)
+ return QString::number(dwVolSerial, 16);
+ else
+ return "invalid_windows_hd"; //what could possibly go wrong
+
+}
+
+#elif (defined (LINUX) || defined (__linux__))
+
+QString get_hdid()
+{
+ //T0D0: add linux implementation
+ return "linux_os_hdid";
+}
+
+#else
+
+QString get_hdid()
+{
+ //T0D0: find a sane way to handle this
+ return "unknown_os_hdid";
+}
+
+#endif
diff --git a/win32_functions.h b/hardware_functions.h
index a095b883..7508a5a6 100644
--- a/win32_functions.h
+++ b/hardware_functions.h
@@ -3,7 +3,10 @@
#include <QString>
+#ifdef Q_OS_WIN32
#include <windows.h>
+#endif // Q_OS_WIN32
+
#include <stdio.h>
QString get_hdid();
diff --git a/packet_distribution.cpp b/packet_distribution.cpp
index 114f01bd..852afaf7 100644
--- a/packet_distribution.cpp
+++ b/packet_distribution.cpp
@@ -3,7 +3,7 @@
#include "lobby.h"
#include "networkmanager.h"
#include "encryption_functions.h"
-#include "win32_functions.h"
+#include "hardware_functions.h"
#include <QDebug>
@@ -87,11 +87,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt();
QString f_hdid;
-#ifdef Q_OS_WIN32
f_hdid = get_hdid();
-#else
- f_hdid = "ao2testinginprogress";
-#endif
AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%");
send_server_packet(hi_packet);
diff --git a/win32_functions.cpp b/win32_functions.cpp
deleted file mode 100644
index 76ca18a3..00000000
--- a/win32_functions.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "win32_functions.h"
-
-DWORD dwVolSerial;
-BOOL bIsRetrieved;
-
-QString get_hdid()
-{
- bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL);
-
- if (bIsRetrieved)
- return QString::number(dwVolSerial, 16);
- else
- return "invalidhd"; //what could possibly go wrong
-
-}