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
This commit is contained in:
David Kelly 2016-12-06 15:17:47 -08:00
parent dc47c5fc0c
commit 562cd12bca
3 changed files with 22 additions and 8 deletions

View file

@ -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<NodeList>();

View file

@ -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)

View file

@ -15,8 +15,12 @@
#include <QString>
#include <QUuid>
namespace fingerprint {
QUuid getMachineFingerprint();
class FingerprintUtils {
public:
static QUuid getMachineFingerprint();
private:
static QString getMachineFingerprintString();
};
#endif // hifi_FingerprintUtils_h