You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by be...@apache.org on 2012/01/13 16:59:06 UTC

[11/50] git commit: Got PGViewController working, with no splash screen support yet.

Got PGViewController working, with no splash screen support yet.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/01dfa7d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/01dfa7d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/01dfa7d0

Branch: refs/heads/master
Commit: 01dfa7d0678c6461d4c93f36549e80851b3312ea
Parents: b808ee9
Author: shazron <sh...@gmail.com>
Authored: Fri Jan 6 17:53:01 2012 -0800
Committer: shazron <sh...@gmail.com>
Committed: Fri Jan 6 17:53:01 2012 -0800

----------------------------------------------------------------------
 PhoneGap-based Application/Classes/AppDelegate.m  |   66 +-
 PhoneGapLib/Classes/Capture.m                     |   26 +-
 PhoneGapLib/Classes/Location.m                    |    6 +-
 PhoneGapLib/Classes/PGURLProtocol.m               |    5 +-
 PhoneGapLib/Classes/PGViewController.h            |   28 +-
 PhoneGapLib/Classes/PGViewController.m            |  259 ++++---
 PhoneGapLib/Classes/PhoneGapDelegate.h            |   40 +-
 PhoneGapLib/Classes/PhoneGapDelegate.m            |  620 +---------------
 PhoneGapLib/Classes/PhoneGapViewController.h      |   13 +-
 PhoneGapLib/Classes/PhoneGapViewController.m      |  108 ---
 PhoneGapLib/Classes/Sound.m                       |    5 +-
 PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj |   40 +-
 12 files changed, 281 insertions(+), 935 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGap-based Application/Classes/AppDelegate.m
----------------------------------------------------------------------
diff --git a/PhoneGap-based Application/Classes/AppDelegate.m b/PhoneGap-based Application/Classes/AppDelegate.m
index 6308aa0..f937903 100644
--- a/PhoneGap-based Application/Classes/AppDelegate.m	
+++ b/PhoneGap-based Application/Classes/AppDelegate.m	
@@ -28,7 +28,7 @@
 /**
  * This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
  */
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
 {    
     NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
     if (url && [url isKindOfClass:[NSURL class]])
@@ -37,33 +37,38 @@
 		NSLog(@"___PROJECTNAME___ launchOptions = %@",url);
     }    
 		
-	return [super application:application didFinishLaunchingWithOptions:launchOptions];
+	BOOL ok = [super application:application didFinishLaunchingWithOptions:launchOptions];
+    if (ok) {
+        self.viewController.webView.delegate = self;
+    }
+    return ok;
 }
 
 // this happens while we are running ( in the background, or from within our own app )
 // only valid if ___PROJECTNAME___.plist specifies a protocol to handle
-- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
+- (BOOL) application:(UIApplication*)application handleOpenURL:(NSURL*)url 
 {
     // must call super so all plugins will get the notification, and their handlers will be called 
 	// super also calls into javascript global function 'handleOpenURL'
     return [super application:application handleOpenURL:url];
 }
 
--(id) getCommandInstance:(NSString*)className
+- (id) getCommandInstance:(NSString*)className
 {
-	/** You can catch your own commands here, if you wanted to extend the gap: protocol, or add your
-	 *  own app specific protocol to it. -jm
-	 **/
-	return [super getCommandInstance:className];
+	return [super.viewController getCommandInstance:className];
 }
 
-/**
- Called when the webview finishes loading.  This stops the activity view and closes the imageview
- */
-- (void)webViewDidFinishLoad:(UIWebView *)theWebView 
+- (BOOL) execute:(InvokedUrlCommand*)command
+{
+	return [super.viewController execute:command];
+}
+
+#pragma UIWebDelegate implementation
+
+- (void) webViewDidFinishLoad:(UIWebView*) theWebView 
 {
 	// only valid if ___PROJECTNAME___.plist specifies a protocol to handle
-	if(self.invokeString)
+	if (self.invokeString)
 	{
 		// this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
 		NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
@@ -73,42 +78,27 @@
 	 // Black base color for background matches the native apps
    	theWebView.backgroundColor = [UIColor blackColor];
     
-	return [ super webViewDidFinishLoad:theWebView ];
+	return [super.viewController webViewDidFinishLoad:theWebView];
 }
 
-- (void)webViewDidStartLoad:(UIWebView *)theWebView 
+- (void) webViewDidStartLoad:(UIWebView*)theWebView 
 {
-	return [ super webViewDidStartLoad:theWebView ];
+	return [super.viewController webViewDidStartLoad:theWebView];
 }
 
-/**
- * Fail Loading With Error
- * Error - If the webpage failed to load display an error with the reason.
- */
-- (void)webView:(UIWebView *)theWebView didFailLoadWithError:(NSError *)error 
-{
-	return [ super webView:theWebView didFailLoadWithError:error ];
-}
-
-/**
- * Start Loading Request
- * This is where most of the magic happens... We take the request(s) and process the response.
- * From here we can redirect links and other protocols to different internal methods.
- */
-- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
+- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error 
 {
-	return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
+	return [super.viewController webView:theWebView didFailLoadWithError:error];
 }
 
-
-- (BOOL) execute:(InvokedUrlCommand*)command
+- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
 {
-	return [ super execute:command];
+	return [super.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
 }
 
-- (void)dealloc
+- (void) dealloc
 {
-	[ super dealloc ];
+	[super dealloc];
 }
 
-@end
+@end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/Capture.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Capture.m b/PhoneGapLib/Classes/Capture.m
index 72e5dce..b577351 100644
--- a/PhoneGapLib/Classes/Capture.m
+++ b/PhoneGapLib/Classes/Capture.m
@@ -9,6 +9,7 @@
 #import "Capture.h"
 #import "JSONKit.h"
 #import "PhoneGapDelegate.h"
+#import "PGViewController.h"
 
 #define kW3CMediaFormatHeight @"height"
 #define kW3CMediaFormatWidth @"width"
@@ -338,12 +339,16 @@
     
     if (!mimeType){
         // try to determine mime type if not provided
-        PGFile* pgFile = [[self appDelegate] getCommandInstance: @"com.phonegap.file"];
-        mimeType = [pgFile getMimeTypeFromPath:fullPath];
-        if (!mimeType) {
-            // can't do much without mimeType, return error
-            bError = YES;
-            errorCode = CAPTURE_INVALID_ARGUMENT;
+        id command = [[self appDelegate].viewController getCommandInstance: @"com.phonegap.file"];
+        bError = !([command isKindOfClass:[PGFile class]]);
+        if (!bError) {
+            PGFile* pgFile = (PGFile*)command;
+            mimeType = [pgFile getMimeTypeFromPath:fullPath];
+            if (!mimeType) {
+                // can't do much without mimeType, return error
+                bError = YES;
+                errorCode = CAPTURE_INVALID_ARGUMENT;
+            }
         }
     }
     if (!bError) {
@@ -421,9 +426,12 @@
     [fileDict setObject: fullPath forKey:@"fullPath"];
     // determine type
     if(!type) {
-    PGFile* pgFile = [[self appDelegate] getCommandInstance: @"com.phonegap.file"];
-    NSString* mimeType = [pgFile getMimeTypeFromPath:fullPath];
-    [fileDict setObject: (mimeType != nil ? (NSObject*)mimeType : [NSNull null]) forKey:@"type"];
+        id command = [[self appDelegate].viewController getCommandInstance: @"com.phonegap.file"];
+        if([command isKindOfClass:[PGFile class]]) {
+            PGFile* pgFile = (PGFile*)command;
+            NSString* mimeType = [pgFile getMimeTypeFromPath:fullPath];
+            [fileDict setObject: (mimeType != nil ? (NSObject*)mimeType : [NSNull null]) forKey:@"type"];
+        }
     }
         NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:nil];
     [fileDict setObject: [NSNumber numberWithUnsignedLongLong:[fileAttrs fileSize]] forKey:@"size"];

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/Location.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Location.m b/PhoneGapLib/Classes/Location.m
index a393fbd..9552438 100755
--- a/PhoneGapLib/Classes/Location.m
+++ b/PhoneGapLib/Classes/Location.m
@@ -7,7 +7,7 @@
 
 
 #import "Location.h"
-#import "PhoneGapViewController.h"
+#import "PGViewController.h"
 #import "PhoneGapDelegate.h"
 
 #pragma mark Constants
@@ -362,9 +362,9 @@
         UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation];
         if (currentOrientation != UIDeviceOrientationUnknown) {
             PhoneGapDelegate* pgDelegate = [self appDelegate];
-            PhoneGapViewController* pgViewController = pgDelegate.viewController;
+            PGViewController* pgViewController = pgDelegate.viewController;
             
-            if ([[pgViewController supportedOrientations] containsObject:
+            if ([pgViewController.supportedOrientations containsObject:
                  [NSNumber numberWithInt:currentOrientation]]) {
                 
                 self.locationManager.headingOrientation = (CLDeviceOrientation)currentOrientation;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/PGURLProtocol.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGURLProtocol.m b/PhoneGapLib/Classes/PGURLProtocol.m
index c9cdb58..da46d65 100644
--- a/PhoneGapLib/Classes/PGURLProtocol.m
+++ b/PhoneGapLib/Classes/PGURLProtocol.m
@@ -8,7 +8,8 @@
 
 #import "PGURLProtocol.h"
 #import "PGWhitelist.h"
-#import  "PhoneGapDelegate.h"
+#import "PhoneGapDelegate.h"
+#import "PGViewController.h"
 
 static PGWhitelist* gWhitelist = nil;
 
@@ -30,7 +31,7 @@ static PGWhitelist* gWhitelist = nil;
     
     if (gWhitelist == nil) {
         PhoneGapDelegate* delegate = (PhoneGapDelegate*)[[UIApplication sharedApplication] delegate];
-        gWhitelist = [delegate.whitelist retain];
+        gWhitelist = [delegate.viewController.whitelist retain];
     }
     
     // we only care about http and https connections

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/PGViewController.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGViewController.h b/PhoneGapLib/Classes/PGViewController.h
index 5c41c35..565f8db 100644
--- a/PhoneGapLib/Classes/PGViewController.h
+++ b/PhoneGapLib/Classes/PGViewController.h
@@ -1,6 +1,5 @@
 //
-//  MainViewController.h
-//  Cleaver
+//  PGViewController.h
 //
 //  Created by Jesse MacFadyen on 11-12-08.
 //  Copyright 2011 Nitobi. All rights reserved.
@@ -15,21 +14,20 @@
 
 @interface PGViewController : UIViewController<UIWebViewDelegate> {
 	
-	IBOutlet UIGapView* webView;
 }
 
-@property (nonatomic, retain) UIGapView *webView;
+@property (nonatomic, retain) IBOutlet UIGapView* webView;
 
-@property (nonatomic, readonly, retain) IBOutlet UIActivityIndicatorView *activityView;
-@property (nonatomic, readonly, retain) UIImageView *imageView;
-@property (nonatomic, readonly, retain) NSMutableDictionary *pluginObjects;
-@property (nonatomic, readonly, retain) NSDictionary *pluginsMap;
-@property (nonatomic, readonly, retain) NSDictionary *settings;
+@property (nonatomic, readonly, retain) NSMutableDictionary* pluginObjects;
+@property (nonatomic, readonly, retain) NSDictionary* pluginsMap;
+@property (nonatomic, readonly, retain) NSDictionary* settings;
 @property (nonatomic, readonly, retain) PGWhitelist* whitelist; // readonly for public
+@property (nonatomic, readonly, retain) NSArray* supportedOrientations;
+@property (nonatomic, readonly, copy)   NSString* sessionKey;
 
-@property (nonatomic, retain) 	NSArray* supportedOrientations;
 
-+ (NSDictionary*)getBundlePlist:(NSString *)plistName;
+
++ (NSDictionary*) getBundlePlist:(NSString*)plistName;
 + (NSString*) wwwFolderName;
 + (NSString*) pathForResource:(NSString*)resourcepath;
 + (NSString*) phoneGapVersion;
@@ -37,10 +35,10 @@
 - (NSString*) startPage;
 
 
--(void)createGapView;
+- (void) createGapView;
 
-- (int)executeQueuedCommands;
-- (void)flushCommandQueue;
+- (int) executeQueuedCommands;
+- (void) flushCommandQueue;
 
 - (id) getCommandInstance:(NSString*)pluginName;
 - (void) javascriptAlert:(NSString*)text;
@@ -50,8 +48,6 @@
 
 - (NSArray*) parseInterfaceOrientations:(NSArray*)orientations;
 
-
-
 @end
 
 @interface NSDictionary (LowercaseKeys)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/PGViewController.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGViewController.m b/PhoneGapLib/Classes/PGViewController.m
index 48e51b1..e857bce 100644
--- a/PhoneGapLib/Classes/PGViewController.m
+++ b/PhoneGapLib/Classes/PGViewController.m
@@ -1,6 +1,5 @@
 //
-//  MainViewController.m
-//  Cleaver
+//  PGViewController.m
 //
 //  Created by Jesse MacFadyen on 11-12-08.
 //  Copyright 2011 Nitobi. All rights reserved.
@@ -8,16 +7,20 @@
 
 #import "PGViewController.h"
 #import "PGPlugin.h"
+#import "Location.h"
+#import "Connection.h"
 
 #define SYMBOL_TO_NSSTRING_HELPER(x) @#x
 #define SYMBOL_TO_NSSTRING(x) SYMBOL_TO_NSSTRING_HELPER(x)
 
 @interface PGViewController ()
 
-@property (nonatomic, readwrite, retain) NSDictionary *settings;
+@property (nonatomic, readwrite, retain) NSDictionary* settings;
 @property (nonatomic, readwrite, retain) PGWhitelist* whitelist; 
-@property (nonatomic, readwrite, retain) NSMutableDictionary *pluginObjects;
-@property (nonatomic, readwrite, retain) NSDictionary *pluginsMap;
+@property (nonatomic, readwrite, retain) NSMutableDictionary* pluginObjects;
+@property (nonatomic, readwrite, retain) NSDictionary* pluginsMap;
+@property (nonatomic, readwrite, retain) NSArray* supportedOrientations;
+@property (nonatomic, readwrite, copy)   NSString* sessionKey;
 
 @end
 
@@ -26,15 +29,16 @@
 
 @synthesize webView, supportedOrientations;
 @synthesize pluginObjects, pluginsMap, whitelist;
-@synthesize activityView, imageView, settings;
-
-
-
+@synthesize settings, sessionKey;
 
 
 // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
-- (void)viewDidLoad 
+- (void) viewDidLoad 
 {
+    if (self.sessionKey == nil) {
+        self.sessionKey = [NSString stringWithFormat:@"%d", arc4random()];
+    }
+    
     [super viewDidLoad];
 	
     self.pluginObjects = [[[NSMutableDictionary alloc] initWithCapacity:4] autorelease];
@@ -63,22 +67,65 @@
     // set the whitelist
     self.whitelist = [[[PGWhitelist alloc] initWithArray:[self.settings objectForKey:@"ExternalHosts"]] autorelease];
 	
-    
-	
     self.pluginsMap = [pluginsDict dictionaryWithLowercaseKeys];
     
-	NSString* path = [PGViewController pathForResource:@"index.html"];
-	NSURL *appURL  = [NSURL fileURLWithPath:path];//[NSURL URLWithString:path];
-	//[NSURL fileURLWithPath:path];
-	
-	
-    NSURLRequest *appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestReloadRevalidatingCacheData timeoutInterval:20.0];
-	
-	[ self createGapView];
-	[ self.webView loadRequest:appReq];
+	NSString* path = [PGViewController pathForResource:[self startPage]];
+	NSURL* appURL  = [NSURL fileURLWithPath:path];
+    
+    ///////////////////
 
+    NSString* loadErr = nil;
+    
+    if(![appURL scheme]) {
+        NSString* startFilePath = [[self class] pathForResource:[self startPage]];
+        if (startFilePath == nil) {
+            loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.", [[self class] wwwFolderName], [self startPage]];
+            NSLog(@"%@", loadErr);
+            appURL = nil;
+        } else {
+            appURL = [NSURL fileURLWithPath:startFilePath];
+        }
+    }
+    
+    ///////////////////
+    
+    NSNumber* enableLocation       = [settings objectForKey:@"EnableLocation"];
+    NSString* enableViewportScale  = [settings objectForKey:@"EnableViewportScale"];
+    NSNumber* allowInlineMediaPlayback = [settings objectForKey:@"AllowInlineMediaPlayback"];
+    NSNumber* mediaPlaybackRequiresUserAction = [settings objectForKey:@"MediaPlaybackRequiresUserAction"];
+    
+    self.webView.scalesPageToFit = [enableViewportScale boolValue];
+    
+    /*
+     * Fire up the GPS Service right away as it takes a moment for data to come back.
+     */
+    if ([allowInlineMediaPlayback boolValue] && [self.webView respondsToSelector:@selector(allowsInlineMediaPlayback)]) {
+        self.webView.allowsInlineMediaPlayback = YES;
+    }
+    if ([mediaPlaybackRequiresUserAction boolValue] && [self.webView respondsToSelector:@selector(mediaPlaybackRequiresUserAction)]) {
+        self.webView.mediaPlaybackRequiresUserAction = YES;
+    }
+    
+    /*
+     * This is for iOS 4.x, where you can allow inline <video> and <audio>, and also autoplay them
+     */
+    if ([enableLocation boolValue]) {
+        [[self getCommandInstance:@"com.phonegap.geolocation"] startLocation:nil withDict:nil];
+    }
+    
+    ///////////////////
+    
+    [ self createGapView];
+    
+    if (!loadErr) {
+        NSURLRequest *appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
+        [self.webView loadRequest:appReq];
+    } else {
+        NSString* html = [NSString stringWithFormat:@"<html><body> %@ </body></html>", loadErr];
+        [self.webView loadHTMLString:html baseURL:nil];
+    }
+    
 	//[self loadingStart];
-
 }
 
 - (NSArray*) parseInterfaceOrientations:(NSArray*)orientations
@@ -112,7 +159,7 @@
     return result;
 }
 
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation 
+- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
 {
 	// First ask the webview via JS if it wants to support the new orientation -jm
 	int i = 0;
@@ -159,28 +206,25 @@
 }
 
 
--(void)createGapView
+- (void) createGapView
 {
     CGRect webViewBounds = self.view.bounds;
     webViewBounds.origin = self.view.bounds.origin;
 	
-    if (!webView) 
+    if (!self.webView) 
 	{
-        webView = [[ [ UIGapView alloc ] initWithFrame:webViewBounds] autorelease];
-		webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
-		webView.scalesPageToFit = YES;//[enableViewportScale boolValue];
+        self.webView = [[ [ UIGapView alloc ] initWithFrame:webViewBounds] autorelease];
+		self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
+		self.webView.scalesPageToFit = YES;//[enableViewportScale boolValue];
 		
-		[ self.view addSubview:webView];
-		[ self.view sendSubviewToBack:webView];
+		[self.view addSubview:self.webView];
+		[self.view sendSubviewToBack:self.webView];
 		
-		webView.delegate = self;
+		self.webView.delegate = self;
     }
-
-	
 }
 
-
-- (void)didReceiveMemoryWarning {
+- (void) didReceiveMemoryWarning {
 	// Releases the view if it doesn't have a superview.
     [super didReceiveMemoryWarning];
 	
@@ -188,7 +232,7 @@
 }
 
 
-- (void)viewDidUnload {
+- (void) viewDidUnload {
 	// Release any retained subviews of the main view.
 	// e.g. self.myOutlet = nil;
 }
@@ -200,7 +244,7 @@
  When web application loads Add stuff to the DOM, mainly the user-defined settings from the Settings.plist file, and
  the device's data such as device ID, platform version, etc.
  */
-- (void)webViewDidStartLoad:(UIWebView *)theWebView 
+- (void) webViewDidStartLoad:(UIWebView*)theWebView 
 {
     
 }
@@ -208,10 +252,10 @@
 /**
  Called when the webview finishes loading.  This stops the activity view and closes the imageview
  */
-- (void)webViewDidFinishLoad:(UIWebView *)theWebView 
+- (void) webViewDidFinishLoad:(UIWebView*)theWebView 
 {
     // Share session key with the WebView by setting PhoneGap.sessionKey
-    NSString *sessionKeyScript = [NSString stringWithFormat:@"PhoneGap.sessionKey = \"%@\";", @"bobbyDallas"];//]self.sessionKey];
+    NSString *sessionKeyScript = [NSString stringWithFormat:@"PhoneGap.sessionKey = \"%@\";", self.sessionKey];
     [theWebView stringByEvaluatingJavaScriptFromString:sessionKeyScript];
 	
     
@@ -249,7 +293,8 @@
 //    [self.viewController didRotateFromInterfaceOrientation:(UIInterfaceOrientation)[[UIDevice currentDevice] orientation]];
 }
 
-- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
+- (void) webView:(UIWebView*)webView didFailLoadWithError:(NSError*)error 
+{
     NSLog(@"Failed to load webpage with error: %@", [error localizedDescription]);
     /*
 	 if ([error code] != NSURLErrorCancelled)
@@ -257,9 +302,9 @@
      */
 }
 
-- (BOOL)webView:(UIWebView *)_webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
+- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
 {
-	NSURL *url = [request URL];
+	NSURL* url = [request URL];
     
     /*
      * Execute any commands queued with PhoneGap.exec() on the JS side.
@@ -276,34 +321,34 @@
     {
         return YES;
     }
-//    else if ([self.whitelist schemeIsAllowed:[url scheme]])
-//    {            
-//        if ([self.whitelist URLIsAllowed:url] == YES)
-//        {
-//            NSNumber *openAllInWhitelistSetting = [self.settings objectForKey:@"OpenAllWhitelistURLsInWebView"];
-//            if ((nil != openAllInWhitelistSetting) && [openAllInWhitelistSetting boolValue]) {
-//                NSLog(@"OpenAllWhitelistURLsInWebView set: opening in webview");
-//                return YES;
-//            }
-//			
-//            // mainDocument will be nil for an iFrame
-//            NSString* mainDocument = [_webView.request.mainDocumentURL absoluteString];
-//			
-//            // anchor target="_blank" - load in Mobile Safari
-//            if (navigationType == UIWebViewNavigationTypeOther && mainDocument != nil)
-//            {
-//                [[UIApplication sharedApplication] openURL:url];
-//                return NO;
-//            }
-//            // other anchor target - load in PhoneGap webView
-//            else
-//            {
-//                return YES;
-//            }
-//        }
-//        
-//        return NO;
-//    }
+    else if ([self.whitelist schemeIsAllowed:[url scheme]])
+    {            
+        if ([self.whitelist URLIsAllowed:url] == YES)
+        {
+            NSNumber *openAllInWhitelistSetting = [self.settings objectForKey:@"OpenAllWhitelistURLsInWebView"];
+            if ((nil != openAllInWhitelistSetting) && [openAllInWhitelistSetting boolValue]) {
+                NSLog(@"OpenAllWhitelistURLsInWebView set: opening in webview");
+                return YES;
+            }
+			
+            // mainDocument will be nil for an iFrame
+            NSString* mainDocument = [theWebView.request.mainDocumentURL absoluteString];
+			
+            // anchor target="_blank" - load in Mobile Safari
+            if (navigationType == UIWebViewNavigationTypeOther && mainDocument != nil)
+            {
+                [[UIApplication sharedApplication] openURL:url];
+                return NO;
+            }
+            // other anchor target - load in PhoneGap webView
+            else
+            {
+                return YES;
+            }
+        }
+        
+        return NO;
+    }
     /*
      *    If we loaded the HTML from a string, we let the app handle it
      */
@@ -332,19 +377,18 @@
      */
     else
     {
-//        NSLog(@"PhoneGapDelegate::shouldStartLoadWithRequest: Received Unhandled URL %@", url);
-//		
-//        if ([[UIApplication sharedApplication] canOpenURL:url]) {
-//            [[UIApplication sharedApplication] openURL:url];
-//        } else { // handle any custom schemes to plugins
-//            [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:PGPluginHandleOpenURLNotification object:url]];
-//        }
+        NSLog(@"PhoneGapDelegate::shouldStartLoadWithRequest: Received Unhandled URL %@", url);
+		
+        if ([[UIApplication sharedApplication] canOpenURL:url]) {
+            [[UIApplication sharedApplication] openURL:url];
+        } else { // handle any custom schemes to plugins
+            [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:PGPluginHandleOpenURLNotification object:url]];
+        }
 		
         return NO;
     }
     
     return YES;
-	
 }
 
 #pragma mark GapHelpers
@@ -355,7 +399,6 @@
     [webView stringByEvaluatingJavaScriptFromString:jsString];
 }
 
-/*Gap stuff*/
 + (NSString*) wwwFolderName
 {
     return @"www";
@@ -380,13 +423,11 @@
         directoryStr = [NSString stringWithFormat:@"%@/%@", [self wwwFolderName], [directoryParts componentsJoinedByString:@"/"]];
     }
     
-    return [mainBundle pathForResource:filename
-								ofType:@""
-						   inDirectory:directoryStr];
+    return [mainBundle pathForResource:filename ofType:@"" inDirectory:directoryStr];
 }
 
-+ (NSString*) applicationDocumentsDirectory {
-    
++ (NSString*) applicationDocumentsDirectory 
+{
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
     NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
     return basePath;
@@ -401,7 +442,7 @@
  *
  * Returns the number of executed commands.
  */
-- (int)executeQueuedCommands
+- (int) executeQueuedCommands
 {
     // Grab all the queued commands from the JS side.
     NSString* queuedCommandsJSON = [self.webView stringByEvaluatingJavaScriptFromString:
@@ -430,7 +471,7 @@
 /**
  * Repeatedly fetches and executes the command queue until it is empty.
  */
-- (void)flushCommandQueue
+- (void) flushCommandQueue
 {
     [self.webView stringByEvaluatingJavaScriptFromString:
 	 @"PhoneGap.commandQueueFlushing = true"];
@@ -474,13 +515,12 @@
     [fullMethodName release];
     
     return retVal;
-
 }
 
 /**
  Returns an instance of a PhoneGapCommand object, based on its name.  If one exists already, it is returned.
  */
--(id) getCommandInstance:(NSString*)pluginName
+- (id) getCommandInstance:(NSString*)pluginName
 {
     // first, we try to find the pluginName in the pluginsMap 
     // (acts as a whitelist as well) if it does not exist, we return nil
@@ -525,17 +565,17 @@
     [devProps setObject:[device systemVersion] forKey:@"version"];
     [devProps setObject:[device uniqueIdentifier] forKey:@"uuid"];
     [devProps setObject:[device name] forKey:@"name"];
-//    [devProps setObject:[[self class] phoneGapVersion ] forKey:@"gap"];
-//    
-//    id cmd = [self getCommandInstance:@"com.phonegap.connection"];
-//    if (cmd && [cmd isKindOfClass:[PGConnection class]]) 
-//    {
-//        NSMutableDictionary *connProps = [NSMutableDictionary dictionaryWithCapacity:3];
-//        if ([cmd respondsToSelector:@selector(connectionType)]) {
-//            [connProps setObject:[cmd connectionType] forKey:@"type"];
-//        }
-//        [devProps setObject:connProps forKey:@"connection"];
-//    }
+    [devProps setObject:[[self class] phoneGapVersion ] forKey:@"gap"];
+    
+    id cmd = [self getCommandInstance:@"com.phonegap.connection"];
+    if (cmd && [cmd isKindOfClass:[PGConnection class]]) 
+    {
+        NSMutableDictionary *connProps = [NSMutableDictionary dictionaryWithCapacity:3];
+        if ([cmd respondsToSelector:@selector(connectionType)]) {
+            [connProps setObject:[cmd connectionType] forKey:@"type"];
+        }
+        [devProps setObject:connProps forKey:@"connection"];
+    }
     
     NSDictionary *devReturn = [NSDictionary dictionaryWithDictionary:devProps];
     return devReturn;
@@ -564,7 +604,7 @@
 /**
  Returns the contents of the named plist bundle, loaded as a dictionary object
  */
-+ (NSDictionary*)getBundlePlist:(NSString *)plistName
++ (NSDictionary*) getBundlePlist:(NSString*)plistName
 {
     NSString *errorDesc = nil;
     NSPropertyListFormat format;
@@ -604,11 +644,26 @@ static NSString *gapVersion;
     return gapVersion;
 }
 
-
-
 - (void)dealloc {
     [super dealloc];
 }
 
+@end
+
+#pragma mark -
+
+@implementation NSDictionary (LowercaseKeys)
+
+- (NSDictionary*) dictionaryWithLowercaseKeys 
+{
+    NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:self.count];
+    NSString* key;
+    
+    for (key in self) {
+        [result setObject:[self objectForKey:key] forKey:[key lowercaseString]];
+    }
+    
+    return result;
+}
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/PhoneGapDelegate.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PhoneGapDelegate.h b/PhoneGapLib/Classes/PhoneGapDelegate.h
index eb1e837..194bd37 100644
--- a/PhoneGapLib/Classes/PhoneGapDelegate.h
+++ b/PhoneGapLib/Classes/PhoneGapDelegate.h
@@ -9,42 +9,16 @@
 #import <UIKit/UIKit.h>
 #import "JSONKit.h"
 
-@class InvokedUrlCommand;
-@class PhoneGapViewController;
-@class Sound;
-@class Contacts;
-@class Console;
-@class PGWhitelist;
+@class PGViewController;
 
 @interface PhoneGapDelegate : NSObject <UIApplicationDelegate, UIWebViewDelegate>
 {
 }
 
-@property (nonatomic, readwrite, retain) IBOutlet UIWindow *window;
-@property (nonatomic, readwrite, retain) IBOutlet UIWebView *webView;
-@property (nonatomic, readonly, retain) IBOutlet PhoneGapViewController *viewController;
-@property (nonatomic, readonly, retain) IBOutlet UIActivityIndicatorView *activityView;
+@property (nonatomic, readwrite, retain) IBOutlet UIWindow* window;
+@property (nonatomic, readonly, retain) IBOutlet PGViewController* viewController;
+@property (nonatomic, readonly, retain) IBOutlet UIActivityIndicatorView* activityView;
 @property (nonatomic, readonly, retain) UIImageView *imageView;
-@property (nonatomic, readonly, retain) NSMutableDictionary *pluginObjects;
-@property (nonatomic, readonly, retain) NSDictionary *pluginsMap;
-@property (nonatomic, readonly, retain) NSDictionary *settings;
-@property (nonatomic, readonly, retain) PGWhitelist* whitelist; // readonly for public
-
-+ (NSDictionary*)getBundlePlist:(NSString *)plistName;
-+ (NSString*) wwwFolderName;
-+ (NSString*) pathForResource:(NSString*)resourcepath;
-+ (NSString*) phoneGapVersion;
-+ (NSString*) applicationDocumentsDirectory;
-+ (NSString*) startPage;
-
-- (int)executeQueuedCommands;
-- (void)flushCommandQueue;
-
-- (id) getCommandInstance:(NSString*)pluginName;
-- (void) javascriptAlert:(NSString*)text;
-- (BOOL) execute:(InvokedUrlCommand*)command;
-- (NSString*) appURLScheme;
-- (NSDictionary*) deviceProperties;
 
 - (void)applicationDidEnterBackground:(UIApplication *)application;
 - (void)applicationWillEnterForeground:(UIApplication *)application;
@@ -53,9 +27,3 @@
 
 @end
 
-@interface NSDictionary (LowercaseKeys)
-
-- (NSDictionary*) dictionaryWithLowercaseKeys;
-
-@end
-

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/PhoneGapDelegate.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PhoneGapDelegate.m b/PhoneGapLib/Classes/PhoneGapDelegate.m
index 52d6262..6e7c163 100644
--- a/PhoneGapLib/Classes/PhoneGapDelegate.m
+++ b/PhoneGapLib/Classes/PhoneGapDelegate.m
@@ -18,12 +18,9 @@
 #import "PGWhitelist.h"
 #import "InvokedUrlCommand.h"
 #import "PhoneGapDelegate.h"
-#import "PhoneGapViewController.h"
+#import "PGViewController.h"
 #import "PGPlugin.h"
 
-#define SYMBOL_TO_NSSTRING_HELPER(x) @#x
-#define SYMBOL_TO_NSSTRING(x) SYMBOL_TO_NSSTRING_HELPER(x)
-
 #define degreesToRadian(x) (M_PI * (x) / 180.0)
 
 // class extension
@@ -31,43 +28,25 @@
 
 // readwrite access for self
 
-@property (nonatomic, readwrite, retain) IBOutlet PhoneGapViewController *viewController;
-@property (nonatomic, readwrite, retain) IBOutlet UIActivityIndicatorView *activityView;
-@property (nonatomic, readwrite, retain) UIImageView *imageView;
-@property (nonatomic, readwrite, retain) NSMutableDictionary *pluginObjects;
-@property (nonatomic, readwrite, retain) NSDictionary *pluginsMap;
-@property (nonatomic, readwrite, retain) NSDictionary *settings;
-@property (nonatomic, readwrite, retain) NSURL *invokedURL;
-@property (readwrite, assign) BOOL loadFromString;
-@property (readwrite, assign) UIInterfaceOrientation orientationType;
-
-@property (nonatomic, readwrite, retain) NSString *sessionKey; 
-@property (nonatomic, readwrite, retain) PGWhitelist* whitelist; 
+@property (nonatomic, readwrite, retain) IBOutlet PGViewController* viewController;
+@property (nonatomic, readwrite, retain) IBOutlet UIActivityIndicatorView* activityView;
+@property (nonatomic, readwrite, retain) UIImageView* imageView;
 
 @end
 
 
 @implementation PhoneGapDelegate
 
-@synthesize window, webView, viewController, activityView, imageView;
-@synthesize settings, invokedURL, loadFromString, orientationType, sessionKey;
-@synthesize pluginObjects, pluginsMap, whitelist;
+@synthesize window, viewController, imageView, activityView;
 
 - (id) init
 {
     self = [super init];
     if (self != nil) {
-        self.pluginObjects = [[[NSMutableDictionary alloc] initWithCapacity:4] autorelease];
-        self.imageView = nil;
-        
         // Turn on cookie support ( shared with our app only! )
         NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 
         [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
         
-        // Create the sessionKey to use throughout the lifetime of the application
-        // to authenticate the source of the gap calls
-        self.sessionKey = [NSString stringWithFormat:@"%d", arc4random()];
-        
         [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedOrientationChange) name:UIDeviceOrientationDidChangeNotification
                                                    object:nil];
@@ -77,24 +56,6 @@
     return self; 
 }
 
-+ (NSString*) applicationDocumentsDirectory {
-    
-    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
-    NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
-    return basePath;
-}
-
-
-+ (NSString*) wwwFolderName
-{
-    return @"www";
-}
-
-+ (NSString*) startPage
-{
-    return @"index.html";
-}
-
 + (BOOL) isIPad 
 {
 #ifdef UI_USER_INTERFACE_IDIOM
@@ -122,122 +83,6 @@
     return resource;
 }
 
-
-+ (NSString*) pathForResource:(NSString*)resourcepath
-{
-    NSBundle * mainBundle = [NSBundle mainBundle];
-    NSMutableArray *directoryParts = [NSMutableArray arrayWithArray:[resourcepath componentsSeparatedByString:@"/"]];
-    NSString       *filename       = [directoryParts lastObject];
-    [directoryParts removeLastObject];
-    
-    NSString* directoryPartsJoined =[directoryParts componentsJoinedByString:@"/"];
-    NSString* directoryStr = [self wwwFolderName];
-    
-    if ([directoryPartsJoined length] > 0) {
-        directoryStr = [NSString stringWithFormat:@"%@/%@", [self wwwFolderName], [directoryParts componentsJoinedByString:@"/"]];
-    }
-    
-    return [mainBundle pathForResource:filename
-                       ofType:@""
-                       inDirectory:directoryStr];
-}
-
-/**
-Returns the current version of phoneGap as read from the VERSION file
-This only touches the filesystem once and stores the result in the class variable gapVersion
-*/
-static NSString *gapVersion;
-+ (NSString*) phoneGapVersion
-{
-#ifdef PG_VERSION
-    gapVersion = SYMBOL_TO_NSSTRING(PG_VERSION);
-#else
-
-    if (gapVersion == nil) {
-        NSBundle *mainBundle = [NSBundle mainBundle];
-        NSString *filename = [mainBundle pathForResource:@"VERSION" ofType:nil];
-        // read from the filesystem and save in the variable
-        // first, separate by new line
-        NSString* fileContents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:NULL];
-        NSArray* all_lines = [fileContents componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
-        NSString* first_line = [all_lines objectAtIndex:0];        
-        
-        gapVersion = [first_line retain];
-    }
-#endif
-    
-    return gapVersion;
-}
-
-
-/**
- Returns an instance of a PhoneGapCommand object, based on its name.  If one exists already, it is returned.
- */
--(id) getCommandInstance:(NSString*)pluginName
-{
-    // first, we try to find the pluginName in the pluginsMap 
-    // (acts as a whitelist as well) if it does not exist, we return nil
-    // NOTE: plugin names are matched as lowercase to avoid problems - however, a 
-    // possible issue is there can be duplicates possible if you had:
-    // "com.phonegap.Foo" and "com.phonegap.foo" - only the lower-cased entry will match
-    NSString* className = [self.pluginsMap objectForKey:[pluginName lowercaseString]];
-    if (className == nil) {
-        return nil;
-    }
-    
-    id obj = [self.pluginObjects objectForKey:className];
-    if (!obj) 
-    {
-        // attempt to load the settings for this command class
-        NSDictionary* classSettings = [self.settings objectForKey:className];
-
-        if (classSettings) {
-            obj = [[NSClassFromString(className) alloc] initWithWebView:webView settings:classSettings];
-        } else {
-            obj = [[NSClassFromString(className) alloc] initWithWebView:webView];
-        }
-        
-        if (obj != nil) {
-            [self.pluginObjects setObject:obj forKey:className];
-            [obj release];
-        } else {
-            NSLog(@"PGPlugin class %@ (pluginName: %@) does not exist.", className, pluginName);
-        }
-    }
-    return obj;
-}
-
-- (NSArray*) parseInterfaceOrientations:(NSArray*)orientations
-{
-    NSMutableArray* result = [[[NSMutableArray alloc] init] autorelease];
-
-    if (orientations != nil) 
-    {
-        NSEnumerator* enumerator = [orientations objectEnumerator];
-        NSString* orientationString;
-        
-        while (orientationString = [enumerator nextObject]) 
-        {
-            if ([orientationString isEqualToString:@"UIInterfaceOrientationPortrait"]) {
-                [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortrait]];
-            } else if ([orientationString isEqualToString:@"UIInterfaceOrientationPortraitUpsideDown"]) {
-                [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortraitUpsideDown]];
-            } else if ([orientationString isEqualToString:@"UIInterfaceOrientationLandscapeLeft"]) {
-                [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeLeft]];
-            } else if ([orientationString isEqualToString:@"UIInterfaceOrientationLandscapeRight"]) {
-                [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight]];
-            }
-        }
-    }
-    
-    // default
-    if ([result count] == 0) {
-        [result addObject:[NSNumber numberWithInt:UIInterfaceOrientationPortrait]];
-    }
-    
-    return result;
-}
-
 - (void) showSplashScreen
 {
     NSString* launchImageFile = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UILaunchImageFile"];
@@ -317,7 +162,7 @@ static NSString *gapVersion;
      *     gray       = UIActivityIndicatorViewStyleGray
      *
      */
-    NSString *topActivityIndicator = [self.settings objectForKey:@"TopActivityIndicator"];
+    NSString *topActivityIndicator = [self.viewController.settings objectForKey:@"TopActivityIndicator"];
     UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleGray;
     
     if ([topActivityIndicator isEqualToString:@"whiteLarge"]) {
@@ -331,7 +176,7 @@ static NSString *gapVersion;
     self.activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:topActivityIndicatorStyle] autorelease];
     self.activityView.tag = 2;
 
-    id showSplashScreenSpinnerValue = [self.settings objectForKey:@"ShowSplashScreenSpinner"];
+    id showSplashScreenSpinnerValue = [self.viewController.settings objectForKey:@"ShowSplashScreenSpinner"];
     // backwards compatibility - if key is missing, default to true
     if (showSplashScreenSpinnerValue == nil || [showSplashScreenSpinnerValue boolValue]) {
         [self.window addSubview:self.activityView];
@@ -340,8 +185,7 @@ static NSString *gapVersion;
     self.activityView.center = self.viewController.view.center;
     [self.activityView startAnimating];
     
-    
-    [self.window layoutSubviews];//asking window to do layout AFTER imageView is created refer to line: 250     self.window.autoresizesSubviews = YES;
+    [self.window layoutSubviews];
 }    
 
 BOOL gSplashScreenShown = NO;
@@ -349,63 +193,35 @@ BOOL gSplashScreenShown = NO;
 {
     if (self.imageView == nil) {
         gSplashScreenShown = YES;
-        [self showSplashScreen];
+        //[self showSplashScreen];
     }
 }
 
 /**
  * This is main kick off after the app inits, the views and Settings are setup here.
  */
-// - (void)applicationDidFinishLaunching:(UIApplication *)application
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
 {    
-    // read from UISupportedInterfaceOrientations (or UISupportedInterfaceOrientations~iPad, if its iPad) from -Info.plist
-    NSArray* supportedOrientations = [self parseInterfaceOrientations:
-                                               [[[NSBundle mainBundle] infoDictionary] objectForKey:@"UISupportedInterfaceOrientations"]];
-    
-    // read from PhoneGap.plist in the app bundle
-    NSString* appPlistName = @"PhoneGap";
-    NSDictionary* phonegapPlist = [[self class] getBundlePlist:appPlistName];
-    if (phonegapPlist == nil) {
-        NSLog(@"WARNING: %@.plist is missing.", appPlistName);
-        return NO;
-    }
-    self.settings = [[[NSDictionary alloc] initWithDictionary:phonegapPlist] autorelease];
-
-    // read from Plugins dict in PhoneGap.plist in the app bundle
-    NSString* pluginsKey = @"Plugins";
-    NSDictionary* pluginsDict = [self.settings objectForKey:@"Plugins"];
-    if (pluginsDict == nil) {
-        NSLog(@"WARNING: %@ key in %@.plist is missing! PhoneGap will not work, you need to have this key.", pluginsKey, appPlistName);
-        return NO;
-    }
-    
-    // set the whitelist
-    self.whitelist = [[[PGWhitelist alloc] initWithArray:[self.settings objectForKey:@"ExternalHosts"]] autorelease];
-    
-    self.pluginsMap = [pluginsDict dictionaryWithLowercaseKeys];
-    
-    self.viewController = [[[PhoneGapViewController alloc] init] autorelease];
-    
-    NSNumber *enableLocation       = [self.settings objectForKey:@"EnableLocation"];
-    NSString *enableViewportScale  = [self.settings objectForKey:@"EnableViewportScale"];
-    NSNumber *allowInlineMediaPlayback = [self.settings objectForKey:@"AllowInlineMediaPlayback"];
-    NSNumber *mediaPlaybackRequiresUserAction = [self.settings objectForKey:@"MediaPlaybackRequiresUserAction"];
+    CGRect screenBounds = [ [ UIScreen mainScreen ] bounds ];
+    self.window = [ [ [ UIWindow alloc ] initWithFrame:screenBounds ] autorelease ];
+    self.window.autoresizesSubviews = YES;
     
-    // Set the supported orientations for rotation. If number of items in the array is > 1, autorotate is supported
-    viewController.supportedOrientations = supportedOrientations;
+    CGRect viewBounds = [[UIScreen mainScreen] applicationFrame];
+    viewBounds.origin = screenBounds.origin;
+    self.viewController = [[[PGViewController alloc] init] autorelease];
+    self.viewController.view.bounds = viewBounds;
     
-    //check whether the current orientation is supported: if it is, keep it, rather than forcing a rotation
+    // check whether the current orientation is supported: if it is, keep it, rather than forcing a rotation
     BOOL forceStartupRotation = YES;
     UIDeviceOrientation curDevOrientation = [[UIDevice currentDevice] orientation];
 
     if (UIDeviceOrientationUnknown == curDevOrientation) {
-        //UIDevice isn't firing orientation notifications yet...go look at status bar
+        // UIDevice isn't firing orientation notifications yet… go look at the status bar
         curDevOrientation = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
     }
 
     if (UIDeviceOrientationIsValidInterfaceOrientation(curDevOrientation)) {
-        for (NSNumber *orient in supportedOrientations) {
+        for (NSNumber *orient in self.viewController.supportedOrientations) {
             if ([orient intValue] == curDevOrientation) {
                 forceStartupRotation = NO;
                 break;
@@ -414,126 +230,19 @@ BOOL gSplashScreenShown = NO;
     } 
     
     if (forceStartupRotation) {
-        NSLog(@"supportedOrientations: %@",supportedOrientations);
+        NSLog(@"supportedOrientations: %@", self.viewController.supportedOrientations);
         // The first item in the supportedOrientations array is the start orientation (guaranteed to be at least Portrait)
-        UIInterfaceOrientation newOrient = [[supportedOrientations objectAtIndex:0] intValue];
+        UIInterfaceOrientation newOrient = [[self.viewController.supportedOrientations objectAtIndex:0] intValue];
         NSLog(@"PhoneGapDelegate forcing status bar to: %d from: %d",newOrient,curDevOrientation);
         [[UIApplication sharedApplication] setStatusBarOrientation:newOrient];
     }
     
-    CGRect screenBounds = [ [ UIScreen mainScreen ] bounds ];
-    self.window = [ [ [ UIWindow alloc ] initWithFrame:screenBounds ] autorelease ];
-
-
-    self.window.autoresizesSubviews = YES;
-    CGRect webViewBounds = [ [ UIScreen mainScreen ] applicationFrame ] ;
-    webViewBounds.origin = screenBounds.origin;
-    if (!self.webView) {
-        self.webView = [[ [ UIWebView alloc ] initWithFrame:webViewBounds] autorelease];
-    }
-    self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
-    self.webView.scalesPageToFit = [enableViewportScale boolValue];
-    
-    viewController.webView = self.webView;
-    [self.viewController.view addSubview:self.webView];
-    
-        
-    /*
-     * Fire up the GPS Service right away as it takes a moment for data to come back.
-     */
-    if ([allowInlineMediaPlayback boolValue] && [self.webView respondsToSelector:@selector(allowsInlineMediaPlayback)]) {
-        self.webView.allowsInlineMediaPlayback = YES;
-    }
-    if ([mediaPlaybackRequiresUserAction boolValue] && [self.webView respondsToSelector:@selector(mediaPlaybackRequiresUserAction)]) {
-        self.webView.mediaPlaybackRequiresUserAction = YES;
-    }
-
-    /*
-     * This is for iOS 4.x, where you can allow inline <video> and <audio>, and also autoplay them
-     */
-    if ([enableLocation boolValue]) {
-        [[self getCommandInstance:@"com.phonegap.geolocation"] startLocation:nil withDict:nil];
-    }
-    
-
-    self.webView.delegate = self;
-
     [self.window addSubview:self.viewController.view];
-
-    /*
-     * webView
-     * This is where we define the inital instance of the browser (WebKit) and give it a starting url/file.
-     */
-    
-    NSString* startPage = [[self class] startPage];
-    NSURL *appURL = [NSURL URLWithString:startPage];
-    NSString* loadErr = nil;
-    
-    if(![appURL scheme])
-    {
-        NSString* startFilePath = [[self class] pathForResource:startPage];
-        if (startFilePath == nil)
-        {
-            loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.", [[self class] wwwFolderName], startPage];
-            NSLog(@"%@", loadErr);
-            appURL = nil;
-        }
-        else {
-            appURL = [NSURL fileURLWithPath:startFilePath];
-        }
-    }
-    
-    if (!loadErr) {
-        NSURLRequest *appReq = [NSURLRequest requestWithURL:appURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
-        [self.webView loadRequest:appReq];
-    } else {
-        NSString* html = [NSString stringWithFormat:@"<html><body> %@ </body></html>", loadErr];
-        [self.webView loadHTMLString:html baseURL:nil];
-        self.loadFromString = YES;
-    }
-
     [self.window makeKeyAndVisible];
     
-    if (self.loadFromString) {
-        self.imageView.hidden = YES;
-    }
-    
     return YES;
 }
 
-/**
- When web application loads Add stuff to the DOM, mainly the user-defined settings from the Settings.plist file, and
- the device's data such as device ID, platform version, etc.
- */
-- (void)webViewDidStartLoad:(UIWebView *)theWebView 
-{
-    
-}
-
-- (NSDictionary*) deviceProperties
-{
-    UIDevice *device = [UIDevice currentDevice];
-    NSMutableDictionary *devProps = [NSMutableDictionary dictionaryWithCapacity:4];
-    [devProps setObject:[device model] forKey:@"platform"];
-    [devProps setObject:[device systemVersion] forKey:@"version"];
-    [devProps setObject:[device uniqueIdentifier] forKey:@"uuid"];
-    [devProps setObject:[device name] forKey:@"name"];
-    [devProps setObject:[[self class] phoneGapVersion ] forKey:@"gap"];
-    
-    id cmd = [self getCommandInstance:@"com.phonegap.connection"];
-    if (cmd && [cmd isKindOfClass:[PGConnection class]]) 
-    {
-        NSMutableDictionary *connProps = [NSMutableDictionary dictionaryWithCapacity:3];
-        if ([cmd respondsToSelector:@selector(connectionType)]) {
-            [connProps setObject:[cmd connectionType] forKey:@"type"];
-        }
-        [devProps setObject:connProps forKey:@"connection"];
-    }
-    
-    NSDictionary *devReturn = [NSDictionary dictionaryWithDictionary:devProps];
-    return devReturn;
-}
-
 - (NSString*) appURLScheme
 {
     NSString* URLScheme = nil;
@@ -552,260 +261,6 @@ BOOL gSplashScreenShown = NO;
     return URLScheme;
 }
 
-- (void) javascriptAlert:(NSString*)text
-{
-    NSString* jsString = [NSString stringWithFormat:@"alert('%@');", text];
-    [webView stringByEvaluatingJavaScriptFromString:jsString];
-}
-
-/**
- Returns the contents of the named plist bundle, loaded as a dictionary object
- */
-+ (NSDictionary*)getBundlePlist:(NSString *)plistName
-{
-    NSString *errorDesc = nil;
-    NSPropertyListFormat format;
-    NSString *plistPath = [[NSBundle mainBundle] pathForResource:plistName ofType:@"plist"];
-    NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
-    NSDictionary *temp = (NSDictionary *)[NSPropertyListSerialization
-                                          propertyListFromData:plistXML
-                                          mutabilityOption:NSPropertyListMutableContainersAndLeaves              
-                                          format:&format errorDescription:&errorDesc];
-    return temp;
-}
-
-/**
- Called when the webview finishes loading.  This stops the activity view and closes the imageview
- */
-- (void)webViewDidFinishLoad:(UIWebView *)theWebView 
-{
-
-    // Share session key with the WebView by setting PhoneGap.sessionKey
-    NSString *sessionKeyScript = [NSString stringWithFormat:@"PhoneGap.sessionKey = \"%@\";", self.sessionKey];
-    [theWebView stringByEvaluatingJavaScriptFromString:sessionKeyScript];
-
-    
-    NSDictionary *deviceProperties = [ self deviceProperties];
-    NSMutableString *result = [[NSMutableString alloc] initWithFormat:@"DeviceInfo = %@;", [deviceProperties JSONString]];
-    
-    /* Settings.plist
-     * Read the optional Settings.plist file and push these user-defined settings down into the web application.
-     * This can be useful for supplying build-time configuration variables down to the app to change its behaviour,
-     * such as specifying Full / Lite version, or localization (English vs German, for instance).
-     */
-    
-    NSDictionary *temp = [[self class] getBundlePlist:@"Settings"];
-    if ([temp respondsToSelector:@selector(JSONString)]) {
-        [result appendFormat:@"\nwindow.Settings = %@;", [temp JSONString]];
-    }
-    
-    NSLog(@"Device initialization: %@", result);
-    [theWebView stringByEvaluatingJavaScriptFromString:result];
-    [result release];
-    
-    /*
-     * Hide the Top Activity THROBBER in the Battery Bar
-     */
-    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
-
-    id autoHideSplashScreenValue = [self.settings objectForKey:@"AutoHideSplashScreen"];
-    // if value is missing, default to yes
-    if (autoHideSplashScreenValue == nil || [autoHideSplashScreenValue boolValue]) {
-        self.imageView.hidden = YES;
-        self.activityView.hidden = YES;    
-        [self.window bringSubviewToFront:self.viewController.view];
-    }
-    
-    [self.viewController didRotateFromInterfaceOrientation:(UIInterfaceOrientation)[[UIDevice currentDevice] orientation]];
-}
-
-
-/**
- * Fail Loading With Error
- * Error - If the webpage failed to load display an error with the reason.
- *
- */
-- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
-    NSLog(@"Failed to load webpage with error: %@", [error localizedDescription]);
-    /*
-    if ([error code] != NSURLErrorCancelled)
-        alert([error localizedDescription]);
-     */
-}
-
-/**
- * Fetches the command queue and executes each command. It is possible that the
- * queue will not be empty after this function has completed since the executed
- * commands may have run callbacks which queued more commands.
- *
- * Returns the number of executed commands.
- */
-- (int)executeQueuedCommands
-{
-    // Grab all the queued commands from the JS side.
-    NSString* queuedCommandsJSON =
-        [self.webView stringByEvaluatingJavaScriptFromString:
-        @"PhoneGap.getAndClearQueuedCommands()"];
-
-    // Parse the returned JSON array.
-    //PG_SBJsonParser* jsonParser = [[[PG_SBJsonParser alloc] init] autorelease];
-    NSArray* queuedCommands =
-        [queuedCommandsJSON objectFromJSONString];
-
-    // Iterate over and execute all of the commands.
-    for (NSString* commandJson in queuedCommands) {
-        [self execute:
-            [InvokedUrlCommand commandFromObject:
-                [commandJson mutableObjectFromJSONString]]];
-    }
-
-    return [queuedCommands count];
-}
-
-/**
- * Repeatedly fetches and executes the command queue until it is empty.
- */
-- (void)flushCommandQueue
-{
-    [self.webView stringByEvaluatingJavaScriptFromString:
-        @"PhoneGap.commandQueueFlushing = true"];
-
-    // Keep executing the command queue until no commands get executed.
-    // This ensures that commands that are queued while executing other
-    // commands are executed as well.
-    int numExecutedCommands = 0;
-    do {
-        numExecutedCommands = [self executeQueuedCommands];
-    } while (numExecutedCommands != 0);
-
-    [self.webView stringByEvaluatingJavaScriptFromString:
-        @"PhoneGap.commandQueueFlushing = false"];
-}
-
-/**
- * Start Loading Request
- * This is where most of the magic happens... We take the request(s) and process the response.
- * From here we can re direct links and other protocalls to different internal methods.
- *
- */
-- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
-{
-    NSURL *url = [request URL];
-    
-    /*
-     * Execute any commands queued with PhoneGap.exec() on the JS side.
-     * The part of the URL after gap:// is irrelevant.
-     */
-     if ([[url scheme] isEqualToString:@"gap"]) {
-        [self flushCommandQueue];
-        return NO;
-     }
-    /*
-     * If a URL is being loaded that's a file/http/https URL, just load it internally
-     */
-    else if ([url isFileURL])
-    {
-        return YES;
-    }
-    else if ([self.whitelist schemeIsAllowed:[url scheme]])
-    {            
-        if ([self.whitelist URLIsAllowed:url] == YES)
-        {
-            NSNumber *openAllInWhitelistSetting = [self.settings objectForKey:@"OpenAllWhitelistURLsInWebView"];
-            if ((nil != openAllInWhitelistSetting) && [openAllInWhitelistSetting boolValue]) {
-                NSLog(@"OpenAllWhitelistURLsInWebView set: opening in webview");
-                return YES;
-            }
-
-            // mainDocument will be nil for an iFrame
-            NSString* mainDocument = [webView.request.mainDocumentURL absoluteString];
-
-            // anchor target="_blank" - load in Mobile Safari
-            if (navigationType == UIWebViewNavigationTypeOther && mainDocument != nil)
-            {
-                [[UIApplication sharedApplication] openURL:url];
-                return NO;
-            }
-            // other anchor target - load in PhoneGap webView
-            else
-            {
-                return YES;
-            }
-        }
-        
-        return NO;
-    }
-    /*
-     *    If we loaded the HTML from a string, we let the app handle it
-     */
-    else if (self.loadFromString == YES)
-    {
-        self.loadFromString = NO;
-        return YES;
-    }
-    /*
-     * all tel: scheme urls we let the UIWebview handle it using the default behaviour
-     */
-    else if ([[url scheme] isEqualToString:@"tel"])
-    {
-        return YES;
-    }
-    /*
-     * all about: scheme urls are not handled
-     */
-    else if ([[url scheme] isEqualToString:@"about"])
-    {
-        return NO;
-    }
-    /*
-     * We don't have a PhoneGap or web/local request, load it in the main Safari browser.
-     * pass this to the application to handle.  Could be a mailto:dude@duderanch.com or a tel:55555555 or sms:55555555 facetime:55555555
-     */
-    else
-    {
-        NSLog(@"PhoneGapDelegate::shouldStartLoadWithRequest: Received Unhandled URL %@", url);
-
-        if ([[UIApplication sharedApplication] canOpenURL:url]) {
-            [[UIApplication sharedApplication] openURL:url];
-        } else { // handle any custom schemes to plugins
-            [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:PGPluginHandleOpenURLNotification object:url]];
-        }
-
-        return NO;
-    }
-    
-    return YES;
-}
-
-- (BOOL) execute:(InvokedUrlCommand*)command
-{
-    if (command.className == nil || command.methodName == nil) {
-        return NO;
-    }
-    
-    // Fetch an instance of this class
-    PGPlugin* obj = [self getCommandInstance:command.className];
-    
-    if (!([obj isKindOfClass:[PGPlugin class]])) { // still allow deprecated class, until 1.0 release
-        NSLog(@"ERROR: Plugin '%@' not found, or is not a PGPlugin. Check your plugin mapping in PhoneGap.plist.", command.className);
-        return NO;
-    }
-    BOOL retVal = YES;
-    
-    // construct the fill method name to ammend the second argument.
-    NSString* fullMethodName = [[NSString alloc] initWithFormat:@"%@:withDict:", command.methodName];
-    if ([obj respondsToSelector:NSSelectorFromString(fullMethodName)]) {
-        [obj performSelector:NSSelectorFromString(fullMethodName) withObject:command.arguments withObject:command.options];
-    } else {
-        // There's no method to call, so throw an error.
-        NSLog(@"ERROR: Method '%@' not defined in Plugin '%@'", fullMethodName, command.className);
-        retVal = NO;
-    }
-    [fullMethodName release];
-    
-    return retVal;
-}
-
 /*
  This method lets your application know that it is about to be terminated and purged from memory entirely
 */
@@ -841,7 +296,7 @@ BOOL gSplashScreenShown = NO;
 - (void)applicationWillResignActive:(UIApplication *)application
 {
     //NSLog(@"%@",@"applicationWillResignActive");
-    [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('resign');"];
+    [self.viewController.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('resign');"];
 }
 
 /*
@@ -852,14 +307,14 @@ BOOL gSplashScreenShown = NO;
 - (void)applicationWillEnterForeground:(UIApplication *)application
 {
     //NSLog(@"%@",@"applicationWillEnterForeground");
-    [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('resume');"];
+    [self.viewController.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('resume');"];
 }
 
 // This method is called to let your application know that it moved from the inactive to active state. 
 - (void)applicationDidBecomeActive:(UIApplication *)application
 {
     //NSLog(@"%@",@"applicationDidBecomeActive");
-    [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('active');"];
+    [self.viewController.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('active');"];
 }
 
 /*
@@ -869,7 +324,7 @@ BOOL gSplashScreenShown = NO;
 - (void)applicationDidEnterBackground:(UIApplication *)application
 {
     //NSLog(@"%@",@"applicationDidEnterBackground");
-    [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('pause');"];
+    [self.viewController.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('pause');"];
 }
 
 
@@ -885,7 +340,7 @@ BOOL gSplashScreenShown = NO;
 
     // Do something with the url here
     NSString* jsString = [NSString stringWithFormat:@"handleOpenURL(\"%@\");", url];
-    [self.webView stringByEvaluatingJavaScriptFromString:jsString];
+    [self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString];
     
     [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:PGPluginHandleOpenURLNotification object:url]];
     
@@ -895,31 +350,12 @@ BOOL gSplashScreenShown = NO;
 - (void)dealloc
 {
     [PluginResult releaseStatus];
-    self.pluginObjects = nil;
-    self.pluginsMap    = nil;
     self.viewController = nil;
     self.activityView = nil;
     self.window = nil;
     self.imageView = nil;
-    self.whitelist = nil;
     
     [super dealloc];
 }
 
-@end
-
-@implementation NSDictionary (LowercaseKeys)
-
-- (NSDictionary*) dictionaryWithLowercaseKeys 
-{
-    NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:self.count];
-    NSString* key;
-    
-    for (key in self) {
-        [result setObject:[self objectForKey:key] forKey:[key lowercaseString]];
-    }
-    
-    return result;
-}
-
-@end
+@end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/PhoneGapViewController.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PhoneGapViewController.h b/PhoneGapLib/Classes/PhoneGapViewController.h
index d09dbf8..944848a 100755
--- a/PhoneGapLib/Classes/PhoneGapViewController.h
+++ b/PhoneGapLib/Classes/PhoneGapViewController.h
@@ -6,14 +6,13 @@
  */
 
 
-#import <UIKit/UIKit.h>
-#import <Foundation/Foundation.h>
+#import "PGViewController.h"
 
-@interface PhoneGapViewController : UIViewController {
+/* This is here for legacy reasons - deprecated */
+ __attribute__((deprecated)) @interface PhoneGapViewController : PGViewController {
 }
+@end
 
-@property (nonatomic, retain) 	NSArray* supportedOrientations;
-@property (nonatomic, retain)	UIWebView* webView;
-
-
+/* here for legacy reasons - deprecated */
+@implementation PhoneGapViewController
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/PhoneGapViewController.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PhoneGapViewController.m b/PhoneGapLib/Classes/PhoneGapViewController.m
deleted file mode 100755
index 1db03e1..0000000
--- a/PhoneGapLib/Classes/PhoneGapViewController.m
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * PhoneGap is available under *either* the terms of the modified BSD license *or* the
- * MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.
- * 
- * Copyright (c) 2005-2010, Nitobi Software Inc.
- */
-
-
-#import "PhoneGapViewController.h"
-#import "PhoneGapDelegate.h" 
-
-@implementation PhoneGapViewController
-
-@synthesize supportedOrientations, webView;
-
-- (id) init
-{
-    if (self = [super init]) {
-		// do other init here
-	}
-	
-	return self;
-}
-
-
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation 
-{
-	// First ask the webview via JS if it wants to support the new orientation -jm
-	int i = 0;
-	
-	switch (interfaceOrientation){
-
-		case UIInterfaceOrientationPortraitUpsideDown:
-			i = 180;
-			break;
-		case UIInterfaceOrientationLandscapeLeft:
-			i = -90;
-			break;
-		case UIInterfaceOrientationLandscapeRight:
-			i = 90;
-			break;
-		default:
-		case UIInterfaceOrientationPortrait:
-			// noop
-			break;
-	}
-	
-	NSString* jsCall = [ NSString stringWithFormat:@"shouldRotateToOrientation(%d);",i];
-	NSString* res = [webView stringByEvaluatingJavaScriptFromString:jsCall];
-	
-	if([res length] > 0)
-	{
-		return [res boolValue];
-	}
-	
-	// if js did not handle the new orientation ( no return value ) we will look it up in the plist -jm
-	
-	BOOL autoRotate = [self.supportedOrientations count] > 0; // autorotate if only more than 1 orientation supported
-	if (autoRotate)
-	{
-		if ([self.supportedOrientations containsObject:
-			 [NSNumber numberWithInt:interfaceOrientation]]) {
-			return YES;
-		}
-    }
-	
-	// default return value is NO! -jm
-	
-	return NO;
-}
-
-/**
- Called by UIKit when the device starts to rotate to a new orientation.  This fires the \c setOrientation
- method on the Orientation object in JavaScript.  Look at the JavaScript documentation for more information.
- */
-- (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation
-{
-	int i = 0;
-	
-	switch (self.interfaceOrientation){
-		case UIInterfaceOrientationPortrait:
-			i = 0;
-			break;
-		case UIInterfaceOrientationPortraitUpsideDown:
-			i = 180;
-			break;
-		case UIInterfaceOrientationLandscapeLeft:
-			i = -90;
-			break;
-		case UIInterfaceOrientationLandscapeRight:
-			i = 90;
-			break;
-	}
-	
-	NSString* jsCallback = [NSString stringWithFormat:@"window.__defineGetter__('orientation',function(){ return %d; }); PhoneGap.fireEvent('orientationchange', window);",i];
-	[webView stringByEvaluatingJavaScriptFromString:jsCallback];
-	 
-}
-
-- (void) dealloc
-{
-    self.supportedOrientations = nil;
-    self.webView = nil;
-    
-    [super dealloc];
-}
-
-@end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/Classes/Sound.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Sound.m b/PhoneGapLib/Classes/Sound.m
index f6d86ca..f7aa59c 100644
--- a/PhoneGapLib/Classes/Sound.m
+++ b/PhoneGapLib/Classes/Sound.m
@@ -8,6 +8,7 @@
 
 #import "Sound.h"
 #import "PhonegapDelegate.h"
+#import "PGViewController.h"
 
 #define DOCUMENTS_SCHEME_PREFIX		@"documents://"
 #define HTTP_SCHEME_PREFIX			@"http://"
@@ -55,11 +56,11 @@
         NSLog(@"Will use resource '%@' from the Internet.", resourcePath);
         resourceURL = [NSURL URLWithString:resourcePath];
     } else if ([resourcePath hasPrefix:DOCUMENTS_SCHEME_PREFIX]) {
-        filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/",[PhoneGapDelegate applicationDocumentsDirectory]]];
+        filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/",[PGViewController applicationDocumentsDirectory]]];
        NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
     } else {
         // attempt to find file path in www directory
-        filePath = [PhoneGapDelegate pathForResource:resourcePath];
+        filePath = [PGViewController pathForResource:resourcePath];
         if (filePath != nil) {
             NSLog(@"Found resource '%@' in the web folder.", filePath);
         }else {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/01dfa7d0/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj b/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
index 8d5e01d..689527e 100644
--- a/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
+++ b/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
@@ -46,7 +46,6 @@
 		303259A1136B325100982B63 /* Notification.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD4F1090FBE7009987E8 /* Notification.m */; };
 		303259A2136B325100982B63 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD511090FBE7009987E8 /* NSData+Base64.m */; };
 		303259A4136B325100982B63 /* PhoneGapDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5B1090FBE7009987E8 /* PhoneGapDelegate.m */; };
-		303259A5136B325100982B63 /* PhoneGapViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5D1090FBE7009987E8 /* PhoneGapViewController.m */; };
 		303259A6136B325100982B63 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5F1090FBE7009987E8 /* Reachability.m */; };
 		303259A7136B325100982B63 /* Sound.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD611090FBE7009987E8 /* Sound.m */; };
 		303259A8136B325100982B63 /* Accelerometer.m in Sources */ = {isa = PBXBuildFile; fileRef = 88BA573C109BB46F00FB5E78 /* Accelerometer.m */; };
@@ -63,7 +62,6 @@
 		303259BF136B326300982B63 /* Notification.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD4E1090FBE7009987E8 /* Notification.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		303259C0136B326300982B63 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		303259C2136B326300982B63 /* PhoneGapDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5A1090FBE7009987E8 /* PhoneGapDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		303259C3136B326300982B63 /* PhoneGapViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5C1090FBE7009987E8 /* PhoneGapViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		303259C4136B326300982B63 /* Reachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5E1090FBE7009987E8 /* Reachability.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		303259C5136B326300982B63 /* Sound.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD601090FBE7009987E8 /* Sound.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		303259C6136B326300982B63 /* Accelerometer.h in Headers */ = {isa = PBXBuildFile; fileRef = 88BA573B109BB46F00FB5E78 /* Accelerometer.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -71,7 +69,6 @@
 		303259C9136B326300982B63 /* PluginResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F92F49E1314023E0046367C /* PluginResult.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		303259CA136B326300982B63 /* FileTransfer.h in Headers */ = {isa = PBXBuildFile; fileRef = C937A4541337599E002C4C79 /* FileTransfer.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		30325A0C136B343700982B63 /* VERSION in Resources */ = {isa = PBXBuildFile; fileRef = 30325A0B136B343700982B63 /* VERSION */; };
-		30356214141049E1006C2D43 /* PGWhitelistTests.h in Headers */ = {isa = PBXBuildFile; fileRef = 30356212141049E1006C2D43 /* PGWhitelistTests.h */; };
 		3035621714104C34006C2D43 /* PGWhitelistTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 30356213141049E1006C2D43 /* PGWhitelistTests.m */; };
 		3035621814104C3E006C2D43 /* PGWhitelistTests.h in Resources */ = {isa = PBXBuildFile; fileRef = 30356212141049E1006C2D43 /* PGWhitelistTests.h */; };
 		30383DE01385F65600E37E22 /* Connection.m in Sources */ = {isa = PBXBuildFile; fileRef = 307A8F9D1385A2EC00E43782 /* Connection.m */; };
@@ -109,6 +106,8 @@
 		30E563D013E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 30E563CE13E217EC00C949AA /* NSMutableArray+QueueAdditions.m */; };
 		30E563D113E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 30E563CD13E217EC00C949AA /* NSMutableArray+QueueAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		30E563D213E217EC00C949AA /* NSMutableArray+QueueAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 30E563CE13E217EC00C949AA /* NSMutableArray+QueueAdditions.m */; };
+		30FE6E0E14B7D6C600206FA5 /* PhoneGapViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 30FE6E0C14B7D6C600206FA5 /* PhoneGapViewController.h */; };
+		30FE6E0F14B7D6C600206FA5 /* PhoneGapViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 30FE6E0C14B7D6C600206FA5 /* PhoneGapViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		686357B5141002F200DF4CF2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 686357B3141002F200DF4CF2 /* InfoPlist.strings */; };
 		686357B8141002F200DF4CF2 /* PluginResultJSONSerializationTests.h in Resources */ = {isa = PBXBuildFile; fileRef = 686357B7141002F200DF4CF2 /* PluginResultJSONSerializationTests.h */; };
 		686357BA141002F200DF4CF2 /* PluginResultJSONSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 686357B9141002F200DF4CF2 /* PluginResultJSONSerializationTests.m */; };
@@ -125,12 +124,12 @@
 		68A32D7E141030EB006B237C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 686357AA141002F100DF4CF2 /* UIKit.framework */; };
 		68A32D7F141030F3006B237C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 686357AC141002F100DF4CF2 /* Foundation.framework */; };
 		8852C43A14B65FD800F0E735 /* PGViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852C43614B65FD800F0E735 /* PGViewController.h */; };
-		8852C43B14B65FD800F0E735 /* PGViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852C43614B65FD800F0E735 /* PGViewController.h */; };
+		8852C43B14B65FD800F0E735 /* PGViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852C43614B65FD800F0E735 /* PGViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8852C43C14B65FD800F0E735 /* PGViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43714B65FD800F0E735 /* PGViewController.m */; };
 		8852C43D14B65FD800F0E735 /* PGViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43714B65FD800F0E735 /* PGViewController.m */; };
 		8852C43E14B65FD800F0E735 /* PGViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43714B65FD800F0E735 /* PGViewController.m */; };
 		8852C43F14B65FD800F0E735 /* UIGapView.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852C43814B65FD800F0E735 /* UIGapView.h */; };
-		8852C44014B65FD800F0E735 /* UIGapView.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852C43814B65FD800F0E735 /* UIGapView.h */; };
+		8852C44014B65FD800F0E735 /* UIGapView.h in Headers */ = {isa = PBXBuildFile; fileRef = 8852C43814B65FD800F0E735 /* UIGapView.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8852C44114B65FD800F0E735 /* UIGapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43914B65FD800F0E735 /* UIGapView.m */; };
 		8852C44214B65FD800F0E735 /* UIGapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43914B65FD800F0E735 /* UIGapView.m */; };
 		8852C44314B65FD800F0E735 /* UIGapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8852C43914B65FD800F0E735 /* UIGapView.m */; };
@@ -154,8 +153,6 @@
 		8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD511090FBE7009987E8 /* NSData+Base64.m */; };
 		8887FD991090FBE7009987E8 /* PhoneGapDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5A1090FBE7009987E8 /* PhoneGapDelegate.h */; };
 		8887FD9A1090FBE7009987E8 /* PhoneGapDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5B1090FBE7009987E8 /* PhoneGapDelegate.m */; };
-		8887FD9B1090FBE7009987E8 /* PhoneGapViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5C1090FBE7009987E8 /* PhoneGapViewController.h */; };
-		8887FD9C1090FBE7009987E8 /* PhoneGapViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5D1090FBE7009987E8 /* PhoneGapViewController.m */; };
 		8887FD9D1090FBE7009987E8 /* Reachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5E1090FBE7009987E8 /* Reachability.h */; };
 		8887FD9E1090FBE7009987E8 /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5F1090FBE7009987E8 /* Reachability.m */; };
 		8887FD9F1090FBE7009987E8 /* Sound.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD601090FBE7009987E8 /* Sound.h */; };
@@ -210,6 +207,7 @@
 		30E33AF113A7E24B00594D64 /* PGPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PGPlugin.m; path = Classes/PGPlugin.m; sourceTree = "<group>"; };
 		30E563CD13E217EC00C949AA /* NSMutableArray+QueueAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSMutableArray+QueueAdditions.h"; path = "Classes/NSMutableArray+QueueAdditions.h"; sourceTree = "<group>"; };
 		30E563CE13E217EC00C949AA /* NSMutableArray+QueueAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSMutableArray+QueueAdditions.m"; path = "Classes/NSMutableArray+QueueAdditions.m"; sourceTree = "<group>"; };
+		30FE6E0C14B7D6C600206FA5 /* PhoneGapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhoneGapViewController.h; path = Classes/PhoneGapViewController.h; sourceTree = "<group>"; };
 		686357A9141002F100DF4CF2 /* PhoneGapLibTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PhoneGapLibTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
 		686357AA141002F100DF4CF2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
 		686357AC141002F100DF4CF2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -252,8 +250,6 @@
 		8887FD511090FBE7009987E8 /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+Base64.m"; path = "Classes/NSData+Base64.m"; sourceTree = "<group>"; };
 		8887FD5A1090FBE7009987E8 /* PhoneGapDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhoneGapDelegate.h; path = Classes/PhoneGapDelegate.h; sourceTree = "<group>"; };
 		8887FD5B1090FBE7009987E8 /* PhoneGapDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhoneGapDelegate.m; path = Classes/PhoneGapDelegate.m; sourceTree = "<group>"; };
-		8887FD5C1090FBE7009987E8 /* PhoneGapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhoneGapViewController.h; path = Classes/PhoneGapViewController.h; sourceTree = "<group>"; };
-		8887FD5D1090FBE7009987E8 /* PhoneGapViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PhoneGapViewController.m; path = Classes/PhoneGapViewController.m; sourceTree = "<group>"; };
 		8887FD5E1090FBE7009987E8 /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Reachability.h; path = Classes/Reachability.h; sourceTree = "<group>"; };
 		8887FD5F1090FBE7009987E8 /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Reachability.m; path = Classes/Reachability.m; sourceTree = "<group>"; };
 		8887FD601090FBE7009987E8 /* Sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Sound.h; path = Classes/Sound.h; sourceTree = "<group>"; };
@@ -343,6 +339,17 @@
 			name = Frameworks;
 			sourceTree = "<group>";
 		};
+		3054098714B77FF3009841CA /* Cleaver */ = {
+			isa = PBXGroup;
+			children = (
+				8852C43614B65FD800F0E735 /* PGViewController.h */,
+				8852C43714B65FD800F0E735 /* PGViewController.m */,
+				8852C43814B65FD800F0E735 /* UIGapView.h */,
+				8852C43914B65FD800F0E735 /* UIGapView.m */,
+			);
+			name = Cleaver;
+			sourceTree = "<group>";
+		};
 		32C88DFF0371C24200C91783 /* Other Sources */ = {
 			isa = PBXGroup;
 			children = (
@@ -450,18 +457,14 @@
 		8887FD101090FB43009987E8 /* Classes */ = {
 			isa = PBXGroup;
 			children = (
-				8852C43614B65FD800F0E735 /* PGViewController.h */,
-				8852C43714B65FD800F0E735 /* PGViewController.m */,
-				8852C43814B65FD800F0E735 /* UIGapView.h */,
-				8852C43914B65FD800F0E735 /* UIGapView.m */,
+				3054098714B77FF3009841CA /* Cleaver */,
 				888700D710922F56009987E8 /* Commands */,
 				8887FD361090FBE7009987E8 /* JSON */,
 				888700D910923009009987E8 /* Util */,
 				888700D810922FD3009987E8 /* Plugins */,
 				8887FD5A1090FBE7009987E8 /* PhoneGapDelegate.h */,
 				8887FD5B1090FBE7009987E8 /* PhoneGapDelegate.m */,
-				8887FD5C1090FBE7009987E8 /* PhoneGapViewController.h */,
-				8887FD5D1090FBE7009987E8 /* PhoneGapViewController.m */,
+				30FE6E0C14B7D6C600206FA5 /* PhoneGapViewController.h */,
 			);
 			name = Classes;
 			sourceTree = "<group>";
@@ -494,7 +497,6 @@
 				303259BF136B326300982B63 /* Notification.h in Headers */,
 				303259C0136B326300982B63 /* NSData+Base64.h in Headers */,
 				303259C2136B326300982B63 /* PhoneGapDelegate.h in Headers */,
-				303259C3136B326300982B63 /* PhoneGapViewController.h in Headers */,
 				303259C4136B326300982B63 /* Reachability.h in Headers */,
 				303259C5136B326300982B63 /* Sound.h in Headers */,
 				303259C6136B326300982B63 /* Accelerometer.h in Headers */,
@@ -513,6 +515,7 @@
 				30E563D113E217EC00C949AA /* NSMutableArray+QueueAdditions.h in Headers */,
 				8852C43B14B65FD800F0E735 /* PGViewController.h in Headers */,
 				8852C44014B65FD800F0E735 /* UIGapView.h in Headers */,
+				30FE6E0F14B7D6C600206FA5 /* PhoneGapViewController.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -530,7 +533,6 @@
 				8887FD8D1090FBE7009987E8 /* Notification.h in Headers */,
 				8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
 				8887FD991090FBE7009987E8 /* PhoneGapDelegate.h in Headers */,
-				8887FD9B1090FBE7009987E8 /* PhoneGapViewController.h in Headers */,
 				8887FD9D1090FBE7009987E8 /* Reachability.h in Headers */,
 				8887FD9F1090FBE7009987E8 /* Sound.h in Headers */,
 				88BA573D109BB46F00FB5E78 /* Accelerometer.h in Headers */,
@@ -547,10 +549,10 @@
 				1F2BECC013F9785B00A93BF6 /* Battery.h in Headers */,
 				30C684801406CB38004C1A8E /* PGWhitelist.h in Headers */,
 				30C684941407044B004C1A8E /* PGURLProtocol.h in Headers */,
-				30356214141049E1006C2D43 /* PGWhitelistTests.h in Headers */,
 				30A90B9114588697006178D3 /* JSONKit.h in Headers */,
 				8852C43A14B65FD800F0E735 /* PGViewController.h in Headers */,
 				8852C43F14B65FD800F0E735 /* UIGapView.h in Headers */,
+				30FE6E0E14B7D6C600206FA5 /* PhoneGapViewController.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -746,7 +748,6 @@
 				303259A1136B325100982B63 /* Notification.m in Sources */,
 				303259A2136B325100982B63 /* NSData+Base64.m in Sources */,
 				303259A4136B325100982B63 /* PhoneGapDelegate.m in Sources */,
-				303259A5136B325100982B63 /* PhoneGapViewController.m in Sources */,
 				303259A6136B325100982B63 /* Reachability.m in Sources */,
 				303259A7136B325100982B63 /* Sound.m in Sources */,
 				303259A8136B325100982B63 /* Accelerometer.m in Sources */,
@@ -791,7 +792,6 @@
 				8887FD8E1090FBE7009987E8 /* Notification.m in Sources */,
 				8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
 				8887FD9A1090FBE7009987E8 /* PhoneGapDelegate.m in Sources */,
-				8887FD9C1090FBE7009987E8 /* PhoneGapViewController.m in Sources */,
 				8887FD9E1090FBE7009987E8 /* Reachability.m in Sources */,
 				8887FDA01090FBE7009987E8 /* Sound.m in Sources */,
 				88BA573E109BB46F00FB5E78 /* Accelerometer.m in Sources */,