Skip to content

Commit

Permalink
Use gethostuuid instead of creating our own UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
sorbits committed Nov 16, 2014
1 parent 235d52d commit a2681bf
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions Frameworks/network/src/user_agent.cc
@@ -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>
Expand All @@ -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(),
Expand Down

0 comments on commit a2681bf

Please sign in to comment.