incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject git commit: Re-factored to use PGViewController more effectively (has iPad view scaling problems currently).
Date Fri, 27 Jan 2012 02:13:10 GMT
Updated Branches:
  refs/heads/master d0c39dad2 -> a2b4ec5af


Re-factored to use PGViewController more effectively (has iPad view scaling problems currently).


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/a2b4ec5a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/a2b4ec5a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/a2b4ec5a

Branch: refs/heads/master
Commit: a2b4ec5af3dbb9c971962d191194accef0370ef2
Parents: d0c39da
Author: Shazron Abdullah <shazron@apache.org>
Authored: Thu Jan 26 18:12:48 2012 -0800
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Thu Jan 26 18:12:48 2012 -0800

----------------------------------------------------------------------
 .../TemplateInfo.plist                             |   38 +++
 PhoneGap-based Application/Classes/AppDelegate.h   |   13 +-
 PhoneGap-based Application/Classes/AppDelegate.m   |  115 ++++++--
 .../Classes/MainViewController.h                   |   17 ++
 .../Classes/MainViewController.m                   |   47 +++
 .../Classes/MainViewController.xib                 |  118 ++++++++
 .../___PROJECTNAME___.xcodeproj/project.pbxproj    |   25 ++
 PhoneGapLib/Classes/Camera.m                       |    1 -
 PhoneGapLib/Classes/Capture.m                      |    1 -
 PhoneGapLib/Classes/Contact.m                      |    1 -
 PhoneGapLib/Classes/Contacts.m                     |    1 -
 PhoneGapLib/Classes/Location.m                     |    4 +-
 PhoneGapLib/Classes/PGAppDelegate.h                |   38 ---
 PhoneGapLib/Classes/PGAppDelegate.m                |  222 ---------------
 PhoneGapLib/Classes/PGPlugin.m                     |    1 -
 PhoneGapLib/Classes/PGSplashScreen.m               |   18 +-
 PhoneGapLib/Classes/PGURLProtocol.m                |   13 +-
 PhoneGapLib/Classes/PGViewController.m             |   99 ++++++-
 PhoneGapLib/Classes/Sound.m                        |    1 -
 PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj  |   12 -
 20 files changed, 458 insertions(+), 327 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGap-based Application.xctemplate/TemplateInfo.plist
----------------------------------------------------------------------
diff --git a/PhoneGap-based Application.xctemplate/TemplateInfo.plist b/PhoneGap-based Application.xctemplate/TemplateInfo.plist
index 3799187..9bae1fc 100644
--- a/PhoneGap-based Application.xctemplate/TemplateInfo.plist	
+++ b/PhoneGap-based Application.xctemplate/TemplateInfo.plist	
@@ -59,6 +59,41 @@
 			<key>PathType</key>
 			<string>Group</string>
 		</dict>
+		<key>Classes/MainViewController.h</key>
+		<dict>
+			<key>Group</key>
+			<array>
+				<string>Classes</string>
+			</array>
+			<key>Path</key>
+			<string>./Classes/MainViewController.h</string>
+			<key>PathType</key>
+			<string>Group</string>
+			<key>TargetIndices</key>
+			<array/>
+		</dict>
+		<key>Classes/MainViewController.m</key>
+		<dict>
+			<key>Group</key>
+			<array>
+				<string>Classes</string>
+			</array>
+			<key>Path</key>
+			<string>./Classes/MainViewController.m</string>
+			<key>PathType</key>
+			<string>Group</string>
+		</dict>
+		<key>Classes/MainViewController.xib</key>
+		<dict>
+			<key>Group</key>
+			<array>
+				<string>Supporting Files</string>
+			</array>
+			<key>Path</key>
+			<string>./Classes/MainViewController.xib</string>
+			<key>PathType</key>
+			<string>Group</string>
+		</dict>
 		<key>main.m</key>
 		<dict>
 			<key>Group</key>
@@ -220,6 +255,9 @@
 		<string>PhoneGap.plist</string>
 		<string>Classes/AppDelegate.h</string>
 		<string>Classes/AppDelegate.m</string>
+		<string>Classes/MainViewController.h</string>
+		<string>Classes/MainViewController.m</string>
+		<string>Classes/MainViewController.xib</string>
 		<string>Plugins/README</string>
 	</array>
 	<key>Options</key>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGap-based Application/Classes/AppDelegate.h
----------------------------------------------------------------------
diff --git a/PhoneGap-based Application/Classes/AppDelegate.h b/PhoneGap-based Application/Classes/AppDelegate.h
index 4e4eb23..a9da5c1 100644
--- a/PhoneGap-based Application/Classes/AppDelegate.h	
+++ b/PhoneGap-based Application/Classes/AppDelegate.h	
@@ -16,6 +16,7 @@
  specific language governing permissions and limitations
  under the License.
  */
+
 //
 //  AppDelegate.h
 //  ___PROJECTNAME___
@@ -25,25 +26,27 @@
 //
 
 #import <UIKit/UIKit.h>
+
 #ifdef PHONEGAP_FRAMEWORK
-	#import <PhoneGap/PGAppDelegate.h>
     #import <PhoneGap/PGViewController.h>
 #else
-	#import "PGAppDelegate.h"
     #import "PGViewController.h"
 #endif
 
-@interface AppDelegate : PGAppDelegate < PGCommandDelegate > {
+
+@interface AppDelegate : NSObject < UIApplicationDelegate, UIWebViewDelegate, PGCommandDelegate > {
 
 	NSString* invokeString;
 }
 
 // invoke string is passed to your app on launch, this is only valid if you 
-// edit ___PROJECTNAME___.plist to add a protocol
+// edit FooBar.plist to add a protocol
 // a simple tutorial can be found here : 
 // http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
 
-@property (copy)  NSString* invokeString;
+@property (nonatomic, copy)  NSString* invokeString;
+@property (nonatomic, retain) IBOutlet UIWindow* window;
+@property (nonatomic, retain) IBOutlet PGViewController* viewController;
 
 @end
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGap-based Application/Classes/AppDelegate.m
----------------------------------------------------------------------
diff --git a/PhoneGap-based Application/Classes/AppDelegate.m b/PhoneGap-based Application/Classes/AppDelegate.m
index 3d2d295..fbe38e0 100644
--- a/PhoneGap-based Application/Classes/AppDelegate.m	
+++ b/PhoneGap-based Application/Classes/AppDelegate.m	
@@ -16,6 +16,7 @@
  specific language governing permissions and limitations
  under the License.
  */
+
 //
 //  AppDelegate.m
 //  ___PROJECTNAME___
@@ -25,68 +26,136 @@
 //
 
 #import "AppDelegate.h"
+#import "MainViewController.h"
+
+#ifdef PHONEGAP_FRAMEWORK
+    #import <PhoneGap/PGPlugin.h>
+    #import <PhoneGap/PGURLProtocol.h>
+#else
+    #import "PGPlugin.h"
+    #import "PGURLProtocol.h"
+#endif
+
 
 @implementation AppDelegate
 
-@synthesize invokeString;
+@synthesize invokeString, window, viewController;
 
 - (id) init
 {	
 	/** If you need to do any extra app-specific initialization, you can do it here
 	 *  -jm
 	 **/
+    NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 
+    [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
+    
+    [PGURLProtocol registerPGHttpURLProtocol];
+    
     return [super init];
 }
 
+#pragma UIApplicationDelegate implementation
+
 /**
  * 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
 {    
     NSURL* url = [launchOptions objectForKey:UIApplicationLaunchOptionsURLKey];
-    if (url && [url isKindOfClass:[NSURL class]])
-    {
+    if (url && [url isKindOfClass:[NSURL class]]) {
         self.invokeString = [url absoluteString];
-		NSLog(@"___PROJECTNAME___ launchOptions = %@",url);
+		NSLog(@"___PROJECTNAME___ launchOptions = %@", url);
     }    
-		
-	BOOL ok = [super application:application didFinishLaunchingWithOptions:launchOptions];
-    if (ok) {
-        self.viewController.webView.delegate = self;
-        self.viewController.commandDelegate = self;
+    
+    CGRect screenBounds = [[UIScreen mainScreen] applicationFrame];
+    self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
+    self.window.autoresizesSubviews = YES;
+    
+    CGRect viewBounds = screenBounds;
+    viewBounds.origin.y = 0; 
+    
+    self.viewController = [[[MainViewController alloc] init] autorelease];
+    self.viewController.useSplashScreen = YES;
+    self.viewController.wwwFolderName = @"www";
+    self.viewController.startPage = @"index.html";
+    self.viewController.view.bounds = viewBounds;
+    
+    // over-ride delegates
+    self.viewController.webView.delegate = self;
+    self.viewController.commandDelegate = self;
+
+    // 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 the status bar
+        curDevOrientation = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
+    }
+    
+    if (UIDeviceOrientationIsValidInterfaceOrientation(curDevOrientation)) {
+        for (NSNumber *orient in self.viewController.supportedOrientations) {
+            if ([orient intValue] == curDevOrientation) {
+                forceStartupRotation = NO;
+                break;
+            }
+        }
+    } 
+    
+    if (forceStartupRotation) {
+        NSLog(@"supportedOrientations: %@", self.viewController.supportedOrientations);
+        // The first item in the supportedOrientations array is the start orientation (guaranteed to be at least Portrait)
+        UIInterfaceOrientation newOrient = [[self.viewController.supportedOrientations objectAtIndex:0] intValue];
+        NSLog(@"AppDelegate forcing status bar to: %d from: %d", newOrient, curDevOrientation);
+        [[UIApplication sharedApplication] setStatusBarOrientation:newOrient];
     }
-    return ok;
+    
+    [self.window addSubview:self.viewController.view];
+    [self.window makeKeyAndVisible];
+    
+    return YES;
 }
 
 // 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
+// only valid if FooBar.plist specifies a protocol to handle
 - (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];
+    if (!url) { 
+        return NO; 
+    }
+    
+	// calls into javascript global function 'handleOpenURL'
+    NSString* jsString = [NSString stringWithFormat:@"handleOpenURL(\"%@\");", url];
+    [self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString];
+    
+    // all plugins will get the notification, and their handlers will be called 
+    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:PGPluginHandleOpenURLNotification object:url]];
+    
+    return YES;    
 }
 
+#pragma PGCommandDelegate implementation
+
 - (id) getCommandInstance:(NSString*)className
 {
-	return [super.viewController getCommandInstance:className];
+	return [self.viewController getCommandInstance:className];
 }
 
 - (BOOL) execute:(InvokedUrlCommand*)command
 {
-	return [super.viewController execute:command];
+	return [self.viewController execute:command];
 }
 
 - (NSString*) pathForResource:(NSString*)resourcepath;
 {
-	return [super.viewController pathForResource:resourcepath];
+	return [self.viewController pathForResource:resourcepath];
 }
 
 #pragma UIWebDelegate implementation
 
 - (void) webViewDidFinishLoad:(UIWebView*) theWebView 
 {
-	// only valid if ___PROJECTNAME___.plist specifies a protocol to handle
+	// only valid if FooBar.plist specifies a protocol to handle
 	if (self.invokeString)
 	{
 		// this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
@@ -97,22 +166,22 @@
 	 // Black base color for background matches the native apps
    	theWebView.backgroundColor = [UIColor blackColor];
     
-	return [super.viewController webViewDidFinishLoad:theWebView];
+	return [self.viewController webViewDidFinishLoad:theWebView];
 }
 
 - (void) webViewDidStartLoad:(UIWebView*)theWebView 
 {
-	return [super.viewController webViewDidStartLoad:theWebView];
+	return [self.viewController webViewDidStartLoad:theWebView];
 }
 
 - (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error 
 {
-	return [super.viewController webView:theWebView didFailLoadWithError:error];
+	return [self.viewController webView:theWebView didFailLoadWithError:error];
 }
 
 - (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
 {
-	return [super.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
+	return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
 }
 
 - (void) dealloc
@@ -120,4 +189,4 @@
 	[super dealloc];
 }
 
-@end
\ No newline at end of file
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGap-based Application/Classes/MainViewController.h
----------------------------------------------------------------------
diff --git a/PhoneGap-based Application/Classes/MainViewController.h b/PhoneGap-based Application/Classes/MainViewController.h
new file mode 100644
index 0000000..33ddbc2
--- /dev/null
+++ b/PhoneGap-based Application/Classes/MainViewController.h	
@@ -0,0 +1,17 @@
+//
+//  MainViewController.h
+//  FooBar
+//
+//  Created by Shazron Abdullah on 12-01-26.
+//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
+//
+
+#ifdef PHONEGAP_FRAMEWORK
+    #import <PhoneGap/PGViewController.h>
+#else
+    #import "PGViewController.h"
+#endif
+
+@interface MainViewController : PGViewController
+
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGap-based Application/Classes/MainViewController.m
----------------------------------------------------------------------
diff --git a/PhoneGap-based Application/Classes/MainViewController.m b/PhoneGap-based Application/Classes/MainViewController.m
new file mode 100644
index 0000000..1e2c833
--- /dev/null
+++ b/PhoneGap-based Application/Classes/MainViewController.m	
@@ -0,0 +1,47 @@
+//
+//  MainViewController.m
+//  ___PROJECTNAME___
+//
+#import "MainViewController.h"
+
+@implementation MainViewController
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+    if (self) {
+        // Custom initialization
+    }
+    return self;
+}
+
+- (void)didReceiveMemoryWarning
+{
+    // Releases the view if it doesn't have a superview.
+    [super didReceiveMemoryWarning];
+    
+    // Release any cached data, images, etc that aren't in use.
+}
+
+#pragma mark - View lifecycle
+
+- (void)viewDidLoad
+{
+    [super viewDidLoad];
+    // Do any additional setup after loading the view from its nib.
+}
+
+- (void)viewDidUnload
+{
+    [super viewDidUnload];
+    // Release any retained subviews of the main view.
+    // e.g. self.myOutlet = nil;
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+    // Return YES for supported orientations
+    return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGap-based Application/Classes/MainViewController.xib
----------------------------------------------------------------------
diff --git a/PhoneGap-based Application/Classes/MainViewController.xib b/PhoneGap-based Application/Classes/MainViewController.xib
new file mode 100644
index 0000000..9837f57
--- /dev/null
+++ b/PhoneGap-based Application/Classes/MainViewController.xib	
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
+	<data>
+		<int key="IBDocument.SystemTarget">1280</int>
+		<string key="IBDocument.SystemVersion">11C25</string>
+		<string key="IBDocument.InterfaceBuilderVersion">1919</string>
+		<string key="IBDocument.AppKitVersion">1138.11</string>
+		<string key="IBDocument.HIToolboxVersion">566.00</string>
+		<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+			<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+			<string key="NS.object.0">916</string>
+		</object>
+		<array key="IBDocument.IntegratedClassDependencies">
+			<string>IBProxyObject</string>
+			<string>IBUIView</string>
+		</array>
+		<array key="IBDocument.PluginDependencies">
+			<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+		</array>
+		<object class="NSMutableDictionary" key="IBDocument.Metadata">
+			<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+			<integer value="1" key="NS.object.0"/>
+		</object>
+		<array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+			<object class="IBProxyObject" id="372490531">
+				<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+			</object>
+			<object class="IBProxyObject" id="975951072">
+				<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+			</object>
+			<object class="IBUIView" id="191373211">
+				<reference key="NSNextResponder"/>
+				<int key="NSvFlags">274</int>
+				<string key="NSFrame">{{0, 20}, {320, 460}}</string>
+				<reference key="NSSuperview"/>
+				<reference key="NSWindow"/>
+				<object class="NSColor" key="IBUIBackgroundColor">
+					<int key="NSColorSpace">3</int>
+					<bytes key="NSWhite">MQA</bytes>
+					<object class="NSColorSpace" key="NSCustomColorSpace">
+						<int key="NSID">2</int>
+					</object>
+				</object>
+				<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+			</object>
+		</array>
+		<object class="IBObjectContainer" key="IBDocument.Objects">
+			<array class="NSMutableArray" key="connectionRecords">
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchOutletConnection" key="connection">
+						<string key="label">view</string>
+						<reference key="source" ref="372490531"/>
+						<reference key="destination" ref="191373211"/>
+					</object>
+					<int key="connectionID">3</int>
+				</object>
+			</array>
+			<object class="IBMutableOrderedSet" key="objectRecords">
+				<array key="orderedObjects">
+					<object class="IBObjectRecord">
+						<int key="objectID">0</int>
+						<array key="object" id="0"/>
+						<reference key="children" ref="1000"/>
+						<nil key="parent"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">1</int>
+						<reference key="object" ref="191373211"/>
+						<reference key="parent" ref="0"/>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-1</int>
+						<reference key="object" ref="372490531"/>
+						<reference key="parent" ref="0"/>
+						<string key="objectName">File's Owner</string>
+					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">-2</int>
+						<reference key="object" ref="975951072"/>
+						<reference key="parent" ref="0"/>
+					</object>
+				</array>
+			</object>
+			<dictionary class="NSMutableDictionary" key="flattenedProperties">
+				<string key="-1.CustomClassName">MainViewController</string>
+				<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="-2.CustomClassName">UIResponder</string>
+				<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+				<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+			</dictionary>
+			<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+			<nil key="activeLocalization"/>
+			<dictionary class="NSMutableDictionary" key="localizations"/>
+			<nil key="sourceID"/>
+			<int key="maxID">3</int>
+		</object>
+		<object class="IBClassDescriber" key="IBDocument.Classes">
+			<array class="NSMutableArray" key="referencedPartialClassDescriptions">
+				<object class="IBPartialClassDescription">
+					<string key="className">MainViewController</string>
+					<string key="superclassName">UIViewController</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBProjectSource</string>
+						<string key="minorKey">./Classes/MainViewController.h</string>
+					</object>
+				</object>
+			</array>
+		</object>
+		<int key="IBDocument.localizationMode">0</int>
+		<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
+		<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+		<int key="IBDocument.defaultPropertyAccessControl">3</int>
+		<string key="IBCocoaTouchPluginVersion">916</string>
+	</data>
+</archive>

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGap-based Application/___PROJECTNAME___.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/PhoneGap-based Application/___PROJECTNAME___.xcodeproj/project.pbxproj b/PhoneGap-based Application/___PROJECTNAME___.xcodeproj/project.pbxproj
index 7fd6c48..deb4ec7 100755
--- a/PhoneGap-based Application/___PROJECTNAME___.xcodeproj/project.pbxproj	
+++ b/PhoneGap-based Application/___PROJECTNAME___.xcodeproj/project.pbxproj	
@@ -25,6 +25,8 @@
 		301BF5C1109A6A2B0062928A /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5C0109A6A2B0062928A /* MediaPlayer.framework */; };
 		301BF5C3109A6A2B0062928A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5C2109A6A2B0062928A /* QuartzCore.framework */; };
 		301BF5C5109A6A2B0062928A /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 301BF5C4109A6A2B0062928A /* SystemConfiguration.framework */; };
+		302D95F114D2391D003F00A1 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 302D95EF14D2391D003F00A1 /* MainViewController.m */; };
+		302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 302D95F014D2391D003F00A1 /* MainViewController.xib */; };
 		3053AC6F109B7857006FCFE7 /* VERSION in Resources */ = {isa = PBXBuildFile; fileRef = 3053AC6E109B7857006FCFE7 /* VERSION */; };
 		305D5FD1115AB8F900A74A75 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 305D5FD0115AB8F900A74A75 /* MobileCoreServices.framework */; };
 		3072F99713A8081B00425683 /* Capture.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 3072F99613A8081B00425683 /* Capture.bundle */; };
@@ -55,6 +57,13 @@
 			remoteGlobalIDString = D2AAC07D0554694100DB518D;
 			remoteInfo = PhoneGapLib;
 		};
+		302D95EB14D23909003F00A1 /* PBXContainerItemProxy */ = {
+			isa = PBXContainerItemProxy;
+			containerPortal = 301BF52D109A57CC0062928A /* PhoneGapLib.xcodeproj */;
+			proxyType = 2;
+			remoteGlobalIDString = 686357A9141002F100DF4CF2;
+			remoteInfo = PhoneGapLibTests;
+		};
 		30E47BC2136F595F00DBB853 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
 			containerPortal = 301BF52D109A57CC0062928A /* PhoneGapLib.xcodeproj */;
@@ -85,6 +94,9 @@
 		301BF5C0109A6A2B0062928A /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
 		301BF5C2109A6A2B0062928A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
 		301BF5C4109A6A2B0062928A /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
+		302D95EE14D2391D003F00A1 /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MainViewController.h; path = ../../../../../../Desktop/FooBar/Classes/MainViewController.h; sourceTree = "<group>"; };
+		302D95EF14D2391D003F00A1 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MainViewController.m; path = ../../../../../../Desktop/FooBar/Classes/MainViewController.m; sourceTree = "<group>"; };
+		302D95F014D2391D003F00A1 /* MainViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MainViewController.xib; path = ../../../../../../Desktop/FooBar/Classes/MainViewController.xib; sourceTree = "<group>"; };
 		3053AC6E109B7857006FCFE7 /* VERSION */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VERSION; sourceTree = PHONEGAPLIB; };
 		305D5FD0115AB8F900A74A75 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
 		3072F99613A8081B00425683 /* Capture.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = Capture.bundle; path = Resources/Capture.bundle; sourceTree = "<group>"; };
@@ -131,6 +143,9 @@
 		080E96DDFE201D6D7F000001 /* Classes */ = {
 			isa = PBXGroup;
 			children = (
+				302D95EE14D2391D003F00A1 /* MainViewController.h */,
+				302D95EF14D2391D003F00A1 /* MainViewController.m */,
+				302D95F014D2391D003F00A1 /* MainViewController.xib */,
 				1D3623240D0F684500981E51 /* AppDelegate.h */,
 				1D3623250D0F684500981E51 /* AppDelegate.m */,
 			);
@@ -229,6 +244,7 @@
 			children = (
 				301BF535109A57CC0062928A /* libPhoneGap.a */,
 				30E47BC3136F595F00DBB853 /* PhoneGap.framework */,
+				302D95EC14D23909003F00A1 /* PhoneGapLibTests.octest */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -325,6 +341,13 @@
 			remoteRef = 301BF534109A57CC0062928A /* PBXContainerItemProxy */;
 			sourceTree = BUILT_PRODUCTS_DIR;
 		};
+		302D95EC14D23909003F00A1 /* PhoneGapLibTests.octest */ = {
+			isa = PBXReferenceProxy;
+			fileType = wrapper.cfbundle;
+			path = PhoneGapLibTests.octest;
+			remoteRef = 302D95EB14D23909003F00A1 /* PBXContainerItemProxy */;
+			sourceTree = BUILT_PRODUCTS_DIR;
+		};
 		30E47BC3136F595F00DBB853 /* PhoneGap.framework */ = {
 			isa = PBXReferenceProxy;
 			fileType = wrapper.cfbundle;
@@ -353,6 +376,7 @@
 				3072F99713A8081B00425683 /* Capture.bundle in Resources */,
 				1F766FE113BBADB100FB74C0 /* Localizable.strings in Resources */,
 				1F766FE213BBADB100FB74C0 /* Localizable.strings in Resources */,
+				302D95F214D2391D003F00A1 /* MainViewController.xib in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -382,6 +406,7 @@
 			files = (
 				1D60589B0D05DD56006BFB54 /* main.m in Sources */,
 				1D3623260D0F684500981E51 /* AppDelegate.m in Sources */,
+				302D95F114D2391D003F00A1 /* MainViewController.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/Camera.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Camera.m b/PhoneGapLib/Classes/Camera.m
index 34b537b..9dca33c 100644
--- a/PhoneGapLib/Classes/Camera.m
+++ b/PhoneGapLib/Classes/Camera.m
@@ -20,7 +20,6 @@
 #import "Camera.h"
 #import "NSData+Base64.h"
 #import "Categories.h"
-#import "PGAppDelegate.h"
 #import <MobileCoreServices/UTCoreTypes.h>
 
 @implementation PGCamera

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/Capture.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Capture.m b/PhoneGapLib/Classes/Capture.m
index 4f9d1e2..f406747 100644
--- a/PhoneGapLib/Classes/Capture.m
+++ b/PhoneGapLib/Classes/Capture.m
@@ -19,7 +19,6 @@
 
 #import "Capture.h"
 #import "JSONKit.h"
-#import "PGAppDelegate.h"
 #import "PGViewController.h"
 
 #define kW3CMediaFormatHeight @"height"

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/Contact.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Contact.m b/PhoneGapLib/Classes/Contact.m
index 3d23776..ac2bc85 100644
--- a/PhoneGapLib/Classes/Contact.m
+++ b/PhoneGapLib/Classes/Contact.m
@@ -19,7 +19,6 @@
 
 #import "Contact.h"
 #import "Categories.h"
-#import "PGAppDelegate.h"
 
 #define DATE_OR_NULL(dateObj) ( (aDate != nil) ? (id)([aDate descriptionWithLocale: [NSLocale currentLocale]]) : (id)([NSNull null]) )
 #define IS_VALID_VALUE(value) ((value != nil) && (![value isKindOfClass: [NSNull class]]))

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/Contacts.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Contacts.m b/PhoneGapLib/Classes/Contacts.m
index 05b80c7..ab68929 100755
--- a/PhoneGapLib/Classes/Contacts.m
+++ b/PhoneGapLib/Classes/Contacts.m
@@ -20,7 +20,6 @@
 
 #import "Contacts.h"
 #import <UIKit/UIKit.h>
-#import "PGAppDelegate.h"
 #import "Categories.h"
 #import "Notification.h"
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/Location.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Location.m b/PhoneGapLib/Classes/Location.m
index 1a7f49b..05e6bac 100755
--- a/PhoneGapLib/Classes/Location.m
+++ b/PhoneGapLib/Classes/Location.m
@@ -20,7 +20,6 @@
 
 #import "Location.h"
 #import "PGViewController.h"
-#import "PGAppDelegate.h"
 
 #pragma mark Constants
 
@@ -373,8 +372,7 @@
     if ([self.locationManager respondsToSelector: @selector(headingOrientation)]) {
         UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation];
         if (currentOrientation != UIDeviceOrientationUnknown) {
-            PGAppDelegate* pgDelegate = [self appDelegate];
-            PGViewController* pgViewController = pgDelegate.viewController;
+            PGViewController* pgViewController = (PGViewController*)self.viewController;
             
             if ([pgViewController.supportedOrientations containsObject:
                  [NSNumber numberWithInt:currentOrientation]]) {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/PGAppDelegate.h
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGAppDelegate.h b/PhoneGapLib/Classes/PGAppDelegate.h
deleted file mode 100644
index aea3ae7..0000000
--- a/PhoneGapLib/Classes/PGAppDelegate.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
- 
- http://www.apache.org/licenses/LICENSE-2.0
- 
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import <UIKit/UIKit.h>
-#import "JSONKit.h"
-
-@class PGViewController;
-
-@interface PGAppDelegate : NSObject <UIApplicationDelegate, UIWebViewDelegate>
-{
-}
-
-@property (nonatomic, readwrite, retain) IBOutlet UIWindow* window;
-@property (nonatomic, readonly, retain) IBOutlet PGViewController* viewController;
-
-- (void)applicationDidEnterBackground:(UIApplication *)application;
-- (void)applicationWillEnterForeground:(UIApplication *)application;
-- (void)applicationWillResignActive:(UIApplication *)application;
-- (void)applicationWillTerminate:(UIApplication *)application;
-
-@end
-

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/PGAppDelegate.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGAppDelegate.m b/PhoneGapLib/Classes/PGAppDelegate.m
deleted file mode 100644
index 35a534b..0000000
--- a/PhoneGapLib/Classes/PGAppDelegate.m
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements.  See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership.  The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License.  You may obtain a copy of the License at
- 
- http://www.apache.org/licenses/LICENSE-2.0
- 
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied.  See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import <UIKit/UIKit.h>
-#import <CoreLocation/CoreLocation.h>
-
-#import "Location.h"
-#import "Sound.h"
-#import "DebugConsole.h"
-#import "Connection.h"
-
-#import "PGURLProtocol.h"
-#import "PGWhitelist.h"
-#import "InvokedUrlCommand.h"
-#import "PGAppDelegate.h"
-#import "PGViewController.h"
-#import "PGPlugin.h"
-
-// class extension
-@interface PGAppDelegate ()
-
-// readwrite access for self
-
-@property (nonatomic, readwrite, retain) IBOutlet PGViewController* viewController;
-
-@end
-
-
-@implementation PGAppDelegate
-
-@synthesize window, viewController;
-
-- (id) init
-{
-    self = [super init];
-    if (self != nil) {
-        // Turn on cookie support ( shared with our app only! )
-        NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; 
-        [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
-        
-        [PGURLProtocol registerPGHttpURLProtocol];
-    }
-    return self; 
-}
-
-/**
- * This is main kick off after the app inits, the views and Settings are setup here.
- */
-- (BOOL) application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
-{    
-    CGRect screenBounds = [ [ UIScreen mainScreen ] bounds ];
-    self.window = [ [ [ UIWindow alloc ] initWithFrame:screenBounds ] autorelease ];
-    self.window.autoresizesSubviews = YES;
-    
-    CGRect viewBounds = [[UIScreen mainScreen] applicationFrame];
-    viewBounds.origin = screenBounds.origin;
-    self.viewController = [[[PGViewController alloc] init] autorelease];
-    self.viewController.useSplashScreen = YES;
-    self.viewController.view.bounds = viewBounds;
-    
-    // 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 the status bar
-        curDevOrientation = (UIDeviceOrientation)[[UIApplication sharedApplication] statusBarOrientation];
-    }
-
-    if (UIDeviceOrientationIsValidInterfaceOrientation(curDevOrientation)) {
-        for (NSNumber *orient in self.viewController.supportedOrientations) {
-            if ([orient intValue] == curDevOrientation) {
-                forceStartupRotation = NO;
-                break;
-            }
-        }
-    } 
-    
-    if (forceStartupRotation) {
-        NSLog(@"supportedOrientations: %@", self.viewController.supportedOrientations);
-        // The first item in the supportedOrientations array is the start orientation (guaranteed to be at least Portrait)
-        UIInterfaceOrientation newOrient = [[self.viewController.supportedOrientations objectAtIndex:0] intValue];
-        NSLog(@"PhoneGapDelegate forcing status bar to: %d from: %d",newOrient,curDevOrientation);
-        [[UIApplication sharedApplication] setStatusBarOrientation:newOrient];
-    }
-    
-    [self.window addSubview:self.viewController.view];
-    [self.window makeKeyAndVisible];
-    
-    return YES;
-}
-
-- (NSString*) appURLScheme
-{
-    NSString* URLScheme = nil;
-    
-    NSArray *URLTypes = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleURLTypes"];
-    if(URLTypes != nil ) {
-        NSDictionary* dict = [URLTypes objectAtIndex:0];
-        if(dict != nil ) {
-            NSArray* URLSchemes = [dict objectForKey:@"CFBundleURLSchemes"];
-            if( URLSchemes != nil ) {    
-                URLScheme = [URLSchemes objectAtIndex:0];
-            }
-        }
-    }
-    
-    return URLScheme;
-}
-
-/*
- This method lets your application know that it is about to be terminated and purged from memory entirely
-*/
-- (void)applicationWillTerminate:(UIApplication *)application
-{
-
-    NSLog(@"applicationWillTerminate");
-    
-    // empty the tmp directory
-    NSFileManager* fileMgr = [[NSFileManager alloc] init];
-    NSError* err = nil;    
-
-    // clear contents of NSTemporaryDirectory 
-    NSString* tempDirectoryPath = NSTemporaryDirectory();
-    NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];    
-    NSString* fileName = nil;
-    BOOL result;
-    
-    while ((fileName = [directoryEnumerator nextObject])) {
-        NSString* filePath = [tempDirectoryPath stringByAppendingPathComponent:fileName];
-        result = [fileMgr removeItemAtPath:filePath error:&err];
-        if (!result && err) {
-            NSLog(@"Failed to delete: %@ (error: %@)", filePath, err);
-        }
-    }    
-    [fileMgr release];
-}
-
-/*
- This method is called to let your application know that it is about to move from the active to inactive state.
- You should use this method to pause ongoing tasks, disable timer, ...
-*/
-- (void)applicationWillResignActive:(UIApplication *)application
-{
-    //NSLog(@"%@",@"applicationWillResignActive");
-    [self.viewController.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('resign');"];
-}
-
-/*
- In iOS 4.0 and later, this method is called as part of the transition from the background to the inactive state. 
- You can use this method to undo many of the changes you made to your application upon entering the background.
- invariably followed by applicationDidBecomeActive
-*/
-- (void)applicationWillEnterForeground:(UIApplication *)application
-{
-    //NSLog(@"%@",@"applicationWillEnterForeground");
-    [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.viewController.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('active');"];
-}
-
-/*
- In iOS 4.0 and later, this method is called instead of the applicationWillTerminate: method 
- when the user quits an application that supports background execution.
- */
-- (void)applicationDidEnterBackground:(UIApplication *)application
-{
-    //NSLog(@"%@",@"applicationDidEnterBackground");
-    [self.viewController.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('pause');"];
-}
-
-
-/*
- Determine the URL passed to this application.
- Described in http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html
-*/
-- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
-{
-    if (!url) { 
-        return NO; 
-    }
-
-    // Do something with the url here
-    NSString* jsString = [NSString stringWithFormat:@"handleOpenURL(\"%@\");", url];
-    [self.viewController.webView stringByEvaluatingJavaScriptFromString:jsString];
-    
-    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:PGPluginHandleOpenURLNotification object:url]];
-    
-    return YES;
-}
-
-- (void)dealloc
-{
-    [PluginResult releaseStatus];
-    self.viewController = nil;
-    self.window = nil;
-    
-    [super dealloc];
-}
-
-@end
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/PGPlugin.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGPlugin.m b/PhoneGapLib/Classes/PGPlugin.m
index 65fec10..189cd56 100644
--- a/PhoneGapLib/Classes/PGPlugin.m
+++ b/PhoneGapLib/Classes/PGPlugin.m
@@ -19,7 +19,6 @@
 
 
 #import "PGPlugin.h"
-#import "PGAppDelegate.h"
 
 
 @implementation PGPlugin

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/PGSplashScreen.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGSplashScreen.m b/PhoneGapLib/Classes/PGSplashScreen.m
index c4097c6..9fb571c 100644
--- a/PhoneGapLib/Classes/PGSplashScreen.m
+++ b/PhoneGapLib/Classes/PGSplashScreen.m
@@ -19,7 +19,6 @@
 
 
 #import "PGSplashScreen.h"
-#import "PGAppDelegate.h"
 #import "PGViewController.h"
 #import "PhoneGapDelegate.h"
 
@@ -29,14 +28,17 @@
 - (void) __show:(BOOL)show
 {
     // Legacy support - once deprecated classes removed, clean this up
-    id delg = [self appDelegate];
+    id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
     
-    if ([delg isKindOfClass:[PGAppDelegate class]]) {
-        ((PGAppDelegate*)delg).viewController.imageView.hidden = !show;
-        ((PGAppDelegate*)delg).viewController.activityView.hidden = !show;
-    } if ([delg isKindOfClass:[PhoneGapDelegate class]]) {
-        ((PhoneGapDelegate*)delg).imageView.hidden = !show;
-        ((PhoneGapDelegate*)delg).activityView.hidden = !show;
+    if ([delegate isKindOfClass:[PhoneGapDelegate class]]) {
+        ((PhoneGapDelegate*)delegate).imageView.hidden = !show;
+        ((PhoneGapDelegate*)delegate).activityView.hidden = !show;
+    } else if ([delegate respondsToSelector:@selector(viewController)]) {
+        id vc = [delegate performSelector:@selector(viewController)];
+        if ([vc isKindOfClass:[PGViewController class]]) {
+            ((PGViewController*)vc).imageView.hidden = !show;
+            ((PGViewController*)vc).activityView.hidden = !show;
+        }
     }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/PGURLProtocol.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGURLProtocol.m b/PhoneGapLib/Classes/PGURLProtocol.m
index 6218453..1ba08e6 100644
--- a/PhoneGapLib/Classes/PGURLProtocol.m
+++ b/PhoneGapLib/Classes/PGURLProtocol.m
@@ -19,7 +19,6 @@
 
 #import "PGURLProtocol.h"
 #import "PGWhitelist.h"
-#import "PGAppDelegate.h"
 #import "PhoneGapDelegate.h"
 #import "PGViewController.h"
 
@@ -42,11 +41,15 @@ static PGWhitelist* gWhitelist = nil;
     NSString* theScheme = [theUrl scheme];
     
     if (gWhitelist == nil) {
-        id delegate = [[UIApplication sharedApplication] delegate];
-        if ([delegate isKindOfClass:[PGAppDelegate class]]) {
-            gWhitelist = [((PGAppDelegate*)delegate).viewController.whitelist retain];
-        } else if ([delegate isKindOfClass:[PhoneGapDelegate class]]) {
+        id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
+        
+        if ([delegate isKindOfClass:[PhoneGapDelegate class]]) {
             gWhitelist = [((PhoneGapDelegate*)delegate).whitelist retain];
+        } else if ([delegate respondsToSelector:@selector(viewController)]) {
+            id vc = [delegate performSelector:@selector(viewController)];
+            if ([vc isKindOfClass:[PGViewController class]]) {
+                gWhitelist = [((PGViewController*)vc).whitelist retain];
+            }
         }
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/PGViewController.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/PGViewController.m b/PhoneGapLib/Classes/PGViewController.m
index b07ed4f..a9d7b0a 100644
--- a/PhoneGapLib/Classes/PGViewController.m
+++ b/PhoneGapLib/Classes/PGViewController.m
@@ -56,8 +56,20 @@
     self = [super init];
     if (self != nil) {
         [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedOrientationChange) name:UIDeviceOrientationDidChangeNotification
-                                                   object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedOrientationChange) 
+                                                     name:UIDeviceOrientationDidChangeNotification object:nil];
+        
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillTerminate:) 
+                                                     name:UIApplicationWillTerminateNotification object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillResignActive:) 
+                                                     name:UIApplicationWillResignActiveNotification object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppWillEnterForeground:) 
+                                                     name:UIApplicationWillEnterForegroundNotification object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidBecomeActive:) 
+                                                     name:UIApplicationDidBecomeActiveNotification object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppDidEnterBackground:) 
+                                                     name:UIApplicationDidEnterBackgroundNotification object:nil];
+
         self.wwwFolderName = @"www";
         self.startPage = @"index.html";
     }
@@ -772,8 +784,6 @@ BOOL gSplashScreenShown = NO;
     return URLScheme;
 }
 
-
-
 /**
  Returns the contents of the named plist bundle, loaded as a dictionary object
  */
@@ -817,7 +827,86 @@ static NSString *gapVersion;
     return gapVersion;
 }
 
-- (void)dealloc {
+
+#pragma mark -
+#pragma mark UIApplicationDelegate impl
+
+/*
+ This method lets your application know that it is about to be terminated and purged from memory entirely
+ */
+- (void) onAppWillTerminate:(NSNotification*)notification
+{
+    NSLog(@"applicationWillTerminate");
+    
+    // empty the tmp directory
+    NSFileManager* fileMgr = [[NSFileManager alloc] init];
+    NSError* err = nil;    
+    
+    // clear contents of NSTemporaryDirectory 
+    NSString* tempDirectoryPath = NSTemporaryDirectory();
+    NSDirectoryEnumerator* directoryEnumerator = [fileMgr enumeratorAtPath:tempDirectoryPath];    
+    NSString* fileName = nil;
+    BOOL result;
+    
+    while ((fileName = [directoryEnumerator nextObject])) {
+        NSString* filePath = [tempDirectoryPath stringByAppendingPathComponent:fileName];
+        result = [fileMgr removeItemAtPath:filePath error:&err];
+        if (!result && err) {
+            NSLog(@"Failed to delete: %@ (error: %@)", filePath, err);
+        }
+    }    
+    [fileMgr release];
+}
+
+/*
+ This method is called to let your application know that it is about to move from the active to inactive state.
+ You should use this method to pause ongoing tasks, disable timer, ...
+ */
+- (void) onAppWillResignActive:(NSNotification*)notification
+{
+    //NSLog(@"%@",@"applicationWillResignActive");
+    [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('resign');"];
+}
+
+/*
+ In iOS 4.0 and later, this method is called as part of the transition from the background to the inactive state. 
+ You can use this method to undo many of the changes you made to your application upon entering the background.
+ invariably followed by applicationDidBecomeActive
+ */
+- (void) onAppWillEnterForeground:(NSNotification*)notification
+{
+    //NSLog(@"%@",@"applicationWillEnterForeground");
+    [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('resume');"];
+}
+
+// This method is called to let your application know that it moved from the inactive to active state. 
+- (void) onAppDidBecomeActive:(NSNotification*)notification
+{
+    //NSLog(@"%@",@"applicationDidBecomeActive");
+    [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('active');"];
+}
+
+/*
+ In iOS 4.0 and later, this method is called instead of the applicationWillTerminate: method 
+ when the user quits an application that supports background execution.
+ */
+- (void) onAppDidEnterBackground:(NSNotification*)notification
+{
+    //NSLog(@"%@",@"applicationDidEnterBackground");
+    [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('pause');"];
+}
+
+// ///////////////////////
+
+
+- (void)dealloc 
+{
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
+    
     [super dealloc];
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/Classes/Sound.m
----------------------------------------------------------------------
diff --git a/PhoneGapLib/Classes/Sound.m b/PhoneGapLib/Classes/Sound.m
index 7037a92..e96349a 100644
--- a/PhoneGapLib/Classes/Sound.m
+++ b/PhoneGapLib/Classes/Sound.m
@@ -19,7 +19,6 @@
 
 
 #import "Sound.h"
-#import "PGAppDelegate.h"
 #import "PGViewController.h"
 
 #define DOCUMENTS_SCHEME_PREFIX		@"documents://"

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/a2b4ec5a/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj b/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
index 49f5b37..ba51cec 100644
--- a/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
+++ b/PhoneGapLib/PhoneGapLib.xcodeproj/project.pbxproj
@@ -45,7 +45,6 @@
 		3032599E136B325100982B63 /* Location.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD471090FBE7009987E8 /* Location.m */; };
 		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 /* PGAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5B1090FBE7009987E8 /* PGAppDelegate.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 */; };
@@ -61,7 +60,6 @@
 		303259BC136B326300982B63 /* Location.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD461090FBE7009987E8 /* Location.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		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 /* PGAppDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5A1090FBE7009987E8 /* PGAppDelegate.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, ); }; };
@@ -163,8 +161,6 @@
 		8887FD8E1090FBE7009987E8 /* Notification.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD4F1090FBE7009987E8 /* Notification.m */; };
 		8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD501090FBE7009987E8 /* NSData+Base64.h */; };
 		8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD511090FBE7009987E8 /* NSData+Base64.m */; };
-		8887FD991090FBE7009987E8 /* PGAppDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 8887FD5A1090FBE7009987E8 /* PGAppDelegate.h */; };
-		8887FD9A1090FBE7009987E8 /* PGAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8887FD5B1090FBE7009987E8 /* PGAppDelegate.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 */; };
@@ -266,8 +262,6 @@
 		8887FD4F1090FBE7009987E8 /* Notification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Notification.m; path = Classes/Notification.m; sourceTree = "<group>"; };
 		8887FD501090FBE7009987E8 /* NSData+Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSData+Base64.h"; path = "Classes/NSData+Base64.h"; sourceTree = "<group>"; };
 		8887FD511090FBE7009987E8 /* NSData+Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSData+Base64.m"; path = "Classes/NSData+Base64.m"; sourceTree = "<group>"; };
-		8887FD5A1090FBE7009987E8 /* PGAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PGAppDelegate.h; path = Classes/PGAppDelegate.h; sourceTree = "<group>"; };
-		8887FD5B1090FBE7009987E8 /* PGAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PGAppDelegate.m; path = Classes/PGAppDelegate.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>"; };
@@ -495,8 +489,6 @@
 				8887FD361090FBE7009987E8 /* JSON */,
 				888700D910923009009987E8 /* Util */,
 				888700D810922FD3009987E8 /* Plugins */,
-				8887FD5A1090FBE7009987E8 /* PGAppDelegate.h */,
-				8887FD5B1090FBE7009987E8 /* PGAppDelegate.m */,
 			);
 			name = Classes;
 			sourceTree = "<group>";
@@ -528,7 +520,6 @@
 				303259BC136B326300982B63 /* Location.h in Headers */,
 				303259BF136B326300982B63 /* Notification.h in Headers */,
 				303259C0136B326300982B63 /* NSData+Base64.h in Headers */,
-				303259C2136B326300982B63 /* PGAppDelegate.h in Headers */,
 				303259C4136B326300982B63 /* Reachability.h in Headers */,
 				303259C5136B326300982B63 /* Sound.h in Headers */,
 				303259C6136B326300982B63 /* Accelerometer.h in Headers */,
@@ -567,7 +558,6 @@
 				8887FD851090FBE7009987E8 /* Location.h in Headers */,
 				8887FD8D1090FBE7009987E8 /* Notification.h in Headers */,
 				8887FD8F1090FBE7009987E8 /* NSData+Base64.h in Headers */,
-				8887FD991090FBE7009987E8 /* PGAppDelegate.h in Headers */,
 				8887FD9D1090FBE7009987E8 /* Reachability.h in Headers */,
 				8887FD9F1090FBE7009987E8 /* Sound.h in Headers */,
 				88BA573D109BB46F00FB5E78 /* Accelerometer.h in Headers */,
@@ -787,7 +777,6 @@
 				304D303E14C4F74700261D84 /* PhoneGapViewController.m in Sources */,
 				8852C43D14B65FD800F0E735 /* PGViewController.m in Sources */,
 				303259A2136B325100982B63 /* NSData+Base64.m in Sources */,
-				303259A4136B325100982B63 /* PGAppDelegate.m in Sources */,
 				8852C44214B65FD800F0E735 /* UIGapView.m in Sources */,
 				303259A6136B325100982B63 /* Reachability.m in Sources */,
 				303259A7136B325100982B63 /* Sound.m in Sources */,
@@ -832,7 +821,6 @@
 				8887FD861090FBE7009987E8 /* Location.m in Sources */,
 				8887FD8E1090FBE7009987E8 /* Notification.m in Sources */,
 				8887FD901090FBE7009987E8 /* NSData+Base64.m in Sources */,
-				8887FD9A1090FBE7009987E8 /* PGAppDelegate.m in Sources */,
 				8887FD9E1090FBE7009987E8 /* Reachability.m in Sources */,
 				8887FDA01090FBE7009987E8 /* Sound.m in Sources */,
 				88BA573E109BB46F00FB5E78 /* Accelerometer.m in Sources */,


Mime
View raw message