cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [2/2] ios commit: [CB-2443] Removed classSettings initializer from CDVPlugin
Date Fri, 15 Feb 2013 19:07:20 GMT
Updated Branches:
  refs/heads/master 8d22b4cc8 -> b55609eff


[CB-2443] Removed classSettings initializer from CDVPlugin

And added a way to get at settings through CDVCommandDelegate.


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

Branch: refs/heads/master
Commit: b55609eff66667ba498b67dbe8d59dca4ecce4d8
Parents: fadf267
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu Feb 14 17:49:23 2013 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Fri Feb 15 13:48:50 2013 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVCommandDelegate.h     |    2 ++
 CordovaLib/Classes/CDVCommandDelegateImpl.m |    5 +++++
 CordovaLib/Classes/CDVLocalStorage.m        |   21 +++++++++------------
 CordovaLib/Classes/CDVPlugin.h              |    2 --
 CordovaLib/Classes/CDVPlugin.m              |    8 ++------
 CordovaLib/Classes/CDVViewController.h      |    2 +-
 CordovaLib/Classes/CDVViewController.m      |   13 +++++--------
 7 files changed, 24 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b55609ef/CordovaLib/Classes/CDVCommandDelegate.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandDelegate.h b/CordovaLib/Classes/CDVCommandDelegate.h
index fdc033e..e177c63 100644
--- a/CordovaLib/Classes/CDVCommandDelegate.h
+++ b/CordovaLib/Classes/CDVCommandDelegate.h
@@ -26,6 +26,8 @@
 
 @protocol CDVCommandDelegate <NSObject>
 
+@property (nonatomic, readonly) NSDictionary* settings;
+
 - (NSString*)pathForResource:(NSString*)resourcepath;
 - (id)getCommandInstance:(NSString*)pluginName;
 - (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className CDV_DEPRECATED(2.2,
"Use CDVViewController to register plugins, or use config.xml.");

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b55609ef/CordovaLib/Classes/CDVCommandDelegateImpl.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVCommandDelegateImpl.m b/CordovaLib/Classes/CDVCommandDelegateImpl.m
index 8ff60ee..e399289 100644
--- a/CordovaLib/Classes/CDVCommandDelegateImpl.m
+++ b/CordovaLib/Classes/CDVCommandDelegateImpl.m
@@ -143,4 +143,9 @@
            [_viewController.whitelist URLIsAllowed:url];
 }
 
+- (NSDictionary*)settings
+{
+    return _viewController.settings;
+}
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b55609ef/CordovaLib/Classes/CDVLocalStorage.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocalStorage.m b/CordovaLib/Classes/CDVLocalStorage.m
index 217f611..57b37ee 100644
--- a/CordovaLib/Classes/CDVLocalStorage.m
+++ b/CordovaLib/Classes/CDVLocalStorage.m
@@ -31,21 +31,18 @@
 
 @synthesize backupInfo, webviewDelegate;
 
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings
+- (void)pluginInitialize
 {
-    self = (CDVLocalStorage*)[super initWithWebView:theWebView settings:classSettings];
-    if (self) {
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResignActive)
-                                                     name:UIApplicationWillResignActiveNotification
object:nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResignActive)
+                                                 name:UIApplicationWillResignActiveNotification
object:nil];
+    BOOL cloudBackup = [@"cloud" isEqualToString:self.commandDelegate.settings[@"BackupWebStorage"]];
 
-        self.backupInfo = [[self class] createBackupInfoWithCloudBackup:[(NSString*)[classSettings
objectForKey:@"backupType"] isEqualToString:@"cloud"]];
+    self.backupInfo = [[self class] createBackupInfoWithCloudBackup:cloudBackup];
 
-        // over-ride current webview delegate (for restore reasons)
-        self.webviewDelegate = theWebView.delegate;
-        theWebView.delegate = self;
-    }
-
-    return self;
+    // over-ride current webview delegate (for restore reasons)
+    UIWebView* theWebView = self.webView;
+    self.webviewDelegate = theWebView.delegate;
+    theWebView.delegate = self;
 }
 
 #pragma mark -

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b55609ef/CordovaLib/Classes/CDVPlugin.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.h b/CordovaLib/Classes/CDVPlugin.h
index 5264ca0..9317ad0 100644
--- a/CordovaLib/Classes/CDVPlugin.h
+++ b/CordovaLib/Classes/CDVPlugin.h
@@ -30,13 +30,11 @@
 @interface CDVPlugin : NSObject {}
 
 @property (nonatomic, weak) UIWebView* webView;
-@property (nonatomic, strong) NSDictionary* settings;
 @property (nonatomic, weak) UIViewController* viewController;
 @property (nonatomic, weak) id <CDVCommandDelegate> commandDelegate;
 
 @property (readonly, assign) BOOL hasPendingOperation;
 
-- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings;
 - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView;
 - (void)pluginInitialize;
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b55609ef/CordovaLib/Classes/CDVPlugin.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.m b/CordovaLib/Classes/CDVPlugin.m
index f8ff0a0..c2ef4aa 100644
--- a/CordovaLib/Classes/CDVPlugin.m
+++ b/CordovaLib/Classes/CDVPlugin.m
@@ -26,16 +26,12 @@
 @end
 
 @implementation CDVPlugin
-@synthesize webView, settings, viewController, commandDelegate, hasPendingOperation;
+@synthesize webView, 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;
-    }
-    return self;
+    return [self initWithWebView:theWebView];
 }
 
 - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b55609ef/CordovaLib/Classes/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.h b/CordovaLib/Classes/CDVViewController.h
index d5ce70c..e1e98be 100644
--- a/CordovaLib/Classes/CDVViewController.h
+++ b/CordovaLib/Classes/CDVViewController.h
@@ -40,7 +40,7 @@
 
 @property (nonatomic, readonly, strong) NSMutableDictionary* pluginObjects;
 @property (nonatomic, readonly, strong) NSDictionary* pluginsMap;
-@property (nonatomic, readonly, strong) NSDictionary* settings;
+@property (nonatomic, readonly, strong) NSMutableDictionary* settings;
 @property (nonatomic, readonly, strong) NSXMLParser* configParser;
 @property (nonatomic, readonly, strong) CDVWhitelist* whitelist; // readonly for public
 @property (nonatomic, readonly, assign) BOOL loadFromString;

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b55609ef/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index ffa3212..79fb43c 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -39,7 +39,7 @@
 }
 
 @property (nonatomic, readwrite, strong) NSXMLParser* configParser;
-@property (nonatomic, readwrite, strong) NSDictionary* settings;
+@property (nonatomic, readwrite, strong) NSMutableDictionary* settings;
 @property (nonatomic, readwrite, strong) CDVWhitelist* whitelist;
 @property (nonatomic, readwrite, strong) NSMutableDictionary* pluginObjects;
 @property (nonatomic, readwrite, strong) NSDictionary* pluginsMap;
@@ -210,13 +210,14 @@
 
     NSString* backupWebStorageType = @"cloud"; // default value
 
-    id backupWebStorage = [self.settings objectForKey:@"BackupWebStorage"];
+    id backupWebStorage = self.settings[@"BackupWebStorage"];
     if ([backupWebStorage isKindOfClass:[NSString class]]) {
         backupWebStorageType = backupWebStorage;
     } else if ([backupWebStorage isKindOfClass:[NSNumber class]]) {
         NSLog(@"Deprecated: BackupWebStorage boolean property is a string property now (none,
local, cloud). A boolean value of 'true' will be mapped to 'cloud'. Consult the docs: http://docs.cordova.io/en/edge/guide_project-settings_ios_index.md.html#Project%%20Settings%%20for%%20iOS");
         backupWebStorageType = [(NSNumber*) backupWebStorage boolValue] ? @"cloud" : @"none";
     }
+    self.settings[@"BackupWebStorage"] = backupWebStorageType;
 
     if (IsAtLeastiOSVersion(@"5.1")) {
         [CDVLocalStorage __fixupDatabaseLocationsWithBackupType:backupWebStorageType];
@@ -251,8 +252,7 @@
      */
     if (IsAtLeastiOSVersion(@"5.1") && (([backupWebStorageType isEqualToString:@"local"])
||
             ([backupWebStorageType isEqualToString:@"cloud"] && !IsAtLeastiOSVersion(@"6.0"))))
{
-        [self registerPlugin:[[CDVLocalStorage alloc] initWithWebView:self.webView settings:[NSDictionary
dictionaryWithObjectsAndKeys:
-                    @"backupType", backupWebStorageType, nil]] withClassName:NSStringFromClass([CDVLocalStorage
class])];
+        [self registerPlugin:[[CDVLocalStorage alloc] initWithWebView:self.webView] withClassName:NSStringFromClass([CDVLocalStorage
class])];
     }
 
     /*
@@ -839,10 +839,7 @@ BOOL gSplashScreenShown = NO;
 
     id obj = [self.pluginObjects objectForKey:className];
     if (!obj) {
-        // attempt to load the settings for this command class
-        NSDictionary* classSettings = [self.settings objectForKey:className];
-
-        obj = [[NSClassFromString (className)alloc] initWithWebView:webView settings:classSettings];
+        obj = [[NSClassFromString (className)alloc] initWithWebView:webView];
 
         if (obj != nil) {
             [self registerPlugin:obj withClassName:className];


Mime
View raw message