fix 11553. For project template filtering, use feature fags. No longer us OS/SDK version or name attribute. C3_BUILDER_WORK
authortimkelly
Thu, 22 Jul 2010 14:02:11 -0500
branchC3_BUILDER_WORK
changeset 1666 5243d04d3917
parent 1664 65c3d72a8793
child 1667 352fb86872dd
fix 11553. For project template filtering, use feature fags. No longer us OS/SDK version or name attribute.
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java
core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/api/sdk/ui/TemplateUtils.java
templates/com.nokia.carbide.cpp.qt.templates/plugin.xml
templates/com.nokia.carbide.cpp.templates/plugin.xml
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java	Wed Jul 21 17:12:21 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/model/SymbianSDK.java	Thu Jul 22 14:02:11 2010 -0500
@@ -77,6 +77,8 @@
 	private static final String BUILD_INFO_KEYWORD = "ManufacturerSoftwareBuild";
 	
 	private static final String WINSCW_UREL_DIR = "epoc32/release/winscw/urel";
+	private static final String WINSCW_UDEB_DIR = "epoc32/release/winscw/udeb";
+	private static final String ARMV5_UDEB_DIR = "epoc32/release/armv5/udeb";
 	
 	protected DeviceType deviceEntry = null;
 	private boolean enabled = true;
@@ -86,7 +88,7 @@
 	private Map<String, ISDKBuildInfo> buildInfoMap = new HashMap<String, ISDKBuildInfo>();
 	private Map<String, File> prefixFileMap = new HashMap<String, File>();
 	@SuppressWarnings("rawtypes")
-	private Set sdkFeatures = new HashSet();
+	private Set<Object> sdkFeatures = new HashSet<Object>();
 
 	// greedy match means the filename is in the last group
 	public static Pattern VARIANT_HRH_LINE_PATTERN = Pattern.compile("(?i)(.*)(/|\\\\)(.*hrh)");
@@ -639,23 +641,6 @@
 		
 	}
 
-	/**
-	 * Check to see whether or not we should support WINSCW UREL
-	 */
-	@SuppressWarnings("unchecked")
-	private void scanForWINSCW_UREL(){
-		String winscwURELFullPathStr = getEPOCROOT();
-		winscwURELFullPathStr += WINSCW_UREL_DIR;
-		IPath winscwURELPath = new Path(winscwURELFullPathStr);
-		if (winscwURELPath != null && winscwURELPath.toFile().exists()){
-			if (winscwURELPath.append("epoc.exe").toFile().exists()){
-				if (winscwURELPath.append("euser.dll").toFile().exists()){
-					sdkFeatures.add(ISymbianSDKFeatures.IS_WINSCW_UREL_SUPPORTED);
-				}
-			}
-		}
-	}
-	
 	private boolean setDataFromManifestXML(){
 		if (hasManifestXML()){
 			
@@ -673,7 +658,50 @@
 	@SuppressWarnings("unchecked")
 	private void setSupportFeatures() {
 		scanForWINSCW_UREL();
+		scanForAvkon();
 		sdkFeatures.add(ISymbianSDKFeatures.IS_EKA2);
 	}
 
+	/**
+	 * Check if avkon is a supported feature.
+	 */
+	private void scanForAvkon() {
+		String armv5UDEBFullPathStr = getEPOCROOT();
+		armv5UDEBFullPathStr += ARMV5_UDEB_DIR;
+		IPath armv5UDEBPath = new Path(armv5UDEBFullPathStr);
+		if (armv5UDEBPath != null && armv5UDEBPath.toFile().exists()){
+			if (armv5UDEBPath.append("avkon.dll").toFile().exists()){
+				sdkFeatures.add(ISymbianSDKFeatures.IS_AVKON_SUPPORTED);
+				return;
+			}
+			// not there, check winscw
+			String winscwURELFullPathStr = getEPOCROOT();
+			winscwURELFullPathStr += WINSCW_UREL_DIR;
+			IPath winscwURELPath = new Path(winscwURELFullPathStr);
+			if (winscwURELPath != null && winscwURELPath.toFile().exists()){
+				if (winscwURELPath.append("avkon.dll").toFile().exists()){
+					sdkFeatures.add(ISymbianSDKFeatures.IS_AVKON_SUPPORTED);
+					return;
+				}
+			}
+		}
+	}
+	
+	/**
+	 * Check to see whether or not we should support WINSCW UREL
+	 */
+	@SuppressWarnings("unchecked")
+	private void scanForWINSCW_UREL(){
+		String winscwURELFullPathStr = getEPOCROOT();
+		winscwURELFullPathStr += WINSCW_UREL_DIR;
+		IPath winscwURELPath = new Path(winscwURELFullPathStr);
+		if (winscwURELPath != null && winscwURELPath.toFile().exists()){
+			if (winscwURELPath.append("epoc.exe").toFile().exists()){
+				if (winscwURELPath.append("euser.dll").toFile().exists()){
+					sdkFeatures.add(ISymbianSDKFeatures.IS_WINSCW_UREL_SUPPORTED);
+				}
+			}
+		}
+	}
+
 }
--- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/api/sdk/ui/TemplateUtils.java	Wed Jul 21 17:12:21 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/api/sdk/ui/TemplateUtils.java	Thu Jul 22 14:02:11 2010 -0500
@@ -20,19 +20,21 @@
 
 import java.util.ArrayList;
 import java.util.List;
-
-import org.osgi.framework.Version;
+import java.util.Set;
 
-import com.nokia.carbide.cpp.internal.api.sdk.ISBSv1BuildInfo;
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
+import com.nokia.carbide.cpp.sdk.core.ISymbianSDKFeatures;
 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
 import com.nokia.carbide.template.engine.ITemplate;
 
 public class TemplateUtils {
+		
+	private static final String SDK_FEATURE_DELIM = ";"; //$NON-NLS-1$
 	
-	private static final String FAMILY_DELIM = ":"; //$NON-NLS-1$
-	private static final String RANGE_DELIM = "-"; //$NON-NLS-1$
-	private static final String VERSION_DELIM = ";"; //$NON-NLS-1$
+	// Template flags. These are the template flags used for filtering
+	// As of Carbide 3.0, we no longer use OS/SDK version or family name
+	// to filter templates.
+	private static final String FEATURE_SUPPORTS_AVKON = "supportsAvkon"; //$NON-NLS-1$
 
 	public static final String PROJECT_NAME = "projectName"; //$NON-NLS-1$
 	public static final String BASE_NAME = "baseName"; //$NON-NLS-1$
@@ -45,70 +47,33 @@
 	 * @param symbianSDK
 	 * @param template
 	 * @return whether this sdk matches the template
-	 * template filter arguments:= framework[:versionSpec]
-	 * versionSpec is a list of version or versionRange delimited by ;
-	 * versionRange is a minVersion and maxVersion delimited by - 
+	 * template filter arguments
 	 */
 	public static boolean sdkMatchesTemplate(ISymbianSDK symbianSDK, ITemplate template) {
-		Version sdkVersion = symbianSDK.getSDKVersion();
-		String family = symbianSDK.getFamily(); // S60, symbian... 3rd segment of devices.xml 'name' attrib
-		return sdkMatchesTemplate(sdkVersion, family, template);
-	}
-	
-	
-	private static boolean isSameFamily(String f1, String f2) {
-		if (f1.equalsIgnoreCase(f2))
-			return true;
+		String filterArgs = template.getFilterArguments();
+		Set supportedFeatures = symbianSDK.getSupportedFeatures();
+		if (filterArgs != null && filterArgs.length() > 0) {
+			String[] strings = filterArgs.split(SDK_FEATURE_DELIM);
+			if (strings.length > 0) {
+				// check for avkon support
+				boolean hasAvkon = false;
+				if (supportedFeatures.contains(ISymbianSDKFeatures.IS_AVKON_SUPPORTED)){
+					
+					for (String templateFeature : strings){
+						if (templateFeature.equals(FEATURE_SUPPORTS_AVKON)){
+							hasAvkon = true; // This template requires avkon support and it's there
+							break;
+						}
+					}
+				}
+				if (!hasAvkon)
+					return false;  // This template requires avkon support but is not there. Don't show
+			}
+		}
 		
-		if ((f1.equalsIgnoreCase(ISBSv1BuildInfo.S60_FAMILY_ID) &&
-				f2.equalsIgnoreCase(ISBSv1BuildInfo.SERIES60_FAMILY_ID)) ||
-				(f2.equalsIgnoreCase(ISBSv1BuildInfo.S60_FAMILY_ID) &&
-						f1.equalsIgnoreCase(ISBSv1BuildInfo.SERIES60_FAMILY_ID)))
-			return true;
-		
-		return false;
+		return true;
 	}
 	
-	/**
-	 * @param symbianSDK
-	 * @param template
-	 * @return whether this sdk matches the template
-	 * template filter arguments:= family[:versionSpec]
-	 * versionSpec is a list of version or versionRange delimited by ;
-	 * versionRange is a minVersion and maxVersion delimited by - 
-	 */
-	public static boolean sdkMatchesTemplate(Version sdkVersion, String family, ITemplate template) {
-		String filterArgs = template.getFilterArguments();
-		if (filterArgs != null) {
-			String[] strings = filterArgs.split(FAMILY_DELIM);
-			if (strings.length > 0) {
-				if (!isSameFamily(family, strings[0]))
-					return false;
-				
-				if (strings.length > 1) {
-					String[] versions = strings[1].split(VERSION_DELIM);
-					for (int i = 0; i < versions.length; i++) {
-						String[] versionRange = versions[i].split(RANGE_DELIM);
-						if (versionRange.length == 1) {
-							Version version = Version.parseVersion(versionRange[0]);
-							if (sdkVersion.equals(version))
-								return true;
-						}
-						else if (versionRange.length > 1) {
-							Version minVersion = Version.parseVersion(versionRange[0]);
-							Version maxVersion = Version.parseVersion(versionRange[1]);
-							if (sdkVersion.compareTo(minVersion) >= 0 &&
-									sdkVersion.compareTo(maxVersion) <= 0)
-								return true;
-						}
-					}
-					return false;
-				}
-			}
-		}
-		return true;
-	}
-
 	public static List<ISymbianSDK> getEnabledSDKs() {
 		List<ISymbianSDK> enabledSDKList = new ArrayList<ISymbianSDK>();
 		
--- a/templates/com.nokia.carbide.cpp.qt.templates/plugin.xml	Wed Jul 21 17:12:21 2010 -0500
+++ b/templates/com.nokia.carbide.cpp.qt.templates/plugin.xml	Thu Jul 22 14:02:11 2010 -0500
@@ -14,7 +14,7 @@
 
       <template
       		displayName="%Qt.gui.dialog.template.label"
-            filterArguments="S60:3.0-5.9"
+            filterArguments=""
             groupLabel="%Qt.gui.label"
             image="icons/guiproject.gif"
             location="templates/Qt-GUI-Dialog/template.xml"
@@ -23,7 +23,7 @@
 
       <template
       		displayName="%Qt.gui.mainwindow.template.label"
-            filterArguments="S60:3.0-5.9"
+            filterArguments=""
             groupLabel="%Qt.gui.label"
             image="icons/guiproject.gif"
             location="templates/Qt-GUI-MainWindow/template.xml"
@@ -32,7 +32,7 @@
 
       <template
       		displayName="%Qt.gui.widget.template.label"
-            filterArguments="S60:3.0-5.9"
+            filterArguments=""
             groupLabel="%Qt.gui.label"
             image="icons/guiproject.gif"
             location="templates/Qt-GUI-Widget/template.xml"
--- a/templates/com.nokia.carbide.cpp.templates/plugin.xml	Wed Jul 21 17:12:21 2010 -0500
+++ b/templates/com.nokia.carbide.cpp.templates/plugin.xml	Thu Jul 22 14:02:11 2010 -0500
@@ -7,7 +7,7 @@
 
       <template
       		displayName="%gui.label"
-            filterArguments="S60:3.0-5.9"
+            filterArguments="supportsAvkon"
             groupLabel="%S60.3.label"
             image="icons/icon_S60.png"
             location="templates/projecttemplates/S60-TouchUIApplication/template.xml"
@@ -45,7 +45,7 @@
 
       <template
       		displayName="%openc.label"
-            filterArguments="S60:3.0-5.9"
+            filterArguments=""
             groupLabel="%S60.3.label"
             image="icons/icon_S60.png"
             location="templates/projecttemplates/OpenC-HelloWorld/template.xml"