You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2013/02/25 14:41:02 UTC

[15/50] ios commit: [CB-2443] Add pluginInitialize method to CDVPlugin.

[CB-2443] Add pluginInitialize method to CDVPlugin.


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

Branch: refs/heads/multipart_plugin_result
Commit: fadf267c093d264bcfd9ba667934d5833ce453a3
Parents: 8d22b4c
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Feb 14 13:24:56 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Fri Feb 15 10:12:46 2013 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVPlugin.h         |    1 +
 CordovaLib/Classes/CDVPlugin.m         |   30 +++++++++++++-------------
 CordovaLib/Classes/CDVViewController.m |    9 ++-----
 3 files changed, 19 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/fadf267c/CordovaLib/Classes/CDVPlugin.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.h b/CordovaLib/Classes/CDVPlugin.h
index 8c59a2b..5264ca0 100644
--- a/CordovaLib/Classes/CDVPlugin.h
+++ b/CordovaLib/Classes/CDVPlugin.h
@@ -38,6 +38,7 @@
 
 - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings;
 - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView;
+- (void)pluginInitialize;
 
 - (void)handleOpenURL:(NSNotification*)notification;
 - (void)onAppTerminate;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/fadf267c/CordovaLib/Classes/CDVPlugin.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.m b/CordovaLib/Classes/CDVPlugin.m
index d500d7c..f8ff0a0 100644
--- a/CordovaLib/Classes/CDVPlugin.m
+++ b/CordovaLib/Classes/CDVPlugin.m
@@ -28,12 +28,12 @@
 @implementation CDVPlugin
 @synthesize webView, settings, viewController, commandDelegate, hasPendingOperation;
 
+// Do not override these methods. Use pluginInitialize instead.
 - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings
 {
     self = [self initWithWebView:theWebView];
     if (self) {
         self.settings = classSettings;
-        self.hasPendingOperation = NO;
     }
     return self;
 }
@@ -48,24 +48,24 @@
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onReset) name:CDVPluginResetNotification object:nil];
 
         self.webView = theWebView;
+    }
+    return self;
+}
 
-        // You can listen to more app notifications, see:
-        // http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-DontLinkElementID_4
-
-        /*
-         // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler
+- (void)pluginInitialize
+{
+    // You can listen to more app notifications, see:
+    // http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-DontLinkElementID_4
 
-         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
-         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
-         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
-         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
+    // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler
 
-         // Added in 2.3.0+
-         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil];
+    // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
+    // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
+    // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
+    // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
 
-         */
-    }
-    return self;
+    // Added in 2.3.0
+    // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil];
 }
 
 - (void)dispose

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/fadf267c/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 8ffe3a0..ffa3212 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -818,6 +818,7 @@ BOOL gSplashScreenShown = NO;
     }
 
     [self.pluginObjects setObject:plugin forKey:className];
+    [plugin pluginInitialize];
 }
 
 /**
@@ -841,13 +842,9 @@ BOOL gSplashScreenShown = NO;
         // attempt to load the settings for this command class
         NSDictionary* classSettings = [self.settings objectForKey:className];
 
-        if (classSettings) {
-            obj = [[NSClassFromString (className)alloc] initWithWebView:webView settings:classSettings];
-        } else {
-            obj = [[NSClassFromString (className)alloc] initWithWebView:webView];
-        }
+        obj = [[NSClassFromString (className)alloc] initWithWebView:webView settings:classSettings];
 
-        if ((obj != nil) && [obj isKindOfClass:[CDVPlugin class]]) {
+        if (obj != nil) {
             [self registerPlugin:obj withClassName:className];
         } else {
             NSLog(@"CDVPlugin class %@ (pluginName: %@) does not exist.", className, pluginName);