#include <netdb.h>
#include <arpa/inet.h>
+#include <lockdown.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <SystemConfiguration/SystemConfiguration.h>
CFStringRef Firmware_;
const char *Machine_;
-const char *SerialNumber_;
+CFStringRef UniqueID_;
void CfrsError(const char *name, CFReadStreamRef rs) {
CFStreamError se = CFReadStreamGetError(rs);
std::string urs = uri;
+ for (;;) {
+ size_t bad = urs.find_first_of("+");
+ if (bad == std::string::npos)
+ break;
+ // XXX: generalize
+ urs = urs.substr(0, bad) + "%2b" + urs.substr(bad + 1);
+ }
+
CFStringRef sr = CFStringCreateWithCString(kCFAllocatorDefault, urs.c_str(), se);
CFURLRef ur = CFURLCreateWithString(kCFAllocatorDefault, sr, NULL);
CFRelease(sr);
CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("If-Range"), sr);
CFRelease(sr);
} else if (Queue->LastModified != 0) {
- sr = CFStringCreateWithCString(kCFAllocatorDefault, TimeRFC1123(SBuf.st_mtime).c_str(), se);
+ sr = CFStringCreateWithCString(kCFAllocatorDefault, TimeRFC1123(Queue->LastModified).c_str(), se);
CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("If-Modified-Since"), sr);
CFRelease(sr);
}
CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Machine"), sr);
CFRelease(sr);
- sr = CFStringCreateWithCString(kCFAllocatorDefault, SerialNumber_, se);
- CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Serial-Number"), sr);
- CFRelease(sr);
+ if (UniqueID_ != NULL)
+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Unique-ID"), UniqueID_);
CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("User-Agent"), CFSTR("Telesphoreo APT-HTTP/1.0.98"));
CFRelease(plist);
}
- if (CFMutableDictionaryRef dict = IOServiceMatching("IOPlatformExpertDevice"))
- if (io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, dict)) {
- if (CFTypeRef serial = IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0)) {
- SerialNumber_ = strdup(CFStringGetCStringPtr((CFStringRef) serial, CFStringGetSystemEncoding()));
- CFRelease(serial);
- }
-
- IOObjectRelease(service);
- }
+ if (void *lockdown = lockdown_connect()) {
+ UniqueID_ = lockdown_copy_value(lockdown, NULL, kLockdownUniqueDeviceIDKey);
+ lockdown_disconnect(lockdown);
+ }
return Mth.Loop();
}