You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/03/16 19:14:49 UTC
[27/29] ios commit: device initialization going with a require-based
pattern
device initialization going with a require-based pattern
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/7afc28a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/7afc28a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/7afc28a0
Branch: refs/heads/master
Commit: 7afc28a0c9d610a07faf500da1bb9cd20766f7cf
Parents: b9a6d22
Author: Fil Maj <fi...@nitobi.com>
Authored: Thu Feb 23 10:11:01 2012 -0800
Committer: Fil Maj <ma...@gmail.com>
Committed: Fri Mar 16 10:56:48 2012 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVViewController.m | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/7afc28a0/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 807dd79..92b9a4a 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -166,6 +166,7 @@
*/
if ([enableLocation boolValue]) {
+ // TODO: change this package name
[[self.commandDelegate getCommandInstance:@"org.apache.cordova.geolocation"] startLocation:nil withDict:nil];
}
@@ -308,7 +309,7 @@
i = 90;
break;
}
-
+ // TODO: update JS references here
NSString* jsCallback = [NSString stringWithFormat:@"window.__defineGetter__('orientation',function(){ return %d; }); Cordova.fireEvent('orientationchange', window);",i];
[self.webView stringByEvaluatingJavaScriptFromString:jsCallback];
}
@@ -361,19 +362,19 @@
- (void) webViewDidFinishLoad:(UIWebView*)theWebView
{
// Share session key with the WebView by setting Cordova.sessionKey
+ // TODO: wtf is the sessionKey ?
NSString *sessionKeyScript = [NSString stringWithFormat:@"Cordova.sessionKey = \"%@\";", self.sessionKey];
[theWebView stringByEvaluatingJavaScriptFromString:sessionKeyScript];
-
NSDictionary *deviceProperties = [ self deviceProperties];
- NSMutableString *result = [[NSMutableString alloc] initWithFormat:@"DeviceInfo = %@;", [deviceProperties JSONString]];
+ NSMutableString *result = [[NSMutableString alloc] initWithFormat:@"try{require('cordova/plugin/ios/device').setInfo(%@);}catch(e){alert('errorz1!!!');alert(JSON.stringify(e))}", [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).
*/
-
+ // TODO: turn this into an iOS only plugin
NSDictionary *temp = [[self class] getBundlePlist:@"Settings"];
if ([temp respondsToSelector:@selector(JSONString)]) {
[result appendFormat:@"\nwindow.Settings = %@;", [temp JSONString]];
@@ -685,7 +686,7 @@ BOOL gSplashScreenShown = NO;
{
// Grab all the queued commands from the JS side.
NSString* queuedCommandsJSON = [self.webView stringByEvaluatingJavaScriptFromString:
- @"Cordova.getAndClearQueuedCommands()"];
+ @"require('cordova/plugin/ios/nativecomm')()"];
// Parse the returned JSON array.
@@ -713,7 +714,7 @@ BOOL gSplashScreenShown = NO;
- (void) flushCommandQueue
{
[self.webView stringByEvaluatingJavaScriptFromString:
- @"Cordova.commandQueueFlushing = true"];
+ @"require('cordova').commandQueueFlushing = true"];
// Keep executing the command queue until no commands get executed.
// This ensures that commands that are queued while executing other
@@ -724,7 +725,7 @@ BOOL gSplashScreenShown = NO;
} while (numExecutedCommands != 0);
[self.webView stringByEvaluatingJavaScriptFromString:
- @"Cordova.commandQueueFlushing = false"];
+ @"require('cordova').commandQueueFlushing = false"];
}
- (BOOL) execute:(CDVInvokedUrlCommand*)command