cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject mac commit: [CB-3171] Add deprecation notice for use of <plugin> in config.xml in OSX
Date Wed, 29 May 2013 19:02:45 GMT
Updated Branches:
  refs/heads/master 2b5882335 -> c06d41f61


[CB-3171] Add deprecation notice for use of <plugin> in config.xml in OSX


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

Branch: refs/heads/master
Commit: c06d41f61f26b58ddd1e8744b4352340f35b4725
Parents: 2b58823
Author: Shazron Abdullah <shazron@apache.org>
Authored: Wed May 29 12:02:36 2013 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Wed May 29 12:02:36 2013 -0700

----------------------------------------------------------------------
 .../Classes/Commands/CDVConfigParser.h             |    5 ++-
 .../Classes/Commands/CDVConfigParser.m             |   30 +++++++++++++-
 bin/templates/project/__TESTING__/config.xml       |   31 ++++++++++++---
 3 files changed, 57 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/c06d41f6/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.h
----------------------------------------------------------------------
diff --git a/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.h b/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.h
index 7392580..2e06c88 100644
--- a/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.h
+++ b/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.h
@@ -17,7 +17,10 @@
  under the License.
  */
 
-@interface CDVConfigParser : NSObject <NSXMLParserDelegate>{}
+@interface CDVConfigParser : NSObject <NSXMLParserDelegate>
+{
+    NSString* featureName;
+}
 
 @property (nonatomic, readonly, strong) NSMutableDictionary* pluginsDict;
 @property (nonatomic, readonly, strong) NSMutableDictionary* settings;

http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/c06d41f6/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.m
----------------------------------------------------------------------
diff --git a/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.m b/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.m
index 0f160ff..d00087f 100644
--- a/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.m
+++ b/CordovaFramework/CordovaFramework/Classes/Commands/CDVConfigParser.m
@@ -62,6 +62,7 @@
         self.settings = [[NSMutableDictionary alloc] initWithCapacity:30];
         self.whitelistHosts = [[NSMutableArray alloc] initWithCapacity:30];
         self.startupPluginNames = [[NSMutableArray alloc] initWithCapacity:8];
+        featureName = nil;
     }
     return self;
 }
@@ -73,9 +74,27 @@
     } else if ([elementName isEqualToString:@"plugin"]) {
         NSString* name = [attributeDict[@"name"] lowercaseString];
         pluginsDict[name] = attributeDict[@"value"];
-        if ([@"true" isEqualToString:attributeDict[@"onload"]]) {
+        if ([@"true" isEqualToString : attributeDict[@"onload"]]) {
             [self.startupPluginNames addObject:name];
         }
+        NSLog(@"\nUse of the <plugin> tag has been deprecated. Use a <feature>
tag instead. Change:\n"
+            @"    <plugin name=\"%@\" value=\"%@\" />\n"
+            @"To:\n"
+            @"    <feature name=\"%@\">\n"
+            @"        <param name=\"ios-package\" value=\"%@\">\n"
+            @"    </feature>\n"
+            , attributeDict[@"name"], attributeDict[@"value"], attributeDict[@"name"], attributeDict[@"value"]);
+    } else if ([elementName isEqualToString:@"feature"]) { // store feature name to use with
correct parameter set
+        featureName = [attributeDict[@"name"] lowercaseString];
+    } else if ((featureName != nil) && [elementName isEqualToString:@"param"]) {
+        NSString* paramName = [attributeDict[@"name"] lowercaseString];
+        id value = attributeDict[@"value"];
+        if ([paramName isEqualToString:@"ios-package"]) {
+            pluginsDict[featureName] = value;
+        }
+        if ([paramName isEqualToString:@"onload"] && [@"true" isEqualToString : value])
{
+            [self.startupPluginNames addObject:featureName];
+        }
     } else if ([elementName isEqualToString:@"access"]) {
         [whitelistHosts addObject:attributeDict[@"origin"]];
     } else if ([elementName isEqualToString:@"content"]) {
@@ -83,9 +102,16 @@
     }
 }
 
+- (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
+{
+    if ([elementName isEqualToString:@"feature"]) { // no longer handling a feature so release
+        featureName = nil;
+    }
+}
+
 - (void)parser:(NSXMLParser*)parser parseErrorOccurred:(NSError*)parseError
 {
-    NSAssert(NO, @"config.xml parse error line %ld col %ld", (long)[parser lineNumber], (long)[parser
columnNumber]);
+    NSAssert(NO, @"config.xml parse error line %d col %d", [parser lineNumber], [parser columnNumber]);
 }
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-osx/blob/c06d41f6/bin/templates/project/__TESTING__/config.xml
----------------------------------------------------------------------
diff --git a/bin/templates/project/__TESTING__/config.xml b/bin/templates/project/__TESTING__/config.xml
index bc5a9f8..57a0d63 100644
--- a/bin/templates/project/__TESTING__/config.xml
+++ b/bin/templates/project/__TESTING__/config.xml
@@ -19,15 +19,34 @@
 # under the License.
 #
 -->
-<widget>
-    <preference name="EnableWebGL" value="false" />
+<widget xmlns     = "http://www.w3.org/ns/widgets"
+        id        = "io.cordova.helloCordova"
+        version   = "2.0.0">
+    <name>Hello Cordova</name>
+
+    <description>
+        A sample Apache Cordova application that responds to the deviceready event.
+    </description>
+
+    <author href="http://cordova.io" email="dev@cordova.apache.org">
+        Apache Cordova Team
+    </author>
+
+    <access origin="*"/>
 
+    <!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
     <content src="index.html" />
 
+    <!-- Preferences for OSX -->
+    <preference name="EnableWebGL" value="false" />
+
+    <feature name="Device">
+      <param name="ios-package" value="CDVDevice"/>
+    </feature>
+    <feature name="NetworkStatus">
+      <param name="ios-package" value="CDVConnection"/>
+    </feature>
+    <!-- Deprecated plugins element. REmove in 3.0 -->
     <plugins>
-        <plugin name="Device" value="CDVDevice"/>
-        <plugin name="NetworkStatus" value="CDVConnection" />
     </plugins>
-
-    <access origin="*" />
 </widget>


Mime
View raw message