Use gethostuuid instead of creating our own UUID

This commit is contained in:
Allan Odgaard
2014-11-17 00:05:26 +01:00
parent 235d52db7e
commit a2681bfdfb

View File

@@ -1,7 +1,6 @@
#include "user_agent.h"
#include <OakSystem/application.h>
#include <text/format.h>
#include <plist/uuid.h>
#include <io/path.h>
#include <cf/cf.h>
#include <oak/compat.h>
@@ -22,30 +21,15 @@ static std::string hardware_info (int field, bool integer = false)
return "???";
}
static std::string user_uuid ()
{
CFStringRef const kTextMateApplicationIdentifier = CFSTR("com.macromates.TextMate.preview");
std::string res = NULL_STR;
if(CFStringRef str = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("SoftwareUpdateUUID"), kTextMateApplicationIdentifier))
{
if(CFGetTypeID(str) == CFStringGetTypeID())
res = cf::to_s(str);
CFRelease(str);
}
if(res == NULL_STR)
{
res = oak::uuid_t().generate();
CFPreferencesSetAppValue(CFSTR("SoftwareUpdateUUID"), cf::wrap(res), kTextMateApplicationIdentifier);
CFPreferencesAppSynchronize(kTextMateApplicationIdentifier);
}
return res;
}
std::string create_agent_info_string ()
{
return text::format("%s/%s/%s %zu.%zu.%zu/%s/%s/%s", oak::application_t::name().c_str(), oak::application_t::version().c_str(), user_uuid().c_str(),
uuid_t uuid;
timespec wait = { };
gethostuuid(uuid, &wait);
uuid_string_t uuidStr;
uuid_unparse_upper(uuid, uuidStr);
return text::format("%s/%s/%s %zu.%zu.%zu/%s/%s/%s", oak::application_t::name().c_str(), oak::application_t::version().c_str(), uuidStr,
oak::os_major(), oak::os_minor(), oak::os_patch(),
hardware_info(HW_MACHINE).c_str(),
hardware_info(HW_MODEL).c_str(),