diff -r bb339882c6e9 -r 0367d2db2c06 sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/engine/UseAtool.java --- a/sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/engine/UseAtool.java Tue Aug 24 12:10:03 2010 +0300 +++ b/sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/engine/UseAtool.java Tue Aug 24 12:16:27 2010 +0300 @@ -19,10 +19,11 @@ import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.text.MessageFormat; import java.util.AbstractList; import java.util.ArrayList; @@ -31,6 +32,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.swt.SWT; import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder; @@ -43,30 +45,65 @@ /** * Class to use atool.exe. Atool.exe is usually used in command prompt so that's * why we executes atool commands with using CarbideCommandLauncher class. - * + * * @author kihe - * + * */ public class UseAtool { - /** Used data file name and path */ - private String dataFileName = ""; - + /** XML file path */ + private String xmlFilePath = null; + + /** Clean .dat file path */ + private String cleanDatFilePath = null; + + private static String deviceAtoolVersion = ""; + + /** + * Sets XML file path + * + * @param xmlFilePath + * XML file path + */ + private void setXmlFilePath(String xmlFilePath) { + this.xmlFilePath = xmlFilePath; + } + /** - * Returns used data file name and path - * @return Data file name and path + * Returns XML file path. + * + * @return XML file path */ - public String getDataFileName() { - return dataFileName; + public String getXmlFilePath() { + return xmlFilePath; + } + + /** + * Sets clean .dat file path + * + * @param cleanDatFilePath + * clean .dat file path + */ + private void setCleanDatFilePath(String cleanDatFilePath) { + this.cleanDatFilePath = cleanDatFilePath; + } + + /** + * Returns clean .dat file path. + * + * @return clean .dat file path + */ + public String getCleanDatFilePath() { + return cleanDatFilePath; } /** * Check data file type. Gets first line of file and compares that to * predefined constants. - * + * * @param path - * Data file path - * @return Type of data file + * data file path + * @return type of data file */ public static int checkFileType(final String path) { // return value @@ -76,12 +113,12 @@ if (path == null || ("").equals(path)) { return retValue; } - java.io.File file = new java.io.File(path); + File file = new File(path); if (!file.exists()) { return retValue; } - if( Util.isFileXML(path) ) { + if (Util.isFileXML(path)) { return Constants.DATAFILE_XML; } @@ -89,11 +126,11 @@ BufferedReader input = null; FileInputStream fileInputStream = null; InputStreamReader inputReader = null; + try { - // get input fileInputStream = new FileInputStream(path); - if( fileInputStream.available() == 0 ) { + if (fileInputStream.available() == 0) { fileInputStream.close(); return Constants.DATAFILE_EMPTY; } @@ -102,26 +139,52 @@ inputReader = new InputStreamReader(fileInputStream, "UTF-8"); input = new BufferedReader(inputReader); - // get first line of data file - String line = input.readLine(); + boolean firstLineProcessed = false; + String line; + + while ((line = input.readLine()) != null) { + + if (!firstLineProcessed) { + firstLineProcessed = true; + + if (line.contains(Constants.DATAFILE_VERSION)) { + return Constants.DATAFILE_LOG; + } + if (line.contains(Constants.BINARY_FILE_VERSION)) { + return Constants.DATAFILE_BINARY; + } + } + + if (line.contains(Constants.PREFIX_OLD)) { + return Constants.DATAFILE_OLD_FORMAT; + } - // line contains data file version specification => data file type - // is log - if (line != null && line.contains(Constants.DATAFILE_VERSION)) { - // update return value - retValue = Constants.DATAFILE_LOG; - } else { - // go thru file - while ((line = input.readLine()) != null) { + if (line.contains(Constants.PREFIX)) { + int index = line.indexOf(Constants.PREFIX); + String usedString = line.substring(index, line.length()); + String[] lineFragments = usedString.split(" "); + + if (lineFragments.length > 8) { + if (lineFragments[2].equals(Constants.PCS)) { + + deviceAtoolVersion = lineFragments[8]; - // line contains prefix specification => data file type is - // trace - if (line.contains(Constants.PREFIX)) { - // update return value - retValue = Constants.DATAFILE_TRACE; - return retValue; + int traceFormatVersion = 0; + try { + traceFormatVersion = Integer.parseInt( + lineFragments[7], 16); + } catch (NumberFormatException nfe) { + nfe.printStackTrace(); + return Constants.DATAFILE_INVALID; + } + + if (traceFormatVersion == 3) { + return Constants.DATAFILE_TRACE; + } else { + return Constants.DATAFILE_UNSUPPORTED_TRACE_FORMAT; + } + } } - } } input.close(); @@ -161,11 +224,11 @@ /** * Creates atool_temp folder to current mmp folder location. - * + * * @param folderLocation * Current mmp folder location * @return True if given location contains atool_temp folder otherwise false - * + * */ public static boolean createAToolFolderIfNeeded(final String folderLocation) { @@ -177,7 +240,7 @@ } // create atool_temp folder - if( !returnValue ) { + if (!returnValue) { File file = new File(folderLocation + "\\" + Constants.ATOOL_TEMP); if (!file.exists()) { returnValue = file.mkdir(); @@ -196,8 +259,8 @@ } /** - * Creates xml file to project bld.inf folder. - * + * Creates XML file to project bld.inf folder. + * * @param monitor * IProgressMonitor reference * @param project @@ -209,10 +272,10 @@ * @return XML file name and path if file was successfully created otherwise * null */ - public final Constants.COMMAND_LINE_ERROR_CODE createXMLFileToCarbide(final IProgressMonitor monitor, - final IProject project, final String dataFilePath, final String command) { - // check file type - // possible file types: S60 data file, trace data file or xml file + public final Constants.COMMAND_LINE_ERROR_CODE createXmlAndCleanDatFilesToCarbide( + final IProgressMonitor monitor, final IProject project, + final String dataFilePath, final String command) { + int fileType = 0; // get file type @@ -220,19 +283,23 @@ if (fileType == Constants.DATAFILE_INVALID) { return Constants.COMMAND_LINE_ERROR_CODE.DATA_FILE_INVALID; - } else if( fileType == Constants.DATAFILE_EMPTY ) { + } else if (fileType == Constants.DATAFILE_EMPTY) { return Constants.COMMAND_LINE_ERROR_CODE.DATA_FILE_EMPTY; + } else if (fileType == Constants.DATAFILE_OLD_FORMAT) { + return Constants.COMMAND_LINE_ERROR_CODE.DATA_FILE_OLD_FORMAT; + } else if (fileType == Constants.DATAFILE_UNSUPPORTED_TRACE_FORMAT) { + return Constants.COMMAND_LINE_ERROR_CODE.DATA_FILE_UNSUPPORTED_TRACE_FORMAT; } - - //check that command line engine can be executed - if( !Util.isAtoolAvailable() ) { + + // check that command line engine can be executed + if (!Util.isAtoolAvailable()) { return Constants.COMMAND_LINE_ERROR_CODE.EXECUTE_ERROR; } ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager() .getProjectInfo(project); // if ICarbideProjectInfo not found return null - if( cpi == null ) { + if (cpi == null) { return Constants.COMMAND_LINE_ERROR_CODE.UNKNOWN_ERROR; } String absolutePath = cpi.getAbsoluteBldInfPath().toOSString(); @@ -241,34 +308,40 @@ if (index != -1) { bldInfFolder = absolutePath.substring(0, index); } - if( bldInfFolder != null ) { + if (bldInfFolder != null) { createAToolFolderIfNeeded(bldInfFolder); } AbstractList usedArguments = new ArrayList(); usedArguments.add(command); usedArguments.add(dataFilePath); - - //try to load user defined symbol files + + // try to load user defined symbol files try { - //property store names - QualifiedName useRom = new QualifiedName(Constants.USE_ROM_SYMBOL, Constants.USE_ROM ); - QualifiedName name = new QualifiedName(Constants.USE_ROM_SYMBOL_LOCATION, Constants.ROM_LOC ); - - //get value + // property store names + QualifiedName useRom = new QualifiedName(Constants.USE_ROM_SYMBOL, + Constants.USE_ROM); + QualifiedName name = new QualifiedName( + Constants.USE_ROM_SYMBOL_LOCATION, Constants.ROM_LOC); + + // get value String useRomText = project.getPersistentProperty(useRom); - if( useRomText != null ) { - boolean useRomSymbol = useRomText.equalsIgnoreCase("true") ? true : false; - //is symbol files activated for project - if(useRomSymbol) { - String symbolFileLocation = project.getPersistentProperty(name); - if( symbolFileLocation != null && !("").equals(symbolFileLocation) ) { + if (useRomText != null) { + boolean useRomSymbol = useRomText.equalsIgnoreCase("true") ? true + : false; + // is symbol files activated for project + if (useRomSymbol) { + String symbolFileLocation = project + .getPersistentProperty(name); + if (symbolFileLocation != null + && !("").equals(symbolFileLocation)) { String[] split = symbolFileLocation.split(";"); - if( split != null ) { - for( int i=0; i