]> git.saurik.com Git - apt-legacy.git/commitdiff
Added X-Firmware to APT.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 11 May 2008 06:38:34 +0000 (06:38 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 11 May 2008 06:38:34 +0000 (06:38 +0000)
M cfnetwork.diff

git-svn-id: http://svn.telesphoreo.org/trunk@277 514c082c-b64e-11dc-b46d-3d985efe055d

methods/http.cc
methods/http.cc.orig
methods/makefile

index 678c5f59580e4757ff8c3a9bfd525d3ce0d262f9..2819ae165a61c508d1b28db5dae44e96e0558f3c 100644 (file)
@@ -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)) {
index 3410a3e1f1b6de1b734b2ef788f3b4733875ffa4..5e87631ee49280150ddac34b9e3d4be75e8ab277 100644 (file)
@@ -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)) {
index eb931afa639e3f5fa4ee07ca514ca6e13fb52ab0..4d02404d1d81da44127232b09417e8f4816cdee6 100644 (file)
@@ -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)