]> git.saurik.com Git - cydia.git/commitdiff
Provide cydia.mcc and cydia.mnc, not cydia.plmn.
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 18 Mar 2011 12:28:53 +0000 (05:28 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 18 Mar 2011 12:28:53 +0000 (05:28 -0700)
MobileCydia.mm

index 946bf03c748ad56065c2b316bd4ab9b3368b07c6..e8d8cfc1f21f2188f31958ecec84d9c8f7af2ffd 100644 (file)
@@ -691,7 +691,6 @@ static NSString *ChipID_ = nil;
 static NSString *BBSNum_ = nil;
 static _H<NSString> Token_;
 static NSString *UniqueID_ = nil;
-static NSString *PLMN_ = nil;
 static NSString *Build_ = nil;
 static NSString *Product_ = nil;
 static NSString *Safari_ = nil;
@@ -3962,8 +3961,9 @@ static _H<NSMutableSet> Diversions_;
         @"firmware",
         @"hostname",
         @"idiom",
+        @"mcc",
+        @"mnc",
         @"model",
-        @"plmn",
         @"role",
         @"serial",
         @"token",
@@ -3999,8 +3999,16 @@ static _H<NSMutableSet> Diversions_;
     return (id) Idiom_ ?: [NSNull null];
 }
 
-- (NSString *) plmn {
-    return (id) PLMN_ ?: [NSNull null];
+- (NSString *) mcc {
+    if (CFStringRef (*$CTSIMSupportCopyMobileSubscriberCountryCode)(CFAllocatorRef) = reinterpret_cast<CFStringRef (*)(CFAllocatorRef)>(dlsym(RTLD_DEFAULT, "CTSIMSupportCopyMobileSubscriberCountryCode")))
+        return [(NSString *) (*$CTSIMSupportCopyMobileSubscriberCountryCode)(kCFAllocatorDefault) autorelease];
+    return nil;
+}
+
+- (NSString *) mnc {
+    if (CFStringRef (*$CTSIMSupportCopyMobileSubscriberNetworkCode)(CFAllocatorRef) = reinterpret_cast<CFStringRef (*)(CFAllocatorRef)>(dlsym(RTLD_DEFAULT, "CTSIMSupportCopyMobileSubscriberNetworkCode")))
+        return [(NSString *) (*$CTSIMSupportCopyMobileSubscriberNetworkCode)(kCFAllocatorDefault) autorelease];
+    return nil;
 }
 
 - (NSString *) bbsnum {
@@ -10221,31 +10229,6 @@ int main(int argc, char *argv[]) {
 
     UniqueID_ = [device uniqueIdentifier];
 
-    CFStringRef (*$CTSIMSupportCopyMobileSubscriberCountryCode)(CFAllocatorRef);
-    $CTSIMSupportCopyMobileSubscriberCountryCode = reinterpret_cast<CFStringRef (*)(CFAllocatorRef)>(dlsym(RTLD_DEFAULT, "CTSIMSupportCopyMobileSubscriberCountryCode"));
-    CFStringRef mcc($CTSIMSupportCopyMobileSubscriberCountryCode == NULL ? NULL : (*$CTSIMSupportCopyMobileSubscriberCountryCode)(kCFAllocatorDefault));
-
-    CFStringRef (*$CTSIMSupportCopyMobileSubscriberNetworkCode)(CFAllocatorRef);
-    $CTSIMSupportCopyMobileSubscriberNetworkCode = reinterpret_cast<CFStringRef (*)(CFAllocatorRef)>(dlsym(RTLD_DEFAULT, "CTSIMSupportCopyMobileSubscriberNetworkCode"));
-    CFStringRef mnc($CTSIMSupportCopyMobileSubscriberNetworkCode == NULL ? NULL : (*$CTSIMSupportCopyMobileSubscriberNetworkCode)(kCFAllocatorDefault));
-
-    if (mcc != NULL && mnc != NULL)
-        if (CFStringGetLength(mcc) == 3) {
-            CFIndex length(CFStringGetLength(mnc));
-            if (length == 2 || length == 3) {
-                PLMN_ = [NSString stringWithFormat:@"%@%@", mcc, mnc];
-
-                Pcre pattern("^[0-9]{5,6}$");
-                if (!pattern(PLMN_))
-                    PLMN_ = nil;
-            }
-        }
-
-    if (mnc != NULL)
-        CFRelease(mnc);
-    if (mcc != NULL)
-        CFRelease(mcc);
-
     if (NSDictionary *system = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"])
         Build_ = [system objectForKey:@"ProductBuildVersion"];
     if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:@"/Applications/MobileSafari.app/Info.plist"]) {