From 032f992c5ed1130c348c7ddd074cde239e09cc87 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 11 May 2008 06:38:34 +0000 Subject: [PATCH] Added X-Firmware to APT. M cfnetwork.diff git-svn-id: http://svn.telesphoreo.org/trunk@277 514c082c-b64e-11dc-b46d-3d985efe055d --- methods/http.cc | 21 +++++++++++++++++++++ methods/http.cc.orig | 21 +++++++++++++++++++++ methods/makefile | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/methods/http.cc b/methods/http.cc index 678c5f5..2819ae1 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -61,6 +61,7 @@ extern "C" { /*}}}*/ using namespace std; +CFStringRef Firmware_; const char *Machine_; const char *SerialNumber_; @@ -1158,6 +1159,9 @@ int HttpMethod::Loop() CFRelease(sr); } + if (Firmware_ != NULL) + CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Firmware"), Firmware_); + sr = CFStringCreateWithCString(kCFAllocatorDefault, Machine_, se); CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Machine"), sr); CFRelease(sr); @@ -1401,6 +1405,23 @@ int main() sysctlbyname("hw.machine", machine, &size, NULL, 0); Machine_ = machine; + const char *path = "/System/Library/CoreServices/SystemVersion.plist"; + CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (uint8_t *) path, strlen(path), false); + + CFPropertyListRef plist; { + CFReadStreamRef stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, url); + CFReadStreamOpen(stream); + plist = CFPropertyListCreateFromStream(kCFAllocatorDefault, stream, 0, kCFPropertyListImmutable, NULL, NULL); + CFReadStreamClose(stream); + } + + CFRelease(url); + + if (plist != NULL) { + Firmware_ = (CFStringRef) CFRetain(CFDictionaryGetValue((CFDictionaryRef) plist, CFSTR("ProductVersion"))); + CFRelease(plist); + } + if (CFMutableDictionaryRef dict = IOServiceMatching("IOPlatformExpertDevice")) if (io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, dict)) { if (CFTypeRef serial = IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0)) { diff --git a/methods/http.cc.orig b/methods/http.cc.orig index 3410a3e..5e87631 100644 --- a/methods/http.cc.orig +++ b/methods/http.cc.orig @@ -57,6 +57,7 @@ /*}}}*/ using namespace std; +CFStringRef Firmware_; const char *Machine_; const char *SerialNumber_; @@ -1154,6 +1155,9 @@ int HttpMethod::Loop() CFRelease(sr); } + if (Firmware_ != NULL) + CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Firmware"), Firmware_); + sr = CFStringCreateWithCString(kCFAllocatorDefault, Machine_, se); CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Machine"), sr); CFRelease(sr); @@ -1388,6 +1392,23 @@ int main() sysctlbyname("hw.machine", machine, &size, NULL, 0); Machine_ = machine; + const char *path = "/System/Library/CoreServices/SystemVersion.plist"; + CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (uint8_t *) path, strlen(path), false); + + CFPropertyListRef plist; { + CFReadStreamRef stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, url); + CFReadStreamOpen(stream); + plist = CFPropertyListCreateFromStream(kCFAllocatorDefault, stream, 0, kCFPropertyListImmutable, NULL, NULL); + CFReadStreamClose(stream); + } + + CFRelease(url); + + if (plist != NULL) { + Firmware_ = (CFStringRef) CFRetain(CFDictionaryGetValue((CFDictionaryRef) plist, CFSTR("ProductVersion"))); + CFRelease(plist); + } + if (CFMutableDictionaryRef dict = IOServiceMatching("IOPlatformExpertDevice")) if (io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, dict)) { if (CFTypeRef serial = IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0)) { diff --git a/methods/makefile b/methods/makefile index eb931af..4d02404 100644 --- a/methods/makefile +++ b/methods/makefile @@ -47,7 +47,7 @@ include $(PROGRAM_H) # The http method PROGRAM=http -SLIBS = -lapt-pkg $(SOCKETLIBS) -framework CFNetwork -framework CoreFoundation -framework SystemConfiguration -framework IOKit +SLIBS = -lapt-pkg $(SOCKETLIBS) -framework CoreFoundation -framework CFNetwork -framework SystemConfiguration -framework IOKit LIB_MAKES = apt-pkg/makefile SOURCE = http.cc rfc2553emu.cc connect.cc include $(PROGRAM_H) -- 2.45.2