]> git.saurik.com Git - apt-legacy.git/blobdiff - methods/http.cc
Finalized 2.1 Cydia.
[apt-legacy.git] / methods / http.cc
index 1a7e7c95827552187be702f375145d42d40b6272..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);
@@ -1127,6 +1128,14 @@ int HttpMethod::Loop()
 
       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);
@@ -1143,7 +1152,7 @@ int HttpMethod::Loop()
          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);
       }
@@ -1155,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"));
 
@@ -1405,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();
 }