]> git.saurik.com Git - apt-legacy.git/commitdiff
Finalized 2.1 Cydia.
authorJay Freeman (saurik) <saurik@saurik.com>
Sun, 14 Sep 2008 22:47:28 +0000 (22:47 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Sun, 14 Sep 2008 22:47:28 +0000 (22:47 +0000)
M cfnetwork.diff

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

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

index b512c5cb3fbe8c074c7300a30406695cca338b8e..aa6f516db48594698bba20ba6e49b5e4600a8624 100644 (file)
@@ -50,6 +50,7 @@ extern "C" {
 #include <netdb.h>
 #include <arpa/inet.h>
 
+#include <lockdown.h>
 #include <CoreFoundation/CoreFoundation.h>
 #include <CoreServices/CoreServices.h>
 #include <SystemConfiguration/SystemConfiguration.h>
@@ -63,7 +64,7 @@ using namespace std;
 
 CFStringRef Firmware_;
 const char *Machine_;
-const char *SerialNumber_;
+CFStringRef UniqueID_;
 
 void CfrsError(const char *name, CFReadStreamRef rs) {
     CFStreamError se = CFReadStreamGetError(rs);
@@ -1163,9 +1164,8 @@ int HttpMethod::Loop()
       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"));
 
@@ -1413,15 +1413,10 @@ int main()
         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();
 }
index 75930cab37cd276647215a81326430c1cf3e7366..e56ec17972fef7eea95e3027c7c0f63887789d6b 100644 (file)
@@ -46,6 +46,7 @@
 #include <netdb.h>
 #include <arpa/inet.h>
 
+#include <lockdown.h>
 #include <CoreFoundation/CoreFoundation.h>
 #include <CoreServices/CoreServices.h>
 #include <SystemConfiguration/SystemConfiguration.h>
@@ -59,7 +60,7 @@ using namespace std;
 
 CFStringRef Firmware_;
 const char *Machine_;
-const char *SerialNumber_;
+CFStringRef UniqueID_;
 
 void CfrsError(const char *name, CFReadStreamRef rs) {
     CFStreamError se = CFReadStreamGetError(rs);
@@ -1159,9 +1160,8 @@ int HttpMethod::Loop()
       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"));
 
@@ -1400,15 +1400,10 @@ int main()
         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();
 }
index 4d02404d1d81da44127232b09417e8f4816cdee6..4ca3cf8b097c6a6ecf95eee57f23b38884688f56 100644 (file)
@@ -47,7 +47,7 @@ include $(PROGRAM_H)
 
 # The http method
 PROGRAM=http
-SLIBS = -lapt-pkg $(SOCKETLIBS) -framework CoreFoundation -framework CFNetwork -framework SystemConfiguration -framework IOKit
+SLIBS = -lapt-pkg $(SOCKETLIBS) -framework CoreFoundation -framework CFNetwork -framework SystemConfiguration -framework IOKit -llockdown
 LIB_MAKES = apt-pkg/makefile
 SOURCE = http.cc rfc2553emu.cc connect.cc
 include $(PROGRAM_H)