cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [1/2] ios commit: [CB-1970] MainViewController cannot override pathForResource
Date Fri, 07 Dec 2012 19:35:00 GMT
Updated Branches:
  refs/heads/master d63cf46a4 -> 8f4c46d57


[CB-1970] MainViewController cannot override pathForResource


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

Branch: refs/heads/master
Commit: 495ab52d2e69bde3728404ec31873bbfce9286b1
Parents: d63cf46
Author: Shazron Abdullah <shazron@apache.org>
Authored: Thu Dec 6 16:41:52 2012 -0800
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Fri Dec 7 11:34:48 2012 -0800

----------------------------------------------------------------------
 CordovaLib/Classes/CDVCommandDelegateImpl.h        |    1 +
 CordovaLib/Classes/CDVCommandQueue.m               |    3 +-
 CordovaLib/Classes/CDVViewController.h             |    4 +-
 CordovaLib/Classes/CDVViewController.m             |    5 +-
 .../__TESTING__/Classes/MainViewController.h       |    8 ++
 .../__TESTING__/Classes/MainViewController.m       |   85 ++++++++++-----
 6 files changed, 75 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/495ab52d/CordovaLib/Classes/CDVCommandDelegateImpl.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandDelegateImpl.h b/CordovaLib/Classes/CDVCommandDelegateImpl.h
index ee3be39..6735136 100644
--- a/CordovaLib/Classes/CDVCommandDelegateImpl.h
+++ b/CordovaLib/Classes/CDVCommandDelegateImpl.h
@@ -26,6 +26,7 @@
 @interface CDVCommandDelegateImpl : NSObject <CDVCommandDelegate>{
     @private
     __weak CDVViewController* _viewController;
+    @protected
     __weak CDVCommandQueue* _commandQueue;
 }
 - (id)initWithViewController:(CDVViewController*)viewController;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/495ab52d/CordovaLib/Classes/CDVCommandQueue.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandQueue.m b/CordovaLib/Classes/CDVCommandQueue.m
index ae6bfa7..d88a730 100644
--- a/CordovaLib/Classes/CDVCommandQueue.m
+++ b/CordovaLib/Classes/CDVCommandQueue.m
@@ -21,6 +21,7 @@
 #import "CDV.h"
 #import "CDVCommandQueue.h"
 #import "CDVViewController.h"
+#import "CDVCommandDelegateImpl.h"
 
 @implementation CDVCommandQueue
 
@@ -120,7 +121,7 @@
     }
 
     // Fetch an instance of this class
-    CDVPlugin* obj = [_viewController getCommandInstance:command.className];
+    CDVPlugin* obj = [_viewController.commandDelegate getCommandInstance:command.className];
 
     if (!([obj isKindOfClass:[CDVPlugin class]])) {
         NSLog(@"ERROR: Plugin '%@' not found, or is not a CDVPlugin. Check your plugin mapping
in config.xml.", command.className);

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/495ab52d/CordovaLib/Classes/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.h b/CordovaLib/Classes/CDVViewController.h
index b8f1e13..a5f6b0d 100644
--- a/CordovaLib/Classes/CDVViewController.h
+++ b/CordovaLib/Classes/CDVViewController.h
@@ -30,8 +30,10 @@
 @class CDVCommandDelegateImpl;
 
 @interface CDVViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{
-    @private
+    @protected
     CDVCommandDelegateImpl* _commandDelegate;
+    @protected
+    CDVCommandQueue* _commandQueue;
     NSString* _userAgent;
 }
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/495ab52d/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 93a3da3..ee926ca 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -53,6 +53,7 @@ static NSString* gOriginalUserAgent = nil;
 @synthesize imageView, activityView, useSplashScreen;
 @synthesize wwwFolderName, startPage, invokeString, initialized;
 @synthesize commandDelegate = _commandDelegate;
+@synthesize commandQueue = _commandQueue;
 
 - (void)__init
 {
@@ -178,7 +179,7 @@ static NSString* gOriginalUserAgent = nil;
     } else if ([self.wwwFolderName rangeOfString:@"://"].location != NSNotFound) {
         appURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@", self.wwwFolderName,
self.startPage]];
     } else {
-        NSString* startFilePath = [_commandDelegate pathForResource:self.startPage];
+        NSString* startFilePath = [self.commandDelegate pathForResource:self.startPage];
         if (startFilePath == nil) {
             loadErr = [NSString stringWithFormat:@"ERROR: Start Page at '%@/%@' was not found.",
self.wwwFolderName, self.startPage];
             NSLog(@"%@", loadErr);
@@ -226,7 +227,7 @@ static NSString* gOriginalUserAgent = nil;
      */
 
     if ([enableLocation boolValue]) {
-        [[self getCommandInstance:@"Geolocation"] getLocation:[CDVInvokedUrlCommand new]];
+        [[self.commandDelegate getCommandInstance:@"Geolocation"] getLocation:[CDVInvokedUrlCommand
new]];
     }
 
     /*

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/495ab52d/bin/templates/project/__TESTING__/Classes/MainViewController.h
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Classes/MainViewController.h b/bin/templates/project/__TESTING__/Classes/MainViewController.h
index a821b06..d9f19a2 100644
--- a/bin/templates/project/__TESTING__/Classes/MainViewController.h
+++ b/bin/templates/project/__TESTING__/Classes/MainViewController.h
@@ -26,7 +26,15 @@
 //
 
 #import <Cordova/CDVViewController.h>
+#import <Cordova/CDVCommandDelegateImpl.h>
+#import <Cordova/CDVCommandQueue.h>
 
 @interface MainViewController : CDVViewController
 
 @end
+
+@interface MainCommandDelegate : CDVCommandDelegateImpl
+@end
+
+@interface MainCommandQueue : CDVCommandQueue
+@end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/495ab52d/bin/templates/project/__TESTING__/Classes/MainViewController.m
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/Classes/MainViewController.m b/bin/templates/project/__TESTING__/Classes/MainViewController.m
index d77dee6..b70c93b 100644
--- a/bin/templates/project/__TESTING__/Classes/MainViewController.m
+++ b/bin/templates/project/__TESTING__/Classes/MainViewController.m
@@ -33,7 +33,22 @@
 {
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
     if (self) {
-        // Custom initialization
+        // Uncomment to override the CDVCommandDelegateImpl used
+        // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
+        // Uncomment to override the CDVCommandQueue used
+        // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
+    }
+    return self;
+}
+
+- (id)init
+{
+    self = [super init];
+    if (self) {
+        // Uncomment to override the CDVCommandDelegateImpl used
+        // _commandDelegate = [[MainCommandDelegate alloc] initWithViewController:self];
+        // Uncomment to override the CDVCommandQueue used
+        // _commandQueue = [[MainCommandQueue alloc] initWithViewController:self];
     }
     return self;
 }
@@ -84,32 +99,6 @@
 }
 */
 
-/* Comment out the block below to over-ride */
-
-/*
-#pragma CDVCommandDelegate implementation
-
-- (id) getCommandInstance:(NSString*)className
-{
-    return [super getCommandInstance:className];
-}
-
-- (BOOL) execute:(CDVInvokedUrlCommand*)command
-{
-    return [super execute:command];
-}
-
-- (NSString*) pathForResource:(NSString*)resourcepath;
-{
-    return [super pathForResource:resourcepath];
-}
-
-- (void) registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className
-{
-    return [super registerPlugin:plugin withClassName:className];
-}
-*/
-
 #pragma UIWebDelegate implementation
 
 - (void)webViewDidFinishLoad:(UIWebView*)theWebView
@@ -141,3 +130,45 @@
 */
 
 @end
+
+@implementation MainCommandDelegate
+
+/* To override the methods, uncomment the line in the init function(s)
+   in MainViewController.m
+ */
+
+#pragma CDVCommandDelegate implementation
+
+- (id)getCommandInstance:(NSString*)className
+{
+    return [super getCommandInstance:className];
+}
+
+/*
+   NOTE: this will only inspect execute calls coming explicitly from native plugins,
+   not the commandQueue (from JavaScript). To see execute calls from JavaScript, see
+   MainCommandQueue below
+*/
+- (BOOL)execute:(CDVInvokedUrlCommand*)command
+{
+    return [super execute:command];
+}
+
+- (NSString*)pathForResource:(NSString*)resourcepath;
+{
+    return [super pathForResource:resourcepath];
+}
+
+@end
+
+@implementation MainCommandQueue
+
+/* To override, uncomment the line in the init function(s)
+   in MainViewController.m
+ */
+- (BOOL)execute:(CDVInvokedUrlCommand*)command
+{
+    return [super execute:command];
+}
+
+@end


Mime
View raw message