secureswitools/swisistools/source/interpretsislib/rommanager.cpp
branchRCL_3
changeset 81 42552535c1ac
parent 62 5cc91383ab1e
equal deleted inserted replaced
73:79647526f98c 81:42552535c1ac
     1 /*
     1 /*
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    27 #include "parameterlist.h"
    27 #include "parameterlist.h"
    28 #include "stringutils.h"
    28 #include "stringutils.h"
    29 #include "is_utils.h"
    29 #include "is_utils.h"
    30 
    30 
    31 // String constants
    31 // String constants
    32 #ifndef __TOOLS2_LINUX__
       
    33 const std::wstring KRomManagerSysBinPath 			= L"z:\\sys\\bin\\";
    32 const std::wstring KRomManagerSysBinPath 			= L"z:\\sys\\bin\\";
    34 const std::string KRomManagerRomDrive               = "Z:\\";
    33 const std::string KRomManagerRomDrive               = "Z:\\";
    35 #else
       
    36 const std::wstring KRomManagerSysBinPath 			= L"z:/sys/bin/";
       
    37 const std::string KRomManagerRomDrive               = "Z:/";
       
    38 #endif
       
    39 const std::string KRomManagerRomLogProcessingFile   = "Processing file ";
    34 const std::string KRomManagerRomLogProcessingFile   = "Processing file ";
    40 const std::string KRomManagerRomLogReadingResource  = "Reading resource ";
    35 const std::string KRomManagerRomLogReadingResource  = "Reading resource ";
    41 const std::string KRomManagerRomLogReadingResource2 = " to rom linear address";
    36 const std::string KRomManagerRomLogReadingResource2 = " to rom linear address";
    42 const std::string KRomManagerRomLogUids             = "Uids:                    ";
    37 const std::string KRomManagerRomLogUids             = "Uids:                    ";
    43 const std::string KRomManagerRomLogSecureId         = "Secure ID:               ";
    38 const std::string KRomManagerRomLogSecureId         = "Secure ID:               ";
   149 RomManagerLogFiles::RomManagerLogFiles( const std::list<std::wstring>& aLogFileNames )
   144 RomManagerLogFiles::RomManagerLogFiles( const std::list<std::wstring>& aLogFileNames )
   150 :   iLogFileNames( aLogFileNames )
   145 :   iLogFileNames( aLogFileNames )
   151     {
   146     {
   152     for( std::list<std::wstring>::const_iterator it = aLogFileNames.begin() ; it != aLogFileNames.end(); it++ )
   147     for( std::list<std::wstring>::const_iterator it = aLogFileNames.begin() ; it != aLogFileNames.end(); it++ )
   153         {
   148         {
   154     	std::string narrowLogFileName = wstring2string( *it );
   149     	std::string narrowLogFileName = Ucs2ToUtf8( *it );
   155     	std::string narrowUpperCaseLogFileName = StringUtils::ToUpper( narrowLogFileName );
   150     	std::string narrowUpperCaseLogFileName = StringUtils::ToUpper( narrowLogFileName );
   156 
   151 
   157         // Get the base name
   152         // Get the base name
   158         int dotPos = narrowUpperCaseLogFileName.find( ".LOG" );
   153         int dotPos = narrowUpperCaseLogFileName.find( ".LOG" );
   159         if ( dotPos == std::string::npos )
   154         if ( dotPos == std::string::npos )
   191     {
   186     {
   192     bool exists = false;
   187     bool exists = false;
   193 
   188 
   194     // Get filename & convert it to uppercase, since our map key is
   189     // Get filename & convert it to uppercase, since our map key is
   195     // also in upper case form.
   190     // also in upper case form.
   196     std::string narrowFileName = wstring2string( aFileName );
   191     std::string narrowFileName = Ucs2ToUtf8( aFileName );
   197     narrowFileName = StringUtils::ToUpper( narrowFileName );
   192     narrowFileName = StringUtils::ToUpper( narrowFileName );
   198 
   193 
   199     // Do we have a corresponding entry?
   194     // Do we have a corresponding entry?
   200     RomEntry* entry = iEntriesIndexedByRomFileName[ narrowFileName ];
   195     RomEntry* entry = iEntriesIndexedByRomFileName[ narrowFileName ];
   201     if ( entry != NULL )
   196     if ( entry != NULL )
   213 
   208 
   214 	std::wstring searchNameWild = StringUtils::ToUpper(aSearchNameWild);
   209 	std::wstring searchNameWild = StringUtils::ToUpper(aSearchNameWild);
   215 
   210 
   216 	for ( ; curr != end ; ++curr)
   211 	for ( ; curr != end ; ++curr)
   217 		{
   212 		{
   218 		std::wstring romFile = string2wstring(curr->first);
   213 		std::wstring romFile = Utf8ToUcs2(curr->first);
   219 		if (StringUtils::WildcardCompare(searchNameWild,romFile))
   214 		if (StringUtils::WildcardCompare(searchNameWild,romFile))
   220 			{
   215 			{
   221 			aAdornedFileNamesFound.push_back(romFile);
   216 			aAdornedFileNamesFound.push_back(romFile);
   222 			}
   217 			}
   223 		}
   218 		}
   236 			if (romEntry->Type() == RomEntry::ETypeBinary)
   231 			if (romEntry->Type() == RomEntry::ETypeBinary)
   237 				{
   232 				{
   238 				TUint32 romSid = romEntry->SecurityInfo().iSecureId;
   233 				TUint32 romSid = romEntry->SecurityInfo().iSecureId;
   239 				if (romSid != 0 && romSid == aSid)
   234 				if (romSid != 0 && romSid == aSid)
   240 					{
   235 					{
   241 					aFile = string2wstring(romEntry->RomFileName());
   236 					aFile = Utf8ToUcs2(romEntry->RomFileName());
   242 					return true;
   237 					return true;
   243 					}
   238 					}
   244 				}
   239 				}
   245 			}
   240 			}
   246 		}
   241 		}
   251     {
   246     {
   252     TInt err = -1;
   247     TInt err = -1;
   253 
   248 
   254     // Get filename & convert it to uppercase, since our map key is
   249     // Get filename & convert it to uppercase, since our map key is
   255     // also in upper case form.
   250     // also in upper case form.
   256     std::string narrowFileName = wstring2string( aFileName );
   251     std::string narrowFileName = Ucs2ToUtf8( aFileName );
   257     narrowFileName = StringUtils::ToUpper( narrowFileName );
   252     narrowFileName = StringUtils::ToUpper( narrowFileName );
   258 
   253 
   259     // Do we have a corresponding entry?
   254     // Do we have a corresponding entry?
   260     RomEntry* entry = iEntriesIndexedByRomFileName[ narrowFileName ];
   255     RomEntry* entry = iEntriesIndexedByRomFileName[ narrowFileName ];
   261     if ( entry != NULL )
   256     if ( entry != NULL )
   272     }
   267     }
   273 
   268 
   274 
   269 
   275 void RomManagerLogFiles::ReadObyFile( const std::string& aFileName )
   270 void RomManagerLogFiles::ReadObyFile( const std::string& aFileName )
   276     {
   271     {
   277 	std::wstring fileName = string2wstring( aFileName );
   272 	std::wstring fileName = Utf8ToUcs2( aFileName );
   278     if ( FileExists( fileName ) )
   273     if ( FileExists( fileName ) )
   279         {
   274         {
   280     	std::ifstream stream;
   275     	std::ifstream stream;
   281 	    stream.open( aFileName.c_str(), std::ios::binary );
   276 	    stream.open( aFileName.c_str(), std::ios::binary );
   282         //
   277         //
   573 		stream << "Unknown error";
   568 		stream << "Unknown error";
   574 		break;
   569 		break;
   575 	}
   570 	}
   576     //
   571     //
   577     stream << std::endl;
   572     stream << std::endl;
   578     std::wstring finalMessage = string2wstring( stream.str() );
   573     std::wstring finalMessage = Utf8ToUcs2( stream.str() );
   579     //
   574     //
   580 	LERROR( finalMessage );
   575 	LERROR( finalMessage );
   581     }
   576     }