]> git.saurik.com Git - cydia.git/commitdiff
Checkpoint for LunaCy fork.
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 12 Jun 2009 17:49:26 +0000 (17:49 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 30 Sep 2010 07:13:15 +0000 (07:13 +0000)
UICaboodle/BrowserView.h
UICaboodle/BrowserView.m

index eb11d6c3e33f637bd0f8f7549f34ceb362b84097..f02e6793afe8cc9e19dfc3677937b45d0802d9e9 100644 (file)
@@ -50,6 +50,7 @@
     NSURLRequest *request_;
 
     NSNumber *confirm_;
     NSURLRequest *request_;
 
     NSNumber *confirm_;
+    NSNumber *sensitive_;
     NSString *title_;
     NSMutableSet *loading_;
     bool reloading_;
     NSString *title_;
     NSMutableSet *loading_;
     bool reloading_;
 
 - (id) _rightButtonTitle;
 
 
 - (id) _rightButtonTitle;
 
+- (bool) promptForSensitive:(NSString *)name;
+- (bool) allowSensitiveRequests;
+
 @end
 @end
index cb3709c23f4a2837847d6a32eb7385f3b3d3b56a..f7cf0f51003da0360087609d9435cc24fbd3d02a 100644 (file)
 }
 
 + (NSArray *) _attributeKeys {
 }
 
 + (NSArray *) _attributeKeys {
-    return [NSArray arrayWithObjects:@"device", nil];
+    return [NSArray arrayWithObjects:@"device", @"firewire", @"imei", @"mac", @"serial", nil];
 }
 
 - (NSArray *) attributeKeys {
 }
 
 - (NSArray *) attributeKeys {
     return [[UIDevice currentDevice] uniqueIdentifier];
 }
 
     return [[UIDevice currentDevice] uniqueIdentifier];
 }
 
+- (NSString *) mac {
+    if (![indirect_ promptForSensitive:@"Mac Address"])
+        return nil;
+}
+
+- (NSString *) serial {
+    if (![indirect_ promptForSensitive:@"Serial #"])
+        return nil;
+}
+
+- (NSString *) firewire {
+    if (![indirect_ promptForSensitive:@"Firewire GUID"])
+        return nil;
+}
+
+- (NSString *) imei {
+    if (![indirect_ promptForSensitive:@"IMEI"])
+        return nil;
+}
+
 + (NSString *) webScriptNameForSelector:(SEL)selector {
     if (selector == @selector(close))
         return @"close";
 + (NSString *) webScriptNameForSelector:(SEL)selector {
     if (selector == @selector(close))
         return @"close";
     [indicator_ release];
     if (confirm_ != nil)
         [confirm_ release];
     [indicator_ release];
     if (confirm_ != nil)
         [confirm_ release];
+    if (sensitive_ != nil)
+        [sensitive_ release];
     if (title_ != nil)
         [title_ release];
     [super dealloc];
     if (title_ != nil)
         [title_ release];
     [super dealloc];
     return true;
 }
 
     return true;
 }
 
+- (bool) allowSensitiveRequests {
+    [self _allowJavaScriptPanel];
+}
+
+- (void) _promptForSensitive:(NSMutableArray *)array {
+    NSString *name([array objectAtIndex:0]);
+
+    UIActionSheet *sheet = [[[UIActionSheet alloc]
+        initWithTitle:nil
+        buttons:[NSArray arrayWithObjects:CYLocalize("YES"), CYLocalize("NO"), nil]
+        defaultButtonIndex:0
+        delegate:indirect_
+        context:@"sensitive"
+    ] autorelease];
+
+    NSString *host(@"XXX");
+
+    [sheet setNumberOfRows:1];
+    [sheet setBodyText:[NSString stringWithFormat:@"The website at %@ is requesting your phone's %@. This is almost certainly for product licensing purposes. Will you allow this?", host, name]];
+    [sheet popupAlertAnimated:YES];
+
+    NSRunLoop *loop([NSRunLoop currentRunLoop]);
+    NSDate *future([NSDate distantFuture]);
+
+    while (sensitive_ == nil && [loop runMode:NSDefaultRunLoopMode beforeDate:future]);
+
+    NSNumber *sensitive([sensitive_ autorelease]);
+    sensitive_ = nil;
+
+    [self autorelease];
+    [array replaceObjectAtIndex:0 withObject:sensitive];
+}
+
+- (bool) promptForSensitive:(NSString *)name {
+    if (![self allowSensitiveRequests])
+        return false;
+
+    NSMutableArray *array([NSMutableArray arrayWithCapacity:1]);
+    [array addObject:name];
+
+    [self performSelectorOnMainThread:@selector(_promptForSensitive:) withObject:array waitUntilDone:YES];
+    return [[array lastObject] boolValue];
+}
+
 - (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
     if (![self _allowJavaScriptPanel])
         return;
 - (void) webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame {
     if (![self _allowJavaScriptPanel])
         return;
 
     UIActionSheet *sheet = [[[UIActionSheet alloc]
         initWithTitle:nil
 
     UIActionSheet *sheet = [[[UIActionSheet alloc]
         initWithTitle:nil
-        buttons:[NSArray arrayWithObjects:CYLocalize("OK"), CYLocalize("Cancel"), nil]
+        buttons:[NSArray arrayWithObjects:CYLocalize("OK"), CYLocalize("CANCEL"), nil]
         defaultButtonIndex:0
         delegate:indirect_
         context:@"confirm"
         defaultButtonIndex:0
         delegate:indirect_
         context:@"confirm"
             break;
         }
 
             break;
         }
 
+        [sheet dismiss];
+    } else if ([context isEqualToString:@"sensitive"]) {
+        switch (button) {
+            case 1:
+                sensitive_ = [NSNumber numberWithBool:YES];
+            break;
+
+            case 2:
+                sensitive_ = [NSNumber numberWithBool:NO];
+            break;
+        }
+
         [sheet dismiss];
     } else if ([context isEqualToString:@"challenge"]) {
         id<NSURLAuthenticationChallengeSender> sender([challenge_ sender]);
         [sheet dismiss];
     } else if ([context isEqualToString:@"challenge"]) {
         id<NSURLAuthenticationChallengeSender> sender([challenge_ sender]);