From 643353a31e9adc99828d9aca78fb4e742bfb10e1 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Fri, 2 Dec 2016 15:46:20 -0800 Subject: [PATCH 1/7] Initial push Works on windows, have not tried it on mac. Lots more to do, but need to get it pushed to remote just in case. --- interface/src/Application.cpp | 8 +- libraries/networking/src/FingerprintUtils.cpp | 140 ++++++++++++++++++ libraries/networking/src/FingerprintUtils.h | 29 ++++ 3 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 libraries/networking/src/FingerprintUtils.cpp create mode 100644 libraries/networking/src/FingerprintUtils.h diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 76353104f4..9178a248ef 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -580,9 +581,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _window->setWindowTitle("Interface"); Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us - + + // TODO: This is temporary, while developing + FingerprintUtils::getMachineFingerprint(); + // End TODO auto nodeList = DependencyManager::get(); - + // Set up a watchdog thread to intentionally crash the application on deadlocks _deadlockWatchdogThread = new DeadlockWatchdogThread(); _deadlockWatchdogThread->start(); diff --git a/libraries/networking/src/FingerprintUtils.cpp b/libraries/networking/src/FingerprintUtils.cpp new file mode 100644 index 0000000000..6aa35dd2b6 --- /dev/null +++ b/libraries/networking/src/FingerprintUtils.cpp @@ -0,0 +1,140 @@ +// +// FingerprintUtils.h +// libraries/networking/src +// +// Created by David Kelly on 2016-12-02. +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "FingerprintUtils.h" +#include + +QString FingerprintUtils::getMachineFingerprint() { + QString retval; +#ifdef Q_OS_WIN + HRESULT hres; + IWbemLocator *pLoc = NULL; + + // initialize com + hres = CoCreateInstance( + CLSID_WbemLocator, + 0, + CLSCTX_INPROC_SERVER, + IID_IWbemLocator, (LPVOID *) &pLoc); + + if (FAILED(hres)) { + qDebug() << "Failed to initialize WbemLocator"; + return retval; + } + + // Connect to WMI through the IWbemLocator::ConnectServer method + IWbemServices *pSvc = NULL; + + // Connect to the root\cimv2 namespace with + // the current user and obtain pointer pSvc + // to make IWbemServices calls. + hres = pLoc->ConnectServer( + _bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace + NULL, // User name. NULL = current user + NULL, // User password. NULL = current + 0, // Locale. NULL indicates current + NULL, // Security flags. + 0, // Authority (for example, Kerberos) + 0, // Context object + &pSvc // pointer to IWbemServices proxy + ); + + if (FAILED(hres)) { + pLoc->Release(); + qDebug() << "Failed to connect to WMI"; + return retval; + } + + // Set security levels on the proxy + hres = CoSetProxyBlanket( + pSvc, // Indicates the proxy to set + RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx + RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx + NULL, // Server principal name + RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx + RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx + NULL, // client identity + EOAC_NONE // proxy capabilities + ); + + if (FAILED(hres)) { + pSvc->Release(); + pLoc->Release(); + qDebug() << "Failed to set security on proxy blanket"; + return retval; + } + + // Use the IWbemServices pointer to grab the Win32_BIOS stuff + IEnumWbemClassObject* pEnumerator = NULL; + hres = pSvc->ExecQuery( + bstr_t("WQL"), + bstr_t("SELECT * FROM Win32_ComputerSystemProduct"), + WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, + NULL, + &pEnumerator); + + if (FAILED(hres)) { + pSvc->Release(); + pLoc->Release(); + qDebug() << "query to get Win32_ComputerSystemProduct info"; + return retval; + } + + // Get the SerialNumber from the Win32_BIOS data + IWbemClassObject *pclsObj; + ULONG uReturn = 0; + + SHORT sRetStatus = -100; + + while (pEnumerator) { + HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); + + if(0 == uReturn){ + break; + } + + VARIANT vtProp; + + // Get the value of the Name property + hr = pclsObj->Get(L"UUID", 0, &vtProp, 0, 0); + if (!FAILED(hres)) { + switch (vtProp.vt) { + case VT_BSTR: + retval = QString::fromWCharArray(vtProp.bstrVal); + break; + } + } + VariantClear(&vtProp); + + pclsObj->Release(); + } + pEnumerator->Release(); + + // Cleanup + pSvc->Release(); + pLoc->Release(); + + qDebug() << "Windows BIOS UUID: " << retval; +#endif //Q_OS_WIN + +#ifdef Q_OS_MAC + + io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"); + CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); + IOObjectRelease(ioRegistryRoot); + retval = QString::fromCFString(uuidCf); + CFRelease(uuidCf); + qDebug() << "Mac serial number: " << retval; +#endif //Q_OS_MAC + + return retval; +} + diff --git a/libraries/networking/src/FingerprintUtils.h b/libraries/networking/src/FingerprintUtils.h new file mode 100644 index 0000000000..84a94f0abc --- /dev/null +++ b/libraries/networking/src/FingerprintUtils.h @@ -0,0 +1,29 @@ +// +// FingerprintUtils.h +// libraries/networking/src +// +// Created by David Kelly on 2016-12-02. +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_FingerprintUtils_h +#define hifi_FingerprintUtils_h + +#include + +#ifdef Q_OS_WIN +#include +#include +#endif //Q_OS_WIN + +class FingerprintUtils { +public: + static QString getMachineFingerprint(); + +}; + +#endif // hifi_FingerprintUtils_h + From 54716f70e5194feeb84d6357fdecdccaa1baf7d8 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Mon, 5 Dec 2016 11:11:30 -0800 Subject: [PATCH 2/7] Now works on mac, small build change for that Plus does nothing for linux, but there's a comment. --- libraries/networking/CMakeLists.txt | 9 +++++ libraries/networking/src/FingerprintUtils.cpp | 40 ++++++++++++++----- libraries/networking/src/FingerprintUtils.h | 4 -- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 53ebb86b83..8ef67cb2a4 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -15,6 +15,10 @@ add_dependency_external_projects(tbb) find_package(OpenSSL REQUIRED) find_package(TBB REQUIRED) +if (APPLE) + find_library(FRAMEWORK_IOKIT IOKit) +endif () + if (APPLE AND ${OPENSSL_INCLUDE_DIR} STREQUAL "/usr/include") # this is a user on OS X using system OpenSSL, which is going to throw warnings since they're deprecating for their common crypto message(WARNING "The found version of OpenSSL is the OS X system version. This will produce deprecation warnings." @@ -26,6 +30,11 @@ include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") # append OpenSSL to our list of libraries to link target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES} ${TBB_LIBRARIES}) +# IOKit is needed for getting machine fingerprint +if (APPLE) + target_link_libraries(${TARGET_NAME} ${FRAMEWORK_IOKIT}) +endif (APPLE) + # libcrypto uses dlopen in libdl if (UNIX) target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS}) diff --git a/libraries/networking/src/FingerprintUtils.cpp b/libraries/networking/src/FingerprintUtils.cpp index 6aa35dd2b6..7f18ccd276 100644 --- a/libraries/networking/src/FingerprintUtils.cpp +++ b/libraries/networking/src/FingerprintUtils.cpp @@ -12,8 +12,34 @@ #include "FingerprintUtils.h" #include +#ifdef Q_OS_WIN +#include +#include +#endif //Q_OS_WIN + +#ifdef Q_OS_MAC +#include +#include +#include +#endif //Q_OS_MAC + QString FingerprintUtils::getMachineFingerprint() { QString retval; + +#ifdef Q_OS_LINUX + // sadly need to be root to get smbios guid from linux, so + // for now lets do nothing. +#endif //Q_OS_LINUX + +#ifdef Q_OS_MAC + io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"); + CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); + IOObjectRelease(ioRegistryRoot); + retval = QString::fromCFString(uuidCf); + CFRelease(uuidCf); + qDebug() << "Mac serial number: " << retval; +#endif //Q_OS_MAC + #ifdef Q_OS_WIN HRESULT hres; IWbemLocator *pLoc = NULL; @@ -125,16 +151,10 @@ QString FingerprintUtils::getMachineFingerprint() { qDebug() << "Windows BIOS UUID: " << retval; #endif //Q_OS_WIN -#ifdef Q_OS_MAC - - io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"); - CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); - IOObjectRelease(ioRegistryRoot); - retval = QString::fromCFString(uuidCf); - CFRelease(uuidCf); - qDebug() << "Mac serial number: " << retval; -#endif //Q_OS_MAC - + // TODO: should we have a fallback for cases where this failed, + // leaving us with an empty string or something that isn't a + // guid? For now keeping this a string, but maybe best to return + // a QUuid? return retval; } diff --git a/libraries/networking/src/FingerprintUtils.h b/libraries/networking/src/FingerprintUtils.h index 84a94f0abc..cad198789c 100644 --- a/libraries/networking/src/FingerprintUtils.h +++ b/libraries/networking/src/FingerprintUtils.h @@ -14,10 +14,6 @@ #include -#ifdef Q_OS_WIN -#include -#include -#endif //Q_OS_WIN class FingerprintUtils { public: From 4d0f2c1ebb506ffa45820f6341e1d2ab2ae69349 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Mon, 5 Dec 2016 11:45:36 -0800 Subject: [PATCH 3/7] annoying whitespace --- libraries/networking/src/FingerprintUtils.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/networking/src/FingerprintUtils.h b/libraries/networking/src/FingerprintUtils.h index cad198789c..de7f0b87ff 100644 --- a/libraries/networking/src/FingerprintUtils.h +++ b/libraries/networking/src/FingerprintUtils.h @@ -18,7 +18,6 @@ class FingerprintUtils { public: static QString getMachineFingerprint(); - }; #endif // hifi_FingerprintUtils_h From 7880b5bfe00b31144b5d59ea8148aab795a1c35a Mon Sep 17 00:00:00 2001 From: David Kelly Date: Mon, 5 Dec 2016 17:05:39 -0800 Subject: [PATCH 4/7] Simple fallback now If the bios uuid isn't a valid UUID (on mac or windows it 'should be`) then we read the fallback from the settings and use that, or create and write one to the settings if it is missing. --- libraries/networking/src/FingerprintUtils.cpp | 46 ++++++++++++------- libraries/networking/src/FingerprintUtils.h | 8 ++-- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/libraries/networking/src/FingerprintUtils.cpp b/libraries/networking/src/FingerprintUtils.cpp index 7f18ccd276..b8e519c05d 100644 --- a/libraries/networking/src/FingerprintUtils.cpp +++ b/libraries/networking/src/FingerprintUtils.cpp @@ -11,7 +11,7 @@ #include "FingerprintUtils.h" #include - +#include #ifdef Q_OS_WIN #include #include @@ -23,8 +23,11 @@ #include #endif //Q_OS_MAC -QString FingerprintUtils::getMachineFingerprint() { - QString retval; +static const QString FALLBACK_FINGERPRINT_KEY = "fallbackFingerprint"; + +QUuid FingerprintUtils::getMachineFingerprint() { + + QString uuidString; #ifdef Q_OS_LINUX // sadly need to be root to get smbios guid from linux, so @@ -35,9 +38,9 @@ QString FingerprintUtils::getMachineFingerprint() { io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"); CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); IOObjectRelease(ioRegistryRoot); - retval = QString::fromCFString(uuidCf); + uuidString = QString::fromCFString(uuidCf); CFRelease(uuidCf); - qDebug() << "Mac serial number: " << retval; + qDebug() << "Mac serial number: " << uuidString; #endif //Q_OS_MAC #ifdef Q_OS_WIN @@ -53,7 +56,7 @@ QString FingerprintUtils::getMachineFingerprint() { if (FAILED(hres)) { qDebug() << "Failed to initialize WbemLocator"; - return retval; + return uuidString; } // Connect to WMI through the IWbemLocator::ConnectServer method @@ -76,7 +79,7 @@ QString FingerprintUtils::getMachineFingerprint() { if (FAILED(hres)) { pLoc->Release(); qDebug() << "Failed to connect to WMI"; - return retval; + return uuidString; } // Set security levels on the proxy @@ -95,7 +98,7 @@ QString FingerprintUtils::getMachineFingerprint() { pSvc->Release(); pLoc->Release(); qDebug() << "Failed to set security on proxy blanket"; - return retval; + return uuidString; } // Use the IWbemServices pointer to grab the Win32_BIOS stuff @@ -111,7 +114,7 @@ QString FingerprintUtils::getMachineFingerprint() { pSvc->Release(); pLoc->Release(); qDebug() << "query to get Win32_ComputerSystemProduct info"; - return retval; + return uuidString; } // Get the SerialNumber from the Win32_BIOS data @@ -134,7 +137,7 @@ QString FingerprintUtils::getMachineFingerprint() { if (!FAILED(hres)) { switch (vtProp.vt) { case VT_BSTR: - retval = QString::fromWCharArray(vtProp.bstrVal); + uuidString = QString::fromWCharArray(vtProp.bstrVal); break; } } @@ -148,13 +151,24 @@ QString FingerprintUtils::getMachineFingerprint() { pSvc->Release(); pLoc->Release(); - qDebug() << "Windows BIOS UUID: " << retval; + qDebug() << "Windows BIOS UUID: " << uuidString; #endif //Q_OS_WIN - // TODO: should we have a fallback for cases where this failed, - // leaving us with an empty string or something that isn't a - // guid? For now keeping this a string, but maybe best to return - // a QUuid? - return retval; + // now, turn into uuid. A malformed string will + // return QUuid() ("{00000...}") + QUuid uuid(uuidString); + if (uuid == QUuid()) { + // read fallback key (if any) + Settings settings; + uuid = QUuid(settings.value(FALLBACK_FINGERPRINT_KEY).toString()); + qDebug() << "read fallback maching fingerprint: " << uuid.toString(); + if (uuid == QUuid()) { + // no fallback yet, set one + uuid = QUuid::createUuid(); + settings.setValue(FALLBACK_FINGERPRINT_KEY, uuid.toString()); + qDebug() << "no fallback machine fingerprint, setting it to: " << uuid.toString(); + } + } + return uuid; } diff --git a/libraries/networking/src/FingerprintUtils.h b/libraries/networking/src/FingerprintUtils.h index cad198789c..2e4c5db561 100644 --- a/libraries/networking/src/FingerprintUtils.h +++ b/libraries/networking/src/FingerprintUtils.h @@ -13,12 +13,10 @@ #define hifi_FingerprintUtils_h #include +#include - -class FingerprintUtils { -public: - static QString getMachineFingerprint(); - +namespace FingerprintUtils { + QUuid getMachineFingerprint(); }; #endif // hifi_FingerprintUtils_h From c40aadfea41015548f5cbbb4590c4b8c03c8c842 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Mon, 5 Dec 2016 17:13:12 -0800 Subject: [PATCH 5/7] whitespace --- interface/src/Application.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9178a248ef..1bde51d6cc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -586,7 +586,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo FingerprintUtils::getMachineFingerprint(); // End TODO auto nodeList = DependencyManager::get(); - + // Set up a watchdog thread to intentionally crash the application on deadlocks _deadlockWatchdogThread = new DeadlockWatchdogThread(); _deadlockWatchdogThread->start(); From dc47c5fc0c606a75939ee68007f8c4d786412af4 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Tue, 6 Dec 2016 11:12:50 -0800 Subject: [PATCH 6/7] CR feedback lame mistake - it is always the error branches that get you. --- interface/src/Application.cpp | 2 +- libraries/networking/src/FingerprintUtils.cpp | 6 +----- libraries/networking/src/FingerprintUtils.h | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1bde51d6cc..946bad2cc3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -583,7 +583,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us // TODO: This is temporary, while developing - FingerprintUtils::getMachineFingerprint(); + fingerprint::getMachineFingerprint(); // End TODO auto nodeList = DependencyManager::get(); diff --git a/libraries/networking/src/FingerprintUtils.cpp b/libraries/networking/src/FingerprintUtils.cpp index b8e519c05d..1dc17e0c5b 100644 --- a/libraries/networking/src/FingerprintUtils.cpp +++ b/libraries/networking/src/FingerprintUtils.cpp @@ -25,7 +25,7 @@ static const QString FALLBACK_FINGERPRINT_KEY = "fallbackFingerprint"; -QUuid FingerprintUtils::getMachineFingerprint() { +QUuid fingerprint::getMachineFingerprint() { QString uuidString; @@ -56,7 +56,6 @@ QUuid FingerprintUtils::getMachineFingerprint() { if (FAILED(hres)) { qDebug() << "Failed to initialize WbemLocator"; - return uuidString; } // Connect to WMI through the IWbemLocator::ConnectServer method @@ -79,7 +78,6 @@ QUuid FingerprintUtils::getMachineFingerprint() { if (FAILED(hres)) { pLoc->Release(); qDebug() << "Failed to connect to WMI"; - return uuidString; } // Set security levels on the proxy @@ -98,7 +96,6 @@ QUuid FingerprintUtils::getMachineFingerprint() { pSvc->Release(); pLoc->Release(); qDebug() << "Failed to set security on proxy blanket"; - return uuidString; } // Use the IWbemServices pointer to grab the Win32_BIOS stuff @@ -114,7 +111,6 @@ QUuid FingerprintUtils::getMachineFingerprint() { pSvc->Release(); pLoc->Release(); qDebug() << "query to get Win32_ComputerSystemProduct info"; - return uuidString; } // Get the SerialNumber from the Win32_BIOS data diff --git a/libraries/networking/src/FingerprintUtils.h b/libraries/networking/src/FingerprintUtils.h index 2e4c5db561..1d59bd20a5 100644 --- a/libraries/networking/src/FingerprintUtils.h +++ b/libraries/networking/src/FingerprintUtils.h @@ -15,7 +15,7 @@ #include #include -namespace FingerprintUtils { +namespace fingerprint { QUuid getMachineFingerprint(); }; From 562cd12bca0d8efcde4551e96a9a947a2599c80c Mon Sep 17 00:00:00 2001 From: David Kelly Date: Tue, 6 Dec 2016 15:17:47 -0800 Subject: [PATCH 7/7] More CR feedback Breaking into 2 functions - one public, one private, so I can avoid nested control structures and so on in dealing with errors on the windows side of things. So, no more namespace, back to a class with 2 static functions, one public one private --- interface/src/Application.cpp | 2 +- libraries/networking/src/FingerprintUtils.cpp | 20 ++++++++++++++----- libraries/networking/src/FingerprintUtils.h | 8 ++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 946bad2cc3..1bde51d6cc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -583,7 +583,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us // TODO: This is temporary, while developing - fingerprint::getMachineFingerprint(); + FingerprintUtils::getMachineFingerprint(); // End TODO auto nodeList = DependencyManager::get(); diff --git a/libraries/networking/src/FingerprintUtils.cpp b/libraries/networking/src/FingerprintUtils.cpp index 1dc17e0c5b..42a617e93d 100644 --- a/libraries/networking/src/FingerprintUtils.cpp +++ b/libraries/networking/src/FingerprintUtils.cpp @@ -24,11 +24,8 @@ #endif //Q_OS_MAC static const QString FALLBACK_FINGERPRINT_KEY = "fallbackFingerprint"; - -QUuid fingerprint::getMachineFingerprint() { - +QString FingerprintUtils::getMachineFingerprintString() { QString uuidString; - #ifdef Q_OS_LINUX // sadly need to be root to get smbios guid from linux, so // for now lets do nothing. @@ -56,6 +53,7 @@ QUuid fingerprint::getMachineFingerprint() { if (FAILED(hres)) { qDebug() << "Failed to initialize WbemLocator"; + return uuidString; } // Connect to WMI through the IWbemLocator::ConnectServer method @@ -78,6 +76,7 @@ QUuid fingerprint::getMachineFingerprint() { if (FAILED(hres)) { pLoc->Release(); qDebug() << "Failed to connect to WMI"; + return uuidString; } // Set security levels on the proxy @@ -96,6 +95,7 @@ QUuid fingerprint::getMachineFingerprint() { pSvc->Release(); pLoc->Release(); qDebug() << "Failed to set security on proxy blanket"; + return uuidString; } // Use the IWbemServices pointer to grab the Win32_BIOS stuff @@ -111,6 +111,7 @@ QUuid fingerprint::getMachineFingerprint() { pSvc->Release(); pLoc->Release(); qDebug() << "query to get Win32_ComputerSystemProduct info"; + return uuidString; } // Get the SerialNumber from the Win32_BIOS data @@ -150,8 +151,17 @@ QUuid fingerprint::getMachineFingerprint() { qDebug() << "Windows BIOS UUID: " << uuidString; #endif //Q_OS_WIN + return uuidString; + +} + +QUuid FingerprintUtils::getMachineFingerprint() { + + QString uuidString = getMachineFingerprintString(); + // now, turn into uuid. A malformed string will - // return QUuid() ("{00000...}") + // return QUuid() ("{00000...}"), which handles + // any errors in getting the string QUuid uuid(uuidString); if (uuid == QUuid()) { // read fallback key (if any) diff --git a/libraries/networking/src/FingerprintUtils.h b/libraries/networking/src/FingerprintUtils.h index 1d59bd20a5..572b150ec4 100644 --- a/libraries/networking/src/FingerprintUtils.h +++ b/libraries/networking/src/FingerprintUtils.h @@ -15,8 +15,12 @@ #include #include -namespace fingerprint { - QUuid getMachineFingerprint(); +class FingerprintUtils { +public: + static QUuid getMachineFingerprint(); + +private: + static QString getMachineFingerprintString(); }; #endif // hifi_FingerprintUtils_h