From 1bef2eacc5f2c766c58d521663926fcec7d63cda Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 1 Oct 2021 12:32:44 +0200 Subject: [PATCH] Use hardware UUID as unique id on Apple --- src/slic3r/GUI/SendSystemInfoDialog.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/slic3r/GUI/SendSystemInfoDialog.cpp b/src/slic3r/GUI/SendSystemInfoDialog.cpp index bdf6743fc..34178133f 100644 --- a/src/slic3r/GUI/SendSystemInfoDialog.cpp +++ b/src/slic3r/GUI/SendSystemInfoDialog.cpp @@ -35,6 +35,8 @@ #include #include #pragma comment(lib, "iphlpapi.lib") +#elif __APPLE__ +#import #endif namespace Slic3r { @@ -265,7 +267,19 @@ static std::string get_unique_id() } free(AdapterInfo); #elif __APPLE__ + constexpr int buf_size = 100; + char buf[buf_size] = ""; + memset(&buf, 0, sizeof(buf)); + io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"); + CFStringRef uuidCf = (CFStringRef)IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); + IOObjectRelease(ioRegistryRoot); + CFStringGetCString(uuidCf, buf, buf_size, kCFStringEncodingMacRoman); + CFRelease(uuidCf); + // Now convert the string to std::vector. + for (char* c = buf; *c != 0; ++c) + unique.emplace_back((unsigned char)(*c)); #else // Linux/BSD + #endif // We should have a unique vector. Append a long prime to be