Initial try to set AIR config file version information differ to Flex config 
file version information.


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/8319531d
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/8319531d
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/8319531d

Branch: refs/heads/master
Commit: 8319531df9ff61165b9f2a1b0cbea58fa57a00e8
Parents: 26b14d5
Author: Justin Mclean <jmcl...@apache.org>
Authored: Mon Jul 22 09:27:18 2013 +1000
Committer: Justin Mclean <jmcl...@apache.org>
Committed: Mon Jul 22 09:27:18 2013 +1000

----------------------------------------------------------------------
 installer/src/InstallApacheFlex.mxml | 59 ++++++++++++++++++++++---------
 1 file changed, 43 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/8319531d/installer/src/InstallApacheFlex.mxml
----------------------------------------------------------------------
diff --git a/installer/src/InstallApacheFlex.mxml 
b/installer/src/InstallApacheFlex.mxml
index fef7307..70d2fb8 100644
--- a/installer/src/InstallApacheFlex.mxml
+++ b/installer/src/InstallApacheFlex.mxml
@@ -452,7 +452,8 @@ variables are not required because the locations of these 
pieces are known.
                        selected = files.(@name == 
'Versions').@flashPlayerDefault.toString();
                        for each (var flashPlayerVersion:String in 
flashPlayerVersions) {
                                if (_os != LINUX_OS || 
Number(flashPlayerVersion) <= 11.2) {
-                                       
FLASH_PLAYER_VERSIONS.addItem({label:"Flash Player " + flashPlayerVersion, 
version:flashPlayerVersion});
+                                       var swfVersion:String = files.(@name == 
'FlashPlayer' + FLASH_PLAYER_VERSION).@swfversion.toString();
+                                       
FLASH_PLAYER_VERSIONS.addItem({label:"Flash Player " + flashPlayerVersion, 
version:flashPlayerVersion, swfVersion:swfVersion});
                                }
                        }
                        
@@ -1063,6 +1064,24 @@ variables are not required because the locations of 
these pieces are known.
                        abortInstallation();
                }
                
+               protected function changeConfig(frameworksDir:File, file:File, 
flashPlayerVersion:String, swfVersion:String):void {
+                       if (isValidConfigFile(file)) {
+                               var configFile:FileStream = new FileStream();
+                               configFile.open(file, FileMode.READ);
+                               var contents:String = 
configFile.readMultiByte(configFile.bytesAvailable, "utf-8");
+                               var playerVersion:RegExp = 
/<target-player>\d\d\.\d<\/target-player>/;
+                               contents = contents.replace(playerVersion, 
"<target-player>" + flashPlayerVersion + "<\/target-player>");
+                               var playerSwfVersion:RegExp = 
/<swf-version>\d\d<\/swf-version>/;
+                               contents = contents.replace(playerSwfVersion, 
"<swf-version>" + swfVersion + "<\/swf-version>" );
+                               configFile.close();
+                               configFile.open(file,FileMode.WRITE);
+                               configFile.writeMultiByte(contents, "utf-8");   
                                
+                               var copyToFile:File = 
frameworksDir.resolvePath(file.name);
+                               configFile.close();
+                               file.copyTo(copyToFile, true);
+                       }
+               }
+               
                protected function copyConfigFiles():void {
                        var aborted:Boolean = false;
                        
@@ -1076,28 +1095,26 @@ variables are not required because the locations of 
these pieces are known.
                                var flexHomeFrameworksDir:File = 
File.userDirectory.resolvePath(_flexHome + File.separator + "frameworks");
                                
log(_viewResourceConstants.INFO_INSTALLING_CONFIG_FILES);
                                
+                               for (var i:int = 0; i < AIR_VERSIONS.length; 
i++) {
+                                       if (AIR_VERSION == 
AIR_VERSIONS[i].version) {
+                                               var airVerison:String = 
FLASH_PLAYER_VERSION[i].version;
+                                               var airSWFVersion:String = 
FLASH_PLAYER_VERSION[i].swfVersion;
+                                       }
+                               }
+                               
                                for each (var file:File in configFiles) {
-                                       if (isValidConfigFile(file)) {
-                                               var configFile:FileStream = new 
FileStream();
-                                               configFile.open(file, 
FileMode.READ);
-                                               var contents:String = 
configFile.readMultiByte(configFile.bytesAvailable, "utf-8");
-                                               var playerVersion:RegExp = 
/<target-player>\d\d\.\d<\/target-player>/;
-                                               contents = 
contents.replace(playerVersion, "<target-player>" + FLASH_PLAYER_VERSION + 
"<\/target-player>");
-                                               var swfVersion:RegExp = 
/<swf-version>\d\d<\/swf-version>/;
-                                               contents = 
contents.replace(swfVersion, "<swf-version>" + FLASH_PLAYER_SWF_VERSION + 
"<\/swf-version>" );
-                                               configFile.close();
-                                               
configFile.open(file,FileMode.WRITE);
-                                               
configFile.writeMultiByte(contents, "utf-8");                                   
-                                               var copyToFile:File = 
flexHomeFrameworksDir.resolvePath(file.name);
-                                               configFile.close();
-                                               file.copyTo(copyToFile, true);
+                                       if (isAirConfigFile(file)) {
+                                               
changeConfig(flexHomeFrameworksDir, file, airVerison, airSWFVersion);
+                                       }
+                                       else {
+                                               
changeConfig(flexHomeFrameworksDir, file, FLASH_PLAYER_VERSION, 
FLASH_PLAYER_SWF_VERSION);
                                        }
                                }
                                
                                file = File.userDirectory.resolvePath(_flexHome 
+ File.separator + "flex-sdk-description.xml");
                                var descriptionFile:FileStream = new 
FileStream();
                                descriptionFile.open(file, FileMode.READ);
-                               contents = 
descriptionFile.readMultiByte(descriptionFile.bytesAvailable, "utf-8");
+                               var contents:String = 
descriptionFile.readMultiByte(descriptionFile.bytesAvailable, "utf-8");
                                var description:RegExp = /<name>[^<]*<\/name>/;
                                contents = contents.replace(description, 
"<name>Apache Flex " + APACHE_FLEX_BIN_DISTRO_VERSION + " FP " + 
FLASH_PLAYER_VERSION + " AIR " + AIR_VERSION + " en_US</name>");
                                descriptionFile.close();
@@ -1709,6 +1726,16 @@ variables are not required because the locations of 
these pieces are known.
                        }
                }
                
+               private function isAirConfigFile(file:File):Boolean {
+                       var name:String = file.name;
+                       
+                       if (name.search("air") == 0) {
+                               return true;
+                       } else {
+                               return false;
+                       }
+               }
+               
                private function log(text:String, position:int = -1):void {
                        if (position == -1) {
                                _messages.addItem(text);

Reply via email to