incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [24/29] ios commit: updating refs from require("cordova") to just "cordova", and other require calls to cordova.require
Date Fri, 16 Mar 2012 18:14:49 GMT
updating refs from require("cordova") to just "cordova", and other require calls to cordova.require


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

Branch: refs/heads/master
Commit: 74c9787340d6c38c46848f2d8df4b61068d44ef6
Parents: 7c7a8c4
Author: Fil Maj <maj.fil@gmail.com>
Authored: Fri Mar 9 12:54:18 2012 -0800
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Fri Mar 16 10:56:49 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVPluginResult.m   |    8 +++---
 CordovaLib/Classes/CDVSound.m          |   28 +++++++++++++-------------
 CordovaLib/Classes/CDVViewController.m |   27 +++++++++++++++++--------
 3 files changed, 36 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/74c97873/CordovaLib/Classes/CDVPluginResult.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.m b/CordovaLib/Classes/CDVPluginResult.m
index 3f42516..30704bc 100644
--- a/CordovaLib/Classes/CDVPluginResult.m
+++ b/CordovaLib/Classes/CDVPluginResult.m
@@ -143,10 +143,10 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
 	NSString* successCB;
 	
 	if ([self cast] != nil) {
-		successCB = [NSString stringWithFormat: @"var temp = %@(%@);\nrequire('cordova').callbackSuccess('%@',temp);",
self.cast, [self toJSONString], callbackId];
+		successCB = [NSString stringWithFormat: @"var temp = %@(%@);\ncordova.callbackSuccess('%@',temp);",
self.cast, [self toJSONString], callbackId];
 	}
 	else {
-		successCB = [NSString stringWithFormat:@"require('cordova').callbackSuccess('%@',%@);",
callbackId, [self toJSONString]];			
+		successCB = [NSString stringWithFormat:@"cordova.callbackSuccess('%@',%@);", callbackId,
[self toJSONString]];			
 	}
 	DLog(@"PluginResult toSuccessCallbackString: %@", successCB);
 	return successCB;
@@ -157,10 +157,10 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
 	NSString* errorCB = nil;
 	
 	if ([self cast] != nil) {
-		errorCB = [NSString stringWithFormat: @"var temp = %@(%@);\nrequire('cordova').callbackError('%@',temp);",
self.cast, [self toJSONString], callbackId];
+		errorCB = [NSString stringWithFormat: @"var temp = %@(%@);\ncordova.callbackError('%@',temp);",
self.cast, [self toJSONString], callbackId];
 	}
 	else {
-		errorCB = [NSString stringWithFormat:@"require('cordova').callbackError('%@',%@);", callbackId,
[self toJSONString]];
+		errorCB = [NSString stringWithFormat:@"cordova.callbackError('%@',%@);", callbackId, [self
toJSONString]];
 	}
 	DLog(@"PluginResult toErrorCallbackString: %@", errorCB);
 	return errorCB;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/74c97873/CordovaLib/Classes/CDVSound.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSound.m b/CordovaLib/Classes/CDVSound.m
index ef69dd7..be4b3be 100644
--- a/CordovaLib/Classes/CDVSound.m
+++ b/CordovaLib/Classes/CDVSound.m
@@ -105,7 +105,7 @@
 			errMsg = [NSString stringWithFormat: @"Cannot use audio file from resource '%@'", resourcePath];
 		}
 		if (bError) {
-			jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, errcode];
+			jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, errcode];
             //jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR,[self createMediaErrorWithCode: errcode message: errMsg]];
 			[super writeJavascript:jsString];
 		} else {
@@ -188,7 +188,7 @@
                 }
                 [audioFile.player play];
                 double position = round(audioFile.player.duration * 1000)/1000;
-                jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);",
@"require('cordova/plugin/Media').onStatus", mediaId, MEDIA_DURATION, position, @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_RUNNING];
+                jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);",
@"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_DURATION, position, @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_RUNNING];
                 [super writeJavascript:jsString];
                 
             }
@@ -207,7 +207,7 @@
 				[audioFile.player play];
 			} */
 			// error creating the session or player
-			jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR,  MEDIA_ERR_NONE_SUPPORTED];
+			jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR,  MEDIA_ERR_NONE_SUPPORTED];
             //jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_NONE_SUPPORTED message: nil]];
 			[super writeJavascript:jsString];
 		}
@@ -319,7 +319,7 @@
         NSLog(@"Stopped playing audio sample '%@'", audioFile.resourcePath);
         [audioFile.player stop];
         audioFile.player.currentTime = 0;
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_STOPPED];
+        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_STOPPED];
 	}  // ignore if no media playing 
     if (jsString){
         [super writeJavascript: jsString];
@@ -337,7 +337,7 @@
 	if (audioFile != nil && audioFile.player != nil) {
             NSLog(@"Paused playing audio sample '%@'", audioFile.resourcePath);
 			[audioFile.player pause];
-            jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_PAUSED];
+            jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_PAUSED];
 	} 
     // ignore if no media playing
       
@@ -366,7 +366,7 @@
     if (audioFile != nil && audioFile.player != nil && position){
         double posInSeconds = position/1000;
         audioFile.player.currentTime = posInSeconds;
-        NSString* jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%f);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_POSITION, posInSeconds];
+        NSString* jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%f);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_POSITION, posInSeconds];
 
         [super writeJavascript: jsString];
         
@@ -417,7 +417,7 @@
             position = round(audioFile.player.currentTime *1000)/1000;
     }
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:
position];
-	NSString* jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%.3f);\n%@", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_POSITION, position, [result toSuccessCallbackString:callbackId]];
+	NSString* jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%.3f);\n%@", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_POSITION, position, [result toSuccessCallbackString:callbackId]];
     [super writeJavascript:jsString];
     
 	return;
@@ -448,7 +448,7 @@
             if (![self.avSession  setActive: YES error: &error]){
                 // other audio with higher priority that does not allow mixing could cause
this to fail
                 errorMsg = [NSString stringWithFormat: @"Unable to record audio: %@", [error
localizedFailureReason]];
-                jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
+                jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
                // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_ABORTED message: errorMsg]
];
                 [super writeJavascript:jsString];
                 return;
@@ -464,7 +464,7 @@
             if (self.avSession) {
                 [self.avSession setActive:NO error:nil];
             }
-			jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
+			jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
 			//jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_ABORTED message: errorMsg]];
 			
 		} else {
@@ -472,7 +472,7 @@
 			audioFile.recorder.mediaId = mediaId;
 			[audioFile.recorder record];
 			NSLog(@"Started recording audio sample '%@'", audioFile.resourcePath);
-            jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_RUNNING];
+            jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_RUNNING];
 		}
 	}
     if (jsString) {
@@ -513,9 +513,9 @@
 		NSLog(@"Finished recording audio sample '%@'", audioFile.resourcePath);
     }
     if (flag){
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_STOPPED];
+        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_STOPPED];
     } else {
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
+        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
         //jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_DECODE message:nil]];
     }
     if (self.avSession) {
@@ -536,10 +536,10 @@
 		NSLog(@"Finished playing audio sample '%@'", audioFile.resourcePath);
     }
     if (flag){
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_STOPPED];
+        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_STATE, MEDIA_STOPPED];
         
     } else {
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
+        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
         //jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"require('cordova/plugin/Media').onStatus",
mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_DECODE message:nil]];
         
     }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/74c97873/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index c5c0153..6058e5b 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -366,7 +366,7 @@
     [theWebView stringByEvaluatingJavaScriptFromString:sessionKeyScript];
 	
     NSDictionary *deviceProperties = [ self deviceProperties];
-    NSMutableString *result = [[NSMutableString alloc] initWithFormat:@"try{require('cordova/plugin/ios/device').setInfo(%@);}catch(e){alert('errorz1!!!');alert(JSON.stringify(e))}",
[deviceProperties JSONString]];
+    NSMutableString *result = [[NSMutableString alloc] initWithFormat:@"try{cordova.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.
@@ -399,7 +399,7 @@
     [self didRotateFromInterfaceOrientation:(UIInterfaceOrientation)[[UIDevice currentDevice]
orientation]];
     
     // Tell the webview that native is ready.
-    NSString* nativeReady = @"try{require('cordova/channel').onNativeReady.fire();}catch(e){window._nativeReady
= true;}";
+    NSString* nativeReady = @"try{cordova.require('cordova/channel').onNativeReady.fire();}catch(e){window._nativeReady
= true;}";
     [theWebView stringByEvaluatingJavaScriptFromString:nativeReady];
 }
 
@@ -689,7 +689,7 @@ BOOL gSplashScreenShown = NO;
 {
     // Grab all the queued commands from the JS side.
     NSString* queuedCommandsJSON = [self.webView stringByEvaluatingJavaScriptFromString:
-									@"require('cordova/plugin/ios/nativecomm')()"];
+									@"cordova.require('cordova/plugin/ios/nativecomm')()"];
 	
 	
     // Parse the returned JSON array.
@@ -717,7 +717,7 @@ BOOL gSplashScreenShown = NO;
 - (void) flushCommandQueue
 {
     [self.webView stringByEvaluatingJavaScriptFromString:
-	 @"require('cordova').commandQueueFlushing = true"];
+	 @"cordova.commandQueueFlushing = true"];
 	
     // Keep executing the command queue until no commands get executed.
     // This ensures that commands that are queued while executing other
@@ -728,11 +728,20 @@ BOOL gSplashScreenShown = NO;
     } while (numExecutedCommands != 0);
 	
     [self.webView stringByEvaluatingJavaScriptFromString:
-	 @"require('cordova').commandQueueFlushing = false"];
+	 @"cordova.commandQueueFlushing = false"];
 }
 
 - (BOOL) execute:(CDVInvokedUrlCommand*)command
 {
+    NSLog(@"execute %@ : %@", command.className, command.methodName);
+    NSLog(@"arguments:");
+    for (id t in command.arguments) {
+        NSLog(@"%@", t);
+    }
+    NSLog(@"options:");
+    for (id t in command.options) {
+        NSLog(@"%@", t);
+    }
     if (command.className == nil || command.methodName == nil) {
         return NO;
     }
@@ -920,7 +929,7 @@ static NSString* cdvVersion;
 {
     //NSLog(@"%@",@"applicationWillResignActive");
     // TODO: uhh, wut? pause/resume not enough?
-    [self.webView stringByEvaluatingJavaScriptFromString:@"require('cordova').fireDocumentEvent('resign');"];
+    [self.webView stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('resign');"];
 }
 
 /*
@@ -931,7 +940,7 @@ static NSString* cdvVersion;
 - (void) onAppWillEnterForeground:(NSNotification*)notification
 {
     //NSLog(@"%@",@"applicationWillEnterForeground");
-    [self.webView stringByEvaluatingJavaScriptFromString:@"require('cordova').fireDocumentEvent('resume');"];
+    [self.webView stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('resume');"];
 }
 
 // This method is called to let your application know that it moved from the inactive to
active state. 
@@ -939,7 +948,7 @@ static NSString* cdvVersion;
 {
     //NSLog(@"%@",@"applicationDidBecomeActive");
     // TODO: uhh, wut? pause/resume not enough?
-    [self.webView stringByEvaluatingJavaScriptFromString:@"require('cordova').fireDocumentEvent('active');"];
+    [self.webView stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('active');"];
 }
 
 /*
@@ -949,7 +958,7 @@ static NSString* cdvVersion;
 - (void) onAppDidEnterBackground:(NSNotification*)notification
 {
     //NSLog(@"%@",@"applicationDidEnterBackground");
-    [self.webView stringByEvaluatingJavaScriptFromString:@"require('cordova').fireDocumentEvent('pause');"];
+    [self.webView stringByEvaluatingJavaScriptFromString:@"cordova.fireDocumentEvent('pause');"];
 }
 
 // ///////////////////////


Mime
View raw message