imgtools/imgcheck/src/vidchecker.cpp
changeset 0 044383f39525
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * VidChecker class is to 
       
    16 * 1. extract all VIDs from all executables present in ROM/ROFS sections.
       
    17 * 2. Validate them.
       
    18 * 3. Put the validated data into Reporter class Instance.
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 /**
       
    24  @file
       
    25  @internalComponent
       
    26  @released
       
    27 */
       
    28 #include "vidchecker.h"
       
    29 
       
    30 /** 
       
    31 Constructor intializes the iVidValList member.
       
    32 
       
    33 @internalComponent
       
    34 @released
       
    35 
       
    36 @param aCmdPtr - pointer to an processed CmdLineHandler object
       
    37 @param aImageReaderList - List of ImageReader insatance pointers
       
    38 */
       
    39 VidChecker::VidChecker(CmdLineHandler* aCmdPtr, ImageReaderPtrList& aImageReaderList)
       
    40 :Checker(aCmdPtr, aImageReaderList)
       
    41 {
       
    42 	iVidValList = iCmdLine->VidValueList();
       
    43 	iVidValList.push_back(KDefaultVid);
       
    44 }
       
    45 
       
    46 /**
       
    47 Destructor
       
    48 
       
    49 @internalComponent
       
    50 @released
       
    51 */
       
    52 VidChecker::~VidChecker()
       
    53 {
       
    54 	iVidValList.clear();
       
    55 }
       
    56 
       
    57 /**
       
    58 Fucntion responsible to Prepare the ROM and ROFS image VID data
       
    59 
       
    60 @internalComponent
       
    61 @released
       
    62 
       
    63 @param ImgVsExeStatus - Global integrated container which contains image, exes and attribute value status.
       
    64 */
       
    65 void VidChecker::Check(ImgVsExeStatus& aImgVsExeStatus)
       
    66 {
       
    67 	ImageReaderPtrList::iterator begin = iImageReaderList.begin();
       
    68 	ImageReaderPtrList::iterator end = iImageReaderList.end();
       
    69 
       
    70 	ExeVsIdDataMap::iterator exeBegin;
       
    71 	ExeVsIdDataMap::iterator exeEnd;
       
    72 
       
    73 	String imageName;
       
    74 
       
    75 	while(begin != end)
       
    76 	{
       
    77 		ImageReader* imageReader = *begin;
       
    78 		imageName = imageReader->ImageName();
       
    79 		ExceptionReporter(GATHERINGIDDATA, (char*)KVid.c_str(),(char*)imageName.c_str()).Log();
       
    80 		imageReader->PrepareExeVsIdMap();
       
    81 		ExeVsIdDataMap& exeVsIdDataMa = (ExeVsIdDataMap&)imageReader->GetExeVsIdMap();
       
    82 		exeBegin = exeVsIdDataMa.begin();
       
    83 		exeEnd = exeVsIdDataMa.end();
       
    84 		if((aImgVsExeStatus[imageName].size() == 0) 
       
    85 			|| (aImgVsExeStatus[imageName][exeBegin->first].iIdData == KNull))
       
    86 		{
       
    87 			while(exeBegin != exeEnd)
       
    88 			{
       
    89 				aImgVsExeStatus[imageName][exeBegin->first].iIdData = exeBegin->second;
       
    90 				aImgVsExeStatus[imageName][exeBegin->first].iExeName = exeBegin->first;
       
    91 				++exeBegin;
       
    92 			}
       
    93 		}
       
    94 		++begin;
       
    95 	}
       
    96 }
       
    97 
       
    98 /**
       
    99 Function responsible to Validate and write the VID data into Reporter.
       
   100 
       
   101 @internalComponent
       
   102 @released
       
   103 
       
   104 @param aExeContainer - Global integrated container which contains all the attribute, values and the status.
       
   105 */
       
   106 void VidChecker::PrepareAndWriteData(ExeContainer* aExeContainer)
       
   107 {
       
   108 	ExeAttribute* exeAtt = KNull;
       
   109 	
       
   110 	IdData* idData = KNull;
       
   111 
       
   112 	idData = aExeContainer->iIdData;
       
   113 	exeAtt = new ExeAttribute;
       
   114 	if(!exeAtt)
       
   115 	{
       
   116 		throw ExceptionReporter(NOMEMORY, __FILE__, __LINE__);
       
   117 	}
       
   118 	exeAtt->iAttName = KVid;
       
   119 	exeAtt->iAttValue = Common::IntToString(idData->iVid);
       
   120 	if(!iNoCheck)
       
   121 	{
       
   122 		FillExeVidStatus(idData);
       
   123 		exeAtt->iAttStatus = idData->iVidStatus;
       
   124 	}
       
   125 	else
       
   126 	{
       
   127 		exeAtt->iAttStatus = KNull;
       
   128 	}
       
   129 	if(iAllExecutables || (exeAtt->iAttStatus == KInValid) || iNoCheck)
       
   130 	{
       
   131 		aExeContainer->iExeAttList.push_back(exeAtt);
       
   132 	}
       
   133 }
       
   134 
       
   135 /**
       
   136 Function responsible to Validate the executble VID.
       
   137 1. Compare the executable VID with all the iVidValList entries, if any one of the
       
   138 comparison is success then the VID status is Valid.
       
   139 2. Otherwise Invalid.
       
   140 
       
   141 @internalComponent
       
   142 @released
       
   143 
       
   144 @param aIdData - Executable's IdData data instance.
       
   145 */
       
   146 void VidChecker::FillExeVidStatus(IdData* aIdData)
       
   147 {
       
   148 	aIdData->iVidStatus.assign(KInValid);
       
   149 	UnIntList::iterator vidValBegin = iVidValList.begin();
       
   150 	UnIntList::iterator vidValEnd = iVidValList.end();
       
   151 
       
   152 	while(vidValBegin != vidValEnd)
       
   153 	{
       
   154 		if((*vidValBegin) == aIdData->iVid)
       
   155 		{
       
   156 			aIdData->iVidStatus = KValid;
       
   157 			break;
       
   158 		}
       
   159 		++vidValBegin;
       
   160 	}
       
   161 }