incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [17/29] ios commit: using require in pluginresult helper funcs. added getConnectionInfo method to connection plugin to line up with other platforms
Date Fri, 16 Mar 2012 18:14:49 GMT
using require in pluginresult helper funcs. added getConnectionInfo method to connection plugin
to line up with other platforms


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

Branch: refs/heads/master
Commit: e0023ca51090ada14cc5a8dc770ca44be085cff9
Parents: 22fc69c
Author: Fil Maj <filip.maj@nitobi.com>
Authored: Thu Feb 23 11:52:03 2012 -0800
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Fri Mar 16 10:56:49 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVConnection.m   |   10 ++++++++--
 CordovaLib/Classes/CDVPluginResult.m |   10 ++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/e0023ca5/CordovaLib/Classes/CDVConnection.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVConnection.m b/CordovaLib/Classes/CDVConnection.m
index ba19f70..f3bd758 100644
--- a/CordovaLib/Classes/CDVConnection.m
+++ b/CordovaLib/Classes/CDVConnection.m
@@ -29,9 +29,15 @@
 
 @synthesize connectionType, internetReach;
 
-- (NSString*) getConnectionInfo
+- (void) getConnectionInfo:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
 {
-    return self.connectionType;
+    CDVPluginResult* result = nil;
+    NSString* jsString = nil;
+	NSString* callbackId = [arguments objectAtIndex:0];
+    
+    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:self.connectionType];
+    jsString = [result toSuccessCallbackString:callbackId];
+    [self writeJavascript:jsString];
 }
 
 - (NSString*) w3cConnectionTypeFor:(CDVReachability*)reachability

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/e0023ca5/CordovaLib/Classes/CDVPluginResult.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.m b/CordovaLib/Classes/CDVPluginResult.m
index 57f1577..3f42516 100644
--- a/CordovaLib/Classes/CDVPluginResult.m
+++ b/CordovaLib/Classes/CDVPluginResult.m
@@ -137,28 +137,30 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
 	DLog(@"PluginResult:toJSONString - %@", resultString);
 	return resultString;
 }
+// TODO: get rid of casting
 -(NSString*) toSuccessCallbackString: (NSString*) callbackId
 {
 	NSString* successCB;
 	
 	if ([self cast] != nil) {
-		successCB = [NSString stringWithFormat: @"var temp = %@(%@);\nCordova.callbackSuccess('%@',temp);",
self.cast, [self toJSONString], callbackId];
+		successCB = [NSString stringWithFormat: @"var temp = %@(%@);\nrequire('cordova').callbackSuccess('%@',temp);",
self.cast, [self toJSONString], callbackId];
 	}
 	else {
-		successCB = [NSString stringWithFormat:@"Cordova.callbackSuccess('%@',%@);", callbackId,
[self toJSONString]];			
+		successCB = [NSString stringWithFormat:@"require('cordova').callbackSuccess('%@',%@);",
callbackId, [self toJSONString]];			
 	}
 	DLog(@"PluginResult toSuccessCallbackString: %@", successCB);
 	return successCB;
 }
+// TODO: get rid of casting
 -(NSString*) toErrorCallbackString: (NSString*) callbackId
 {
 	NSString* errorCB = nil;
 	
 	if ([self cast] != nil) {
-		errorCB = [NSString stringWithFormat: @"var temp = %@(%@);\nCordova.callbackError('%@',temp);",
self.cast, [self toJSONString], callbackId];
+		errorCB = [NSString stringWithFormat: @"var temp = %@(%@);\nrequire('cordova').callbackError('%@',temp);",
self.cast, [self toJSONString], callbackId];
 	}
 	else {
-		errorCB = [NSString stringWithFormat:@"Cordova.callbackError('%@',%@);", callbackId, [self
toJSONString]];
+		errorCB = [NSString stringWithFormat:@"require('cordova').callbackError('%@',%@);", callbackId,
[self toJSONString]];
 	}
 	DLog(@"PluginResult toErrorCallbackString: %@", errorCB);
 	return errorCB;


Mime
View raw message