appfw/apparchitecture/aplist/aplappinforeader.cpp
branchRCL_3
changeset 20 c2c61fdca848
parent 19 924385140d98
equal deleted inserted replaced
19:924385140d98 20:c2c61fdca848
     1  // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    26 #include <barsread2.h>
    26 #include <barsread2.h>
    27 #include <e32uid.h>
    27 #include <e32uid.h>
    28 #include "../apgrfx/APGSTD.H"			// EPanicNullPointer
    28 #include "../apgrfx/APGSTD.H"			// EPanicNullPointer
    29 #include "../apgrfx/apsecutils.h"		// CApaSecurityUtils
    29 #include "../apgrfx/apsecutils.h"		// CApaSecurityUtils
    30 
    30 
    31 
       
    32 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    33 const TUint KResourceOffsetMask = 0xFFFFF000;
    31 const TUint KResourceOffsetMask = 0xFFFFF000;
    34 
    32 
    35 _LIT(KAppBinaryPathAndExtension, "\\sys\\bin\\.exe");
    33 _LIT(KAppBinaryPathAndExtension, "\\sys\\bin\\.exe");
    36 const TInt KAppRegistrationInfoResourceId = 1;
    34 const TInt KAppRegistrationInfoResourceId = 1;
    37 
    35 
    38 // The 2nd UID that defines a resource file as being an application registration resource file.
    36 // The 2nd UID that defines a resource file as being an application registration resource file.
    39 const TUid KUidAppRegistrationFile = {0x101F8021};
    37 const TUid KUidAppRegistrationFile = {0x101F8021};
    40 #endif
       
    41 
       
    42 
       
    43 
    38 
    44 //
    39 //
    45 // Local functions
    40 // Local functions
    46 //
    41 //
    47 
    42 
    48 extern void CleanupServiceArray(TAny* aServiceArray);	// Implemented in AplAppList.cpp
    43 extern void CleanupServiceArray(TAny* aServiceArray);	// Implemented in AplAppList.cpp
    49 
    44 
    50 
       
    51 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    52 // ApaUtils
    45 // ApaUtils
    53 
    46 
    54 TBool ApaUtils::TypeUidIsForRegistrationFile(const TUidType& aUidType)
    47 TBool ApaUtils::TypeUidIsForRegistrationFile(const TUidType& aUidType)
    55     { // static
    48 	{ // static
    56     return (aUidType[1].iUid==KUidAppRegistrationFile.iUid ||
    49 	return (aUidType[1].iUid==KUidAppRegistrationFile.iUid ||
    57            aUidType[0].iUid==KUidPrefixedNonNativeRegistrationResourceFile);
    50 		   aUidType[0].iUid==KUidPrefixedNonNativeRegistrationResourceFile);
    58     }
    51 	}
    59 #endif
    52 
    60 
    53 
    61 //
    54 //
    62 // CApaAppInfoReader
    55 // CApaAppInfoReader
    63 //
    56 //
    64 
    57 
    68 // Doing things this way provides a small performance optimisation by enabling the caller
    61 // Doing things this way provides a small performance optimisation by enabling the caller
    69 // to delete it's stored pointer, and replace it with one returned by this function,
    62 // to delete it's stored pointer, and replace it with one returned by this function,
    70 // instead of having to copy the object (copying could be expensive for the methods
    63 // instead of having to copy the object (copying could be expensive for the methods
    71 // of this class that need to return arrays).
    64 // of this class that need to return arrays).
    72 
    65 
       
    66 
       
    67 CApaAppInfoReader* CApaAppInfoReader::NewL(RFs& aFs, const TDesC& aRegistrationFileName, TUid aAppUid)
       
    68 	{
       
    69 	CApaAppInfoReader* self = new(ELeave) CApaAppInfoReader(aFs, aRegistrationFileName, aAppUid);
       
    70 	CleanupStack::PushL(self);
       
    71 	self->ConstructL();
       
    72 	CleanupStack::Pop(self);
       
    73 	return self;
       
    74 	}
       
    75 
       
    76 CApaAppInfoReader::CApaAppInfoReader(RFs& aFs, const TDesC& aRegistrationFileName, TUid aAppUid) :
       
    77 	iFs(aFs),
       
    78 	iAppUid(aAppUid),
       
    79 	iTimeStamp(0),
       
    80 	iDefaultScreenNumber(0),
       
    81 	iNonMbmIconFile(EFalse),
       
    82 	iLocalisableResourceFileTimeStamp(0),
       
    83 	iApplicationLanguage(ELangNone),
       
    84 	iIndexOfFirstOpenService(KErrNotFound),
       
    85 	iRegistrationFileName(aRegistrationFileName)
       
    86 	{
       
    87 	}
       
    88 
    73 void CApaAppInfoReader::ConstructL()
    89 void CApaAppInfoReader::ConstructL()
    74 	{
    90 	{
    75 	iIconLoader = CApaIconLoader::NewL(iFs);
    91 	iIconLoader = CApaIconLoader::NewL(iFs);
    76 	}
    92 	}
    77 
    93 
    85 		iViewDataArray->ResetAndDestroy();
   101 		iViewDataArray->ResetAndDestroy();
    86 	
   102 	
    87 	delete iViewDataArray;
   103 	delete iViewDataArray;
    88 	delete iOwnedFileArray;
   104 	delete iOwnedFileArray;
    89 	delete iIconFileName;
   105 	delete iIconFileName;
    90 #ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK	
       
    91 	delete iLocalisableResourceFileName;
   106 	delete iLocalisableResourceFileName;
    92 #endif
       
    93 	
   107 	
    94 	if (iServiceArray)
   108 	if (iServiceArray)
    95  		{
   109  		{
    96  		CleanupServiceArray(iServiceArray);
   110  		CleanupServiceArray(iServiceArray);
    97  		iServiceArray = NULL;
   111  		iServiceArray = NULL;
   111 TUidType CApaAppInfoReader::AppBinaryUidType() const
   125 TUidType CApaAppInfoReader::AppBinaryUidType() const
   112 	{
   126 	{
   113 	return iAppBinaryUidType;
   127 	return iAppBinaryUidType;
   114 	}
   128 	}
   115 
   129 
       
   130 TTime CApaAppInfoReader::TimeStamp() const
       
   131 	{
       
   132 	return iTimeStamp;
       
   133 	}
       
   134 
       
   135 TTime CApaAppInfoReader::IconFileTimeStamp() const
       
   136      {
       
   137      return iIconFileTimeStamp;
       
   138      }
       
   139 
   116 void CApaAppInfoReader::Capability(TDes8& aCapabilityBuf) const
   140 void CApaAppInfoReader::Capability(TDes8& aCapabilityBuf) const
   117 	{
   141 	{
   118 	TApaAppCapabilityBuf buf(iCapability);
   142 	TApaAppCapabilityBuf buf(iCapability);
   119 	TApaAppCapability::CopyCapability(aCapabilityBuf, buf);
   143 	TApaAppCapability::CopyCapability(aCapabilityBuf, buf);
   120 	}
   144 	}
   174 TBool CApaAppInfoReader::NonMbmIconFile() const
   198 TBool CApaAppInfoReader::NonMbmIconFile() const
   175 	{
   199 	{
   176 	return iNonMbmIconFile;
   200 	return iNonMbmIconFile;
   177 	}
   201 	}
   178 
   202 
   179 
   203 HBufC* CApaAppInfoReader::LocalisableResourceFileName()
       
   204 	{
       
   205 	HBufC* localisableResourceFileName = iLocalisableResourceFileName;
       
   206 	iLocalisableResourceFileName = NULL; // ownership transferred to caller
       
   207 	return localisableResourceFileName;
       
   208 	}
       
   209 
       
   210 TTime CApaAppInfoReader::LocalisableResourceFileTimeStamp() const
       
   211 	{
       
   212 	return iLocalisableResourceFileTimeStamp;
       
   213 	}
       
   214 	
   180 TLanguage CApaAppInfoReader::AppLanguage() const
   215 TLanguage CApaAppInfoReader::AppLanguage() const
   181 	{
   216 	{
   182 	return iApplicationLanguage;
   217 	return iApplicationLanguage;
   183 	}
   218 	}
   184 
   219 
   201 	{
   236 	{
   202 	CApaIconLoader* iconLoader = iIconLoader;
   237 	CApaIconLoader* iconLoader = iIconLoader;
   203 	iIconLoader = NULL; // ownership transferred to caller
   238 	iIconLoader = NULL; // ownership transferred to caller
   204 	return iconLoader;
   239 	return iconLoader;
   205 	}
   240 	}
   206 
       
   207 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   208 
       
   209 CApaAppInfoReader::CApaAppInfoReader(RFs& aFs, const Usif::CApplicationRegistrationData& aAppInfo, const Usif::RSoftwareComponentRegistry& aScr) :
       
   210     iFs(aFs),
       
   211     iDefaultScreenNumber(0),
       
   212     iNonMbmIconFile(EFalse),
       
   213     iApplicationLanguage(ELangNone),
       
   214     iIndexOfFirstOpenService(KErrNotFound),
       
   215     iAppInfo(aAppInfo),
       
   216     iScr(aScr)
       
   217     {
       
   218     }
       
   219 
       
   220 CApaAppInfoReader* CApaAppInfoReader::NewL(RFs& aFs, const Usif::CApplicationRegistrationData& aAppInfo, const Usif::RSoftwareComponentRegistry& aScr)
       
   221     {
       
   222     CApaAppInfoReader* self = new(ELeave) CApaAppInfoReader(aFs, aAppInfo, aScr);
       
   223     CleanupStack::PushL(self);
       
   224     self->ConstructL();
       
   225     CleanupStack::Pop(self);
       
   226     return self;
       
   227     }
       
   228 
       
   229 /*
       
   230  * Reads the application information from SCR. 
       
   231  */
       
   232 TBool CApaAppInfoReader::ReadL()
       
   233     {
       
   234     ReadAppRegistrationInfoL();
       
   235     ReadLocalisationInfoL();  
       
   236 #ifdef APPARC_SHOW_TRACE    
       
   237     DisplayAppInfo();
       
   238 #endif
       
   239     return ETrue;
       
   240     }
       
   241 
       
   242 #ifdef APPARC_SHOW_TRACE
       
   243 void CApaAppInfoReader::DisplayAppInfo()
       
   244     { 
       
   245     RDebug::Print(_L("[Apparc] Application UID: %X"), iAppUid.iUid);
       
   246     if(iAppBinaryFullName)
       
   247         RDebug::Print(_L("[Apparc] AppBinary Name: %S"), iAppBinaryFullName);
       
   248     
       
   249     RDebug::Print(_L("[Apparc] Embeddability: %d"), iCapability.iEmbeddability);
       
   250     RDebug::Print(_L("[Apparc] Hidden: %d"), iCapability.iAppIsHidden);
       
   251     RDebug::Print(_L("[Apparc] NewFile: %d"), iCapability.iSupportsNewFile);
       
   252     RDebug::Print(_L("[Apparc] Launch in Foreground: %d"), iCapability.iLaunchInBackground);
       
   253     RDebug::Print(_L("[Apparc] Attributes: %X"), iCapability.iAttributes);
       
   254     RDebug::Print(_L("[Apparc] Group Name: %S"), &iCapability.iGroupName);
       
   255     
       
   256     RDebug::Print(_L("[Apparc] Default Screen Number: %d"), iDefaultScreenNumber);
       
   257     RDebug::Print(_L("[Apparc] Application Language: %d"), iApplicationLanguage);
       
   258     
       
   259     if(iCaption)
       
   260         RDebug::Print(_L("[Apparc] Short Cpation: %S"), iCaption); 
       
   261 		
       
   262     if(iShortCaption)
       
   263         RDebug::Print(_L("[Apparc] Caption: %S"), iShortCaption);
       
   264     
       
   265     if(iServiceArray)
       
   266         {
       
   267         for(TInt index=0;index<iServiceArray->Count();index++)
       
   268             {
       
   269             TApaAppServiceInfo serviceInfo=(*iServiceArray)[index];
       
   270             RDebug::Print(_L("[Apparc] Service Uid: %X"), serviceInfo.Uid().iUid);
       
   271             
       
   272             for(TInt j=0;j<serviceInfo.DataTypes().Count();j++)
       
   273             {
       
   274             TDataTypeWithPriority dataType=(serviceInfo.DataTypes())[j];
       
   275             RDebug::Print(_L("[Apparc] Data Type: %s   Priority:%d"), &dataType.iDataType, dataType.iPriority);
       
   276             }
       
   277             
       
   278             }
       
   279         }
       
   280     
       
   281     if(iIconFileName)
       
   282         {
       
   283         RDebug::Print(_L("[Apparc] Icon File: %S"), iIconFileName);   
       
   284         
       
   285         if(iNonMbmIconFile)
       
   286             RDebug::Print(_L("[Apparc] Its Non MBM icon file"));
       
   287         RDebug::Print(_L("[Apparc] Num Icons: %d"), iNumOfAppIcons);
       
   288         }
       
   289 
       
   290     if(iViewDataArray)
       
   291         {
       
   292         for(TInt index=0; index<iViewDataArray->Count();index++)
       
   293             {
       
   294             CApaAppViewData* view= (*iViewDataArray)[index];
       
   295             RDebug::Print(_L("[Apparc] ViewID: %X"), view->Uid().iUid);
       
   296             //RDebug::Print(_L("[Apparc] View Caption: %s"), view->Caption());
       
   297             //RDebug::Print(_L("[Apparc] View Icon File: %s"), view->IconFileName());   
       
   298             if(view->NonMbmIconFile())
       
   299                 RDebug::Print(_L("[Apparc] Its Non MBM icon file"));
       
   300             RDebug::Print(_L("[Apparc] Screen Mode: %d"), view->ScreenMode());
       
   301             }
       
   302         }
       
   303     }
       
   304 
       
   305 #endif
       
   306 
       
   307 
       
   308 void CApaAppInfoReader::ReadAppRegistrationInfoL()
       
   309     {
       
   310     //Get 3rd UID of the application
       
   311     iAppUid=iAppInfo.AppUid();
       
   312     
       
   313     iCapability.iAttributes=iAppInfo.Attributes();
       
   314     TUid firstUid(KExecutableImageUid);
       
   315     TUid middleUid(KUidApp);
       
   316 
       
   317     //If the application is non-native, first UID should be Null UID and second uid is the non-native application type(i.e type ID of java, widget etc.). 
       
   318     if (iCapability.iAttributes & TApaAppCapability::ENonNative)
       
   319         {
       
   320             firstUid=KNullUid;
       
   321             middleUid.iUid=iAppInfo.TypeId();
       
   322         }
       
   323     else if (iCapability.iAttributes & TApaAppCapability::EBuiltAsDll)
       
   324         {
       
   325         User::Leave(KErrNotSupported); // legacy dll-style app
       
   326         }
       
   327     
       
   328     iAppBinaryUidType=TUidType(firstUid, middleUid, iAppUid);
       
   329    
       
   330     //If executable file name is not given then just leave. 
       
   331     if(iAppInfo.AppFile().Length() ==0 )
       
   332         User::Leave(KErrGeneral);
       
   333 
       
   334     //Absolute path of the executable file is stored in iAppBinaryFullName
       
   335     iAppBinaryFullName=iAppInfo.AppFile().AllocL();
       
   336     
       
   337 //    //Check whether the binary exists.
       
   338     /*RLibrary::TInfoBuf infoBuf;
       
   339     TInt ret = RLibrary::GetInfo(*iAppBinaryFullName, infoBuf);
       
   340     User::LeaveIfError(ret);
       
   341     
       
   342     if(infoBuf().iUids[2]!=iAppUid && iAppBinaryUidType[1]==KUidApp)
       
   343         User::Leave(KErrNotFound);*/
       
   344     
       
   345     iCapability.iAppIsHidden=iAppInfo.Hidden();
       
   346     iCapability.iEmbeddability = static_cast<TApaAppCapability::TEmbeddability>(iAppInfo.Embeddability());
       
   347     iCapability.iLaunchInBackground=iAppInfo.Launch();
       
   348     iCapability.iSupportsNewFile=iAppInfo.NewFile();
       
   349     
       
   350     iDefaultScreenNumber=iAppInfo.DefaultScreenNumber();
       
   351     
       
   352     iCapability.iGroupName=iAppInfo.GroupName();
       
   353     
       
   354     RPointerArray<Usif::COpaqueData> appOpaqueData=iAppInfo.AppOpaqueData();
       
   355     ASSERT(!(appOpaqueData.Count()>1));
       
   356     
       
   357     if(appOpaqueData.Count()>0)
       
   358         {
       
   359         iOpaqueData=appOpaqueData[0]->OpaqueData().AllocL();
       
   360         }
       
   361     else
       
   362         {
       
   363         //If opaque data is not available, create an empty object and assign to iOpaqueData
       
   364         iOpaqueData=HBufC8::NewL(0);
       
   365         }  
       
   366     
       
   367     ReadServiceInfoL(iAppInfo.ServiceArray()); 
       
   368     ReadOwnedFilesInfoL(iAppInfo.OwnedFileArray());
       
   369     }
       
   370 
       
   371 
       
   372 /*
       
   373  * Reads service information of the application.
       
   374  */
       
   375 void CApaAppInfoReader::ReadServiceInfoL(const RPointerArray<Usif::CServiceInfo>& aServiceInfo)
       
   376     {
       
   377     TInt serviceCount=aServiceInfo.Count();
       
   378     
       
   379     if (serviceCount > 0)
       
   380         {
       
   381         iServiceArray = new(ELeave) CArrayFixFlat<TApaAppServiceInfo>(4);   
       
   382         }
       
   383     else
       
   384         {
       
   385         //if service information is not avaliable, just return.
       
   386         return;        
       
   387         }
       
   388 
       
   389     //Read application service info one at a time and store in iServiceArray.
       
   390     for (TInt index=0;index<serviceCount;index++)
       
   391         {
       
   392         TUid serviceUid=aServiceInfo[index]->Uid();
       
   393         
       
   394         CArrayFixFlat<TDataTypeWithPriority>* mimeTypesSupported = new(ELeave) CArrayFixFlat<TDataTypeWithPriority>(5);
       
   395         CleanupStack::PushL(mimeTypesSupported);
       
   396         
       
   397         //Read supported mime types of a service
       
   398         ReadMimeTypesSupportedL(aServiceInfo[index]->DataTypes(), *mimeTypesSupported); 
       
   399         
       
   400         RPointerArray<Usif::COpaqueData> serviceOpaqueData=aServiceInfo[index]->OpaqueData();
       
   401         //SCR schould give atmost only one opaque data for a service.
       
   402         ASSERT(!(serviceOpaqueData.Count()>1));
       
   403         
       
   404         HBufC8* opaqueData=NULL;
       
   405         if(serviceOpaqueData.Count()>0)
       
   406             {
       
   407             opaqueData= serviceOpaqueData[0]->OpaqueData().AllocL();
       
   408             }
       
   409         else
       
   410             {
       
   411             //If opaque data is not available, create an empty object and assign to opaqueData        
       
   412             opaqueData=HBufC8::NewL(0);
       
   413             }
       
   414         
       
   415         TApaAppServiceInfo serviceInfo(serviceUid, mimeTypesSupported,opaqueData); // takes ownership of mimeTypesSupported and opaqueData 
       
   416         CleanupStack::PushL(opaqueData);
       
   417         iServiceArray->AppendL(serviceInfo);
       
   418         CleanupStack::Pop(2, mimeTypesSupported);        
       
   419     
       
   420         //If service UID is KOpenServiceUid and it is first open service then initialize iIndexOfFirstOpenService
       
   421         if ((serviceUid == KOpenServiceUid) && (iIndexOfFirstOpenService < 0))
       
   422             iIndexOfFirstOpenService = iServiceArray->Count() - 1;        
       
   423         }
       
   424     } 
       
   425 
       
   426 
       
   427 /*
       
   428  * Reads supported mime types and its handling priorities of a service
       
   429  */
       
   430 void CApaAppInfoReader::ReadMimeTypesSupportedL(const RPointerArray<Usif::CDataType>& dataTypes, CArrayFixFlat<TDataTypeWithPriority>& aMimeTypesSupported) 
       
   431     {
       
   432     
       
   433     const TInt dataTypeArraySize = dataTypes.Count();
       
   434     //if there are no data types available, just return.
       
   435     if (dataTypeArraySize <= 0)
       
   436         return;
       
   437    
       
   438     for (TInt i=0; i < dataTypeArraySize; i++)
       
   439         {
       
   440         TDataTypePriority priority = static_cast<TDataTypePriority>(dataTypes[i]->Priority());
       
   441         
       
   442         //Check for data priority of UnTrusted apps however the trusted apps will not have any restrictions 
       
   443         //over the data priority.   
       
   444         //If an untrusted app has write device data capability (i.e. still has priority = KDataTypePrioritySystem),
       
   445         //do not restrict to KDataTypeUnTrustedPriorityThreshold
       
   446         if (priority > KDataTypeUnTrustedPriorityThreshold || priority == KDataTypePrioritySystem )
       
   447             {
       
   448             ReadAppSecurityInfo();
       
   449 
       
   450             if (priority == KDataTypePrioritySystem)
       
   451                 {
       
   452                 // Check that the app has capability WriteDeviceData
       
   453                 if (!iHasWriteDeviceDataCap)
       
   454                     priority = KDataTypePriorityNormal;
       
   455                 }
       
   456             else
       
   457                 {
       
   458                 //data priority for UnTrusted apps would be capped if it is greater than the threshold priority i.e, KMaxTInt16.
       
   459                 //Component ID is zero if the application is shipped with phone.
       
   460                 TBool isInstalledApp=(iScr.GetComponentIdForAppL(iAppBinaryUidType[2])!=0);
       
   461                 if (!iIsSidTrusted && isInstalledApp) 
       
   462                     {
       
   463                     //if application sid is in unprotected range and the applciation is instaleld with  
       
   464                     //one of the installers after phone marketed, then priority needs to be downgraded.
       
   465                     priority = KDataTypeUnTrustedPriorityThreshold; 
       
   466                     }
       
   467                 }
       
   468             }
       
   469 
       
   470         TBuf8<KMaxDataTypeLength> buf;
       
   471         //Convert 16-bit descriptor to 8-bit descriptor.
       
   472         buf.Copy(dataTypes[i]->Type());
       
   473 
       
   474         TDataType dataType(buf);
       
   475         TDataTypeWithPriority dataTypeWithPriority(dataType, priority); 
       
   476         aMimeTypesSupported.AppendL(dataTypeWithPriority);
       
   477         }
       
   478     }
       
   479 
       
   480 
       
   481 /*
       
   482  * Reads owned files information.
       
   483  */
       
   484 void CApaAppInfoReader::ReadOwnedFilesInfoL(const RPointerArray<HBufC>& aOwnedFiles)
       
   485     {
       
   486     const TInt fileOwnershipArraySize = aOwnedFiles.Count();
       
   487     
       
   488     //if owned files information is not avaliable, just return.
       
   489     if (fileOwnershipArraySize <= 0)
       
   490         return;
       
   491     
       
   492     iOwnedFileArray = new(ELeave) CDesCArraySeg(fileOwnershipArraySize);
       
   493 
       
   494     for (TInt index=0; index < fileOwnershipArraySize; index++)
       
   495         {
       
   496         HBufC *fileowned=aOwnedFiles[index]->Des().AllocL();
       
   497         CleanupStack::PushL(fileowned);
       
   498         iOwnedFileArray->AppendL(*fileowned); //takes the ownership of fileowned
       
   499         CleanupStack::Pop(fileowned);
       
   500         }
       
   501     }
       
   502 
       
   503 void CApaAppInfoReader::ReadLocalisationInfoL()
       
   504     {
       
   505     RPointerArray<Usif::CLocalizableAppInfo> localisationInfo;
       
   506     localisationInfo=iAppInfo.LocalizableAppInfoList();
       
   507     ASSERT(localisationInfo.Count() <= 1);
       
   508     
       
   509     if(localisationInfo.Count()<=0)
       
   510         {
       
   511         //If localisable information is not avaialable then assign default icons.
       
   512         TRAP_IGNORE(iIcons = CApaAppIconArray::NewDefaultIconsL());     
       
   513         return;
       
   514         }
       
   515 
       
   516     //Group name provided in localisation file takes precedence over group name provided in registration file name.
       
   517     const TDesC& groupName=localisationInfo[0]->GroupName();
       
   518 
       
   519     if(groupName.Length()>0)
       
   520         {
       
   521         iCapability.iGroupName=groupName;
       
   522         }
       
   523     
       
   524     //Get application language for current phone language.
       
   525     iApplicationLanguage=localisationInfo[0]->ApplicationLanguage();
       
   526     
       
   527     const Usif::CCaptionAndIconInfo* captionIconInfo=localisationInfo[0]->CaptionAndIconInfo();
       
   528     
       
   529     TBool useDefaultIcons=ETrue;
       
   530     
       
   531     if(captionIconInfo!=NULL)
       
   532         {
       
   533         iShortCaption=localisationInfo[0]->ShortCaption().AllocL();
       
   534         if(iShortCaption && iShortCaption->Length() == 0)
       
   535             {
       
   536                 delete iShortCaption;
       
   537                 iShortCaption=NULL;
       
   538             }
       
   539     
       
   540         iCaption=captionIconInfo->Caption().AllocL();
       
   541         if(iCaption && iCaption->Length() == 0)
       
   542             {
       
   543                 delete iCaption;
       
   544                 iCaption=NULL;
       
   545             }        
       
   546     
       
   547         iNumOfAppIcons=captionIconInfo->NumOfAppIcons();
       
   548 
       
   549         if(captionIconInfo->IconFileName().Length()>0)
       
   550             iIconFileName=captionIconInfo->IconFileName().AllocL();    
       
   551 
       
   552         
       
   553         if (iIconFileName && iIconFileName->Length())
       
   554             {
       
   555             if (iFs.IsValidName(*iIconFileName))
       
   556                 {
       
   557                 RFile file;
       
   558                 TInt fileSize( 0 );
       
   559                 TInt err= file.Open(iFs, *iIconFileName, EFileShareReadersOnly );
       
   560                 
       
   561                 //If the icon file does not exist, use default icons.
       
   562                 if(err==KErrNone)
       
   563                     {
       
   564                     User::LeaveIfError(err);
       
   565                     CleanupClosePushL( file );
       
   566                     User::LeaveIfError( file.Size( fileSize ) );
       
   567                     CleanupStack::PopAndDestroy(&file);//file
       
   568                     
       
   569                     if ( fileSize > 0 )
       
   570                         {
       
   571                         if(FileIsMbmWithGenericExtensionL(*iIconFileName))
       
   572                             {
       
   573                             if (iNumOfAppIcons > 0)
       
   574                                 {
       
   575                                 //Icon file is valid and contains mbm icons.
       
   576                                 iIcons = CApaAppIconArray::NewAppIconsL(iNumOfAppIcons, *iIconFileName, *iIconLoader);
       
   577                                 useDefaultIcons=EFalse;
       
   578                                 }
       
   579                             }
       
   580                         else
       
   581                             {
       
   582                             //If the icon file is not a mbm icon file then the file is treated as a non-mbm file.                
       
   583                             iNonMbmIconFile = ETrue;
       
   584                             useDefaultIcons=EFalse;
       
   585                             }
       
   586                         
       
   587                         }
       
   588                     }
       
   589                 }
       
   590             else
       
   591                 {
       
   592                 //If the filename is not a valid name then the file is treated as a non-mbm file.        
       
   593                 iNonMbmIconFile = ETrue;
       
   594                 useDefaultIcons=EFalse;                
       
   595                 }
       
   596             }
       
   597         }
       
   598     
       
   599     if(useDefaultIcons)
       
   600         TRAP_IGNORE(iIcons = CApaAppIconArray::NewDefaultIconsL());        
       
   601 
       
   602     ReadViewInfoL(localisationInfo[0]->ViewDataList());
       
   603     }
       
   604 
       
   605 /*
       
   606  * Read application view information.
       
   607  */
       
   608 
       
   609 void CApaAppInfoReader::ReadViewInfoL(const RPointerArray<Usif::CAppViewData>& aViewData)
       
   610     {
       
   611      const TInt numOfViews = aViewData.Count();
       
   612 
       
   613      //if view information not avaliable, just return.     
       
   614      if(numOfViews <=0 )
       
   615          return;
       
   616      
       
   617      iViewDataArray = new(ELeave) CArrayPtrFlat<CApaAppViewData>(numOfViews);
       
   618 
       
   619      //Read one view information at time and add it iViewDataArray
       
   620      for(TInt view = 0; view < numOfViews; ++view)
       
   621          {
       
   622          CApaAppViewData* viewData = CApaAppViewData::NewLC();
       
   623          
       
   624          const TUid viewUid = aViewData[view]->Uid();
       
   625          viewData->SetUid(viewUid);
       
   626          
       
   627          const TInt screenMode = {aViewData[view]->ScreenMode()};
       
   628          viewData->SetScreenMode(screenMode);
       
   629 
       
   630          const Usif::CCaptionAndIconInfo* viewCaptionIconInfo=aViewData[view]->CaptionAndIconInfo();
       
   631          
       
   632          if(viewCaptionIconInfo!=NULL)
       
   633              {
       
   634              viewData->SetCaptionL(viewCaptionIconInfo->Caption());
       
   635     
       
   636              const TInt numOfViewIcons = viewCaptionIconInfo->NumOfAppIcons();
       
   637              viewData->SetNumOfViewIcons(numOfViewIcons);
       
   638     
       
   639              TPtrC viewIconFile = viewCaptionIconInfo->IconFileName();
       
   640              
       
   641              if (viewIconFile.Length())
       
   642                  {
       
   643                  viewData->SetIconFileNameL(viewIconFile);
       
   644                  
       
   645                  if (iFs.IsValidName(viewIconFile))
       
   646                      {
       
   647                      if(!FileIsMbmWithGenericExtensionL(viewIconFile))
       
   648                          viewData->SetNonMbmIconFile(ETrue);
       
   649                      }
       
   650                  else    //If the filename is not a valid name then the file is treated as a non-mbm file.
       
   651                      viewData->SetNonMbmIconFile(ETrue);
       
   652                  }
       
   653              else
       
   654                  {
       
   655                  viewIconFile.Set(KNullDesC);
       
   656                  if (numOfViewIcons > 0 && iIconFileName)
       
   657                      viewIconFile.Set(*iIconFileName); // default to app icon filename
       
   658                  }
       
   659              
       
   660              if (numOfViewIcons > 0 && iFs.IsValidName(viewIconFile) && FileIsMbmWithGenericExtensionL(viewIconFile))
       
   661                  {
       
   662                  CApaAppIconArray* iconArray = CApaAppIconArray::NewViewIconsL(numOfViewIcons, viewIconFile, *iIconLoader);
       
   663                  viewData->SetIconArray(iconArray);
       
   664                  iconArray = NULL;
       
   665                  }
       
   666              }
       
   667 
       
   668          iViewDataArray->AppendL(viewData);
       
   669          CleanupStack::Pop(viewData);
       
   670          }    
       
   671     }
       
   672 
       
   673 #else
       
   674 
       
   675 CApaAppInfoReader* CApaAppInfoReader::NewL(RFs& aFs, const TDesC& aRegistrationFileName, TUid aAppUid)
       
   676     {
       
   677     CApaAppInfoReader* self = new(ELeave) CApaAppInfoReader(aFs, aRegistrationFileName, aAppUid);
       
   678     CleanupStack::PushL(self);
       
   679     self->ConstructL();
       
   680     CleanupStack::Pop(self);
       
   681     return self;
       
   682     }
       
   683 
       
   684 CApaAppInfoReader::CApaAppInfoReader(RFs& aFs, const TDesC& aRegistrationFileName, TUid aAppUid) :
       
   685     iFs(aFs),
       
   686     iAppUid(aAppUid),
       
   687     iTimeStamp(0),
       
   688     iDefaultScreenNumber(0),
       
   689     iNonMbmIconFile(EFalse),
       
   690     iLocalisableResourceFileTimeStamp(0),
       
   691     iApplicationLanguage(ELangNone),
       
   692     iIndexOfFirstOpenService(KErrNotFound),
       
   693     iRegistrationFileName(aRegistrationFileName)
       
   694     {
       
   695     }
       
   696 
       
   697 TTime CApaAppInfoReader::TimeStamp() const
       
   698     {
       
   699     return iTimeStamp;
       
   700     }
       
   701 
       
   702 TTime CApaAppInfoReader::IconFileTimeStamp() const
       
   703      {
       
   704      return iIconFileTimeStamp;
       
   705      }
       
   706 
       
   707 HBufC* CApaAppInfoReader::LocalisableResourceFileName()
       
   708     {
       
   709     HBufC* localisableResourceFileName = iLocalisableResourceFileName;
       
   710     iLocalisableResourceFileName = NULL; // ownership transferred to caller
       
   711     return localisableResourceFileName;
       
   712     }
       
   713 
       
   714 TTime CApaAppInfoReader::LocalisableResourceFileTimeStamp() const
       
   715     {
       
   716     return iLocalisableResourceFileTimeStamp;
       
   717     }
       
   718 
   241 
   719 // reads as much info as it can
   242 // reads as much info as it can
   720 // at least captions and icons must be setup on return from this method (using defaults if necessary)
   243 // at least captions and icons must be setup on return from this method (using defaults if necessary)
   721 TBool CApaAppInfoReader::ReadL()
   244 TBool CApaAppInfoReader::ReadL()
   722 	{
   245 	{
   834 		// exe-style app
   357 		// exe-style app
   835 		User::LeaveIfError(parse.SetNoWild(registrationFileDrive, &KAppBinaryPathAndExtension, &appNameWithoutExtension));
   358 		User::LeaveIfError(parse.SetNoWild(registrationFileDrive, &KAppBinaryPathAndExtension, &appNameWithoutExtension));
   836 		}
   359 		}
   837 
   360 
   838 	iAppBinaryFullName = parse.FullName().AllocL();
   361 	iAppBinaryFullName = parse.FullName().AllocL();
       
   362 	}
       
   363 
       
   364 
       
   365 HBufC* CApaAppInfoReader::CreateFullIconFileNameL(const TDesC& aIconFileName) const
       
   366 	{
       
   367 	HBufC* filename = NULL;
       
   368 	if (aIconFileName.Length() == 0)
       
   369 		return NULL;
       
   370 	/*
       
   371 	 * aIconFileName may contain a valid string in some format (for eg. URI format) other than path to a regular file on disk
       
   372 	 * and that can be a mbm or non-mbm file. Such a filename will be reported as invalid filename by iFs.IsValidName() method. 
       
   373 	 * aIconFileName will be returned since it is a valid string. 
       
   374 	 */	
       
   375 	if(!iFs.IsValidName(aIconFileName))
       
   376 		{
       
   377 		filename = aIconFileName.AllocL();
       
   378 		return filename;
       
   379 		}
       
   380 	
       
   381 	TParsePtrC parsePtr(aIconFileName);
       
   382 	if (parsePtr.IsWild() || !parsePtr.PathPresent() || !parsePtr.NamePresent())
       
   383 		return NULL;
       
   384 
       
   385 	// check for fully qualified icon filename
       
   386 	if (parsePtr.DrivePresent() && BaflUtils::FileExists(iFs, aIconFileName))
       
   387 		filename = aIconFileName.AllocL();
       
   388 	else
       
   389 		{
       
   390 		// check for icon file on same drive as localisable resource file
       
   391 		TParse parse;
       
   392 		TPtrC localisableResourceFileDrive = TParsePtrC(*iLocalisableResourceFileName).Drive();
       
   393 		TInt ret = parse.SetNoWild(localisableResourceFileDrive, &aIconFileName, NULL);
       
   394 		if (ret == KErrNone && BaflUtils::FileExists(iFs, parse.FullName()))
       
   395 			filename = parse.FullName().AllocL();
       
   396 		else
       
   397 			{
       
   398 			TPtrC registrationFileDrive = TParsePtrC(iRegistrationFileName).Drive();
       
   399 			if (TInt(TDriveUnit(registrationFileDrive)) != TInt(TDriveUnit(localisableResourceFileDrive)))
       
   400 				{
       
   401 				// check for icon file on same drive as registration file
       
   402 				ret = parse.SetNoWild(registrationFileDrive, &aIconFileName, NULL);
       
   403 				if (ret == KErrNone && BaflUtils::FileExists(iFs, parse.FullName()))
       
   404 					filename = parse.FullName().AllocL();
       
   405 				}
       
   406 			}
       
   407 		}
       
   408 
       
   409 	return filename;
   839 	}
   410 	}
   840 
   411 
   841 void CApaAppInfoReader::ReadLocalisableInfoL(const CResourceFile& aResourceFile, TUint aResourceId, TBool& aUseDefaultIcons)
   412 void CApaAppInfoReader::ReadLocalisableInfoL(const CResourceFile& aResourceFile, TUint aResourceId, TBool& aUseDefaultIcons)
   842 	{
   413 	{
   843 	RResourceReader resourceReader;
   414 	RResourceReader resourceReader;
   997 		}
   568 		}
   998 
   569 
   999 	CleanupStack::PopAndDestroy(&resourceReader);
   570 	CleanupStack::PopAndDestroy(&resourceReader);
  1000 	}
   571 	}
  1001 
   572 
       
   573 /*An MBM file may have a generic icon extension. In this case, as a way to check whether the file is an MBM one, 
       
   574 it is necessary to read the content of the fist four 32bit words of it and find out whether these words correspond to 
       
   575 KWriteonceFileStoreUid, KMultiBitmapFileImageUid, zero and KMultiBitmapFileImageChecksum respectively (defined in graphics/gditools/bmconv/bmconv.h).
       
   576 So the file is opened and the first 4 32 bit words are extracted and compared with the header information of standard MBM file.
       
   577 If they match, the function returns ETrue, else it returns EFalse */
       
   578 TBool CApaAppInfoReader::FileIsMbmWithGenericExtensionL(const TDesC& aFileName)
       
   579       { 
       
   580       if (aFileName.Length() > 0) 
       
   581             { 
       
   582             //open a file in Share mode - this will allow other methods to access it too
       
   583             RFile file;
       
   584             RFs fs;
       
   585             User::LeaveIfError(fs.Connect());
       
   586             CleanupClosePushL(fs);
       
   587             User::LeaveIfError(file.Open(fs,aFileName,EFileShareReadersOnly));
       
   588             //this is done beacuse the file can also be accessed by applist at the same time
       
   589             //buffer stores the 16 bytes of the file
       
   590             CleanupClosePushL(file);
       
   591             TBuf8<16> buffer;
       
   592             User::LeaveIfError(file.Read(buffer,16));
       
   593             CleanupStack::PopAndDestroy();//file
       
   594             CleanupStack::PopAndDestroy(&fs);//fs
       
   595             //we use a constant pointer to the buffer to read header info
       
   596         	TPtrC8 filePointer(buffer);
       
   597         	
       
   598             /*The first 16 bytes of an MBM file are the same for any generic MBM file.
       
   599             These are :
       
   600             KWriteOnceFileStoreUid = 0x10000037(Emulator MBM file) 0x10000041(ROM image)	
       
   601             KMultiBitMapFileImageUid = 0x10000042(Emulator MBM file) 	0x00000001(ROM image)
       
   602             Zero = 0x00000000(Emulator MBM file) 0x0000000C(ROM image)
       
   603             checksum = 0x47396439(Emulator MBM file) 0x10000040(ROM image)
       
   604             The first 16 bytes of the given file is compared with these standard values to ascertain it is MBM file*/
       
   605         	if((filePointer[3]==0x10)&&(filePointer[2]==0x00)&&(filePointer[1]==0x00)&&(filePointer[0]==0x37))
       
   606         		{//KWriteOnceFileStoreUid = 0x10000037
       
   607         		if((filePointer[7]==0x10)&&(filePointer[6]==0x00)&&(filePointer[5]==0x00)&&(filePointer[4]==0x42))
       
   608         			{//KMultiBitMapFileImageUid = 0x10000042
       
   609         			if((filePointer[11]==0x00)&&(filePointer[10]==0x00)&&(filePointer[9]==0x00)&&(filePointer[8]==0x00))
       
   610         				{//Zero = 0x00000000)
       
   611         				if((filePointer[15]==0x47)&&(filePointer[14]==0x39)&&(filePointer[13]==0x64)&&(filePointer[12]==0x39))
       
   612         					{//checksum = 0x47396439
       
   613         					return ETrue;
       
   614         					}
       
   615         				}
       
   616         			}
       
   617         		}
       
   618         	//Else Check for ROM Image MBM file's header
       
   619         	else if((filePointer[3]==0x10)&&(filePointer[2]==0x00)&&(filePointer[1]==0x00)&&(filePointer[0]==0x41))
       
   620         		{//KWriteOnceFileStoreUid = 0x10000041
       
   621         		if((filePointer[7]==0x00)&&(filePointer[6]==0x00)&&(filePointer[5]==0x00)&&(filePointer[4]==0x01))
       
   622         			{//KMultiBitMapFileImageUid = 0x00000001
       
   623         			if((filePointer[11]==0x00)&&(filePointer[10]==0x00)&&(filePointer[9]==0x00)&&(filePointer[8]==0x0C))
       
   624         				{//Zero = 0x0000000C)
       
   625         				if((filePointer[15]==0x10)&&(filePointer[14]==0x00)&&(filePointer[13]==0x00)&&(filePointer[12]==0x40))
       
   626         					{//checksum = 0x10000040
       
   627         					return ETrue;
       
   628         					}
       
   629         				}
       
   630         			}
       
   631         		}
       
   632         	}
       
   633       return EFalse;
       
   634       }
  1002 
   635 
  1003 HBufC8* CApaAppInfoReader::ReadOpaqueDataL(TUint aResourceId, const CResourceFile* aRegistrationFile, CResourceFile* aLocalisableResourceFile)
   636 HBufC8* CApaAppInfoReader::ReadOpaqueDataL(TUint aResourceId, const CResourceFile* aRegistrationFile, CResourceFile* aLocalisableResourceFile)
  1004 	{ // static
   637 	{ // static
  1005 	HBufC8* opaqueData = NULL;
   638 	HBufC8* opaqueData = NULL;
  1006 	if (aResourceId == 0)
   639 	if (aResourceId == 0)
  1209 		TDataTypeWithPriority dataTypeWithPriority(dataType, priority);
   842 		TDataTypeWithPriority dataTypeWithPriority(dataType, priority);
  1210 		aMimeTypesSupported.AppendL(dataTypeWithPriority);
   843 		aMimeTypesSupported.AppendL(dataTypeWithPriority);
  1211 		}
   844 		}
  1212 	}
   845 	}
  1213 
   846 
  1214 
       
  1215 HBufC* CApaAppInfoReader::CreateFullIconFileNameL(const TDesC& aIconFileName) const
       
  1216     {
       
  1217     HBufC* filename = NULL;
       
  1218     if (aIconFileName.Length() == 0)
       
  1219         return NULL;
       
  1220     /*
       
  1221      * aIconFileName may contain a valid string in some format (for eg. URI format) other than path to a regular file on disk
       
  1222      * and that can be a mbm or non-mbm file. Such a filename will be reported as invalid filename by iFs.IsValidName() method. 
       
  1223      * aIconFileName will be returned since it is a valid string. 
       
  1224      */ 
       
  1225     if(!iFs.IsValidName(aIconFileName))
       
  1226         {
       
  1227         filename = aIconFileName.AllocL();
       
  1228         return filename;
       
  1229         }
       
  1230     
       
  1231     TParsePtrC parsePtr(aIconFileName);
       
  1232     if (parsePtr.IsWild() || !parsePtr.PathPresent() || !parsePtr.NamePresent())
       
  1233         return NULL;
       
  1234 
       
  1235     // check for fully qualified icon filename
       
  1236     if (parsePtr.DrivePresent() && BaflUtils::FileExists(iFs, aIconFileName))
       
  1237         filename = aIconFileName.AllocL();
       
  1238     else
       
  1239         {
       
  1240         // check for icon file on same drive as localisable resource file
       
  1241         TParse parse;
       
  1242         TPtrC localisableResourceFileDrive = TParsePtrC(*iLocalisableResourceFileName).Drive();
       
  1243         TInt ret = parse.SetNoWild(localisableResourceFileDrive, &aIconFileName, NULL);
       
  1244         if (ret == KErrNone && BaflUtils::FileExists(iFs, parse.FullName()))
       
  1245             filename = parse.FullName().AllocL();
       
  1246         else
       
  1247             {
       
  1248             TPtrC registrationFileDrive = TParsePtrC(iRegistrationFileName).Drive();
       
  1249             if (TInt(TDriveUnit(registrationFileDrive)) != TInt(TDriveUnit(localisableResourceFileDrive)))
       
  1250                 {
       
  1251                 // check for icon file on same drive as registration file
       
  1252                 ret = parse.SetNoWild(registrationFileDrive, &aIconFileName, NULL);
       
  1253                 if (ret == KErrNone && BaflUtils::FileExists(iFs, parse.FullName()))
       
  1254                     filename = parse.FullName().AllocL();
       
  1255                 }
       
  1256             }
       
  1257         }
       
  1258 
       
  1259     return filename;
       
  1260     }
       
  1261 
       
  1262 #endif
       
  1263 
       
  1264 /*An MBM file may have a generic icon extension. In this case, as a way to check whether the file is an MBM one, 
       
  1265 it is necessary to read the content of the fist four 32bit words of it and find out whether these words correspond to 
       
  1266 KWriteonceFileStoreUid, KMultiBitmapFileImageUid, zero and KMultiBitmapFileImageChecksum respectively (defined in graphics/gditools/bmconv/bmconv.h).
       
  1267 So the file is opened and the first 4 32 bit words are extracted and compared with the header information of standard MBM file.
       
  1268 If they match, the function returns ETrue, else it returns EFalse */
       
  1269 TBool CApaAppInfoReader::FileIsMbmWithGenericExtensionL(const TDesC& aFileName)
       
  1270       { 
       
  1271       if (aFileName.Length() > 0) 
       
  1272             { 
       
  1273             //open a file in Share mode - this will allow other methods to access it too
       
  1274             RFile file;
       
  1275             RFs fs;
       
  1276             User::LeaveIfError(fs.Connect());
       
  1277             CleanupClosePushL(fs);
       
  1278             User::LeaveIfError(file.Open(fs,aFileName,EFileShareReadersOnly));
       
  1279             //this is done beacuse the file can also be accessed by applist at the same time
       
  1280             //buffer stores the 16 bytes of the file
       
  1281             CleanupClosePushL(file);
       
  1282             TBuf8<16> buffer;
       
  1283             User::LeaveIfError(file.Read(buffer,16));
       
  1284             CleanupStack::PopAndDestroy();//file
       
  1285             CleanupStack::PopAndDestroy(&fs);//file, fs
       
  1286             //we use a constant pointer to the buffer to read header info
       
  1287             TPtrC8 filePointer(buffer);
       
  1288             
       
  1289             /*The first 16 bytes of an MBM file are the same for any generic MBM file.
       
  1290             These are :
       
  1291             KWriteOnceFileStoreUid = 0x10000037(Emulator MBM file) 0x10000041(ROM image)    
       
  1292             KMultiBitMapFileImageUid = 0x10000042(Emulator MBM file)    0x00000001(ROM image)
       
  1293             Zero = 0x00000000(Emulator MBM file) 0x0000000C(ROM image)
       
  1294             checksum = 0x47396439(Emulator MBM file) 0x10000040(ROM image)
       
  1295             The first 16 bytes of the given file is compared with these standard values to ascertain it is MBM file*/
       
  1296             if((filePointer[3]==0x10)&&(filePointer[2]==0x00)&&(filePointer[1]==0x00)&&(filePointer[0]==0x37))
       
  1297                 {//KWriteOnceFileStoreUid = 0x10000037
       
  1298                 if((filePointer[7]==0x10)&&(filePointer[6]==0x00)&&(filePointer[5]==0x00)&&(filePointer[4]==0x42))
       
  1299                     {//KMultiBitMapFileImageUid = 0x10000042
       
  1300                     if((filePointer[11]==0x00)&&(filePointer[10]==0x00)&&(filePointer[9]==0x00)&&(filePointer[8]==0x00))
       
  1301                         {//Zero = 0x00000000)
       
  1302                         if((filePointer[15]==0x47)&&(filePointer[14]==0x39)&&(filePointer[13]==0x64)&&(filePointer[12]==0x39))
       
  1303                             {//checksum = 0x47396439
       
  1304                             return ETrue;
       
  1305                             }
       
  1306                         }
       
  1307                     }
       
  1308                 }
       
  1309             //Else Check for ROM Image MBM file's header
       
  1310             else if((filePointer[3]==0x10)&&(filePointer[2]==0x00)&&(filePointer[1]==0x00)&&(filePointer[0]==0x41))
       
  1311                 {//KWriteOnceFileStoreUid = 0x10000041
       
  1312                 if((filePointer[7]==0x00)&&(filePointer[6]==0x00)&&(filePointer[5]==0x00)&&(filePointer[4]==0x01))
       
  1313                     {//KMultiBitMapFileImageUid = 0x00000001
       
  1314                     if((filePointer[11]==0x00)&&(filePointer[10]==0x00)&&(filePointer[9]==0x00)&&(filePointer[8]==0x0C))
       
  1315                         {//Zero = 0x0000000C)
       
  1316                         if((filePointer[15]==0x10)&&(filePointer[14]==0x00)&&(filePointer[13]==0x00)&&(filePointer[12]==0x40))
       
  1317                             {//checksum = 0x10000040
       
  1318                             return ETrue;
       
  1319                             }
       
  1320                         }
       
  1321                     }
       
  1322                 }
       
  1323             }
       
  1324       return EFalse;
       
  1325       }
       
  1326 
       
  1327 // This method can be used to check whether app has a WriteDeviceCap 
   847 // This method can be used to check whether app has a WriteDeviceCap 
  1328 // and its sid is trusted
   848 // and its sid is trusted
  1329 void CApaAppInfoReader::ReadAppSecurityInfo()
   849 void CApaAppInfoReader::ReadAppSecurityInfo()
  1330     {
   850     {
  1331     if (!iSecurityInfoHasBeenRead)
   851     if (!iSecurityInfoHasBeenRead)
  1403 		{
   923 		{
  1404 		TInt ret = iIconIndexArray[iCachedArrayIndex].iIndex++;
   924 		TInt ret = iIconIndexArray[iCachedArrayIndex].iIndex++;
  1405 		return ret;
   925 		return ret;
  1406 		}
   926 		}
  1407 	else
   927 	else
  1408 	    aUseCache = ETrue;	    
   928 		aUseCache = ETrue;
  1409 
   929 
  1410 	// if filename in array, get the next index
   930 	// if filename in array, get the next index
  1411 	TInt ret = 0;
   931 	TInt ret = 0;
  1412 	const TInt arrayCount = iIconIndexArray.Count();
   932 	const TInt arrayCount = iIconIndexArray.Count();
  1413 	TInt arrayIndex;
   933 	TInt arrayIndex;
  1441 // returns EFalse if there was an error obtaining aMbmFileName's entry information,
   961 // returns EFalse if there was an error obtaining aMbmFileName's entry information,
  1442 // otherwise returns ETrue.
   962 // otherwise returns ETrue.
  1443 // Leaves if an error occurs while trying to populate aIcons or sort icons
   963 // Leaves if an error occurs while trying to populate aIcons or sort icons
  1444 TBool CApaIconLoader::LoadIconsL(TInt aNumOfIcons, const TDesC& aMbmFileName, CArrayPtr<CApaMaskedBitmap>& aIcons)
   964 TBool CApaIconLoader::LoadIconsL(TInt aNumOfIcons, const TDesC& aMbmFileName, CArrayPtr<CApaMaskedBitmap>& aIcons)
  1445 	{
   965 	{
  1446   
       
  1447 	TEntry entry;
   966 	TEntry entry;
  1448 	TInt error=iFs.Entry(aMbmFileName,entry);
   967 	TInt error=iFs.Entry(aMbmFileName,entry);
  1449 	if (error!=KErrNone)
   968 	if (error!=KErrNone)
  1450 		return EFalse;
   969 		return EFalse;
  1451 
   970 
  1464 	for(iconIndex=0; iconIndex<aNumOfIcons; ++iconIndex)	
   983 	for(iconIndex=0; iconIndex<aNumOfIcons; ++iconIndex)	
  1465 		{		
   984 		{		
  1466 		CApaMaskedBitmap* bitmap = CApaMaskedBitmap::NewLC();
   985 		CApaMaskedBitmap* bitmap = CApaMaskedBitmap::NewLC();
  1467 		fileIndex = IconIndexL(aMbmFileName, useCache);
   986 		fileIndex = IconIndexL(aMbmFileName, useCache);
  1468 		User::LeaveIfError(bitmap->Load(mbmFile, 2*fileIndex));
   987 		User::LeaveIfError(bitmap->Load(mbmFile, 2*fileIndex));
  1469 		User::LeaveIfError((bitmap->Mask())->Load(mbmFile,2*fileIndex+1));   
   988 		User::LeaveIfError((bitmap->Mask())->Load(mbmFile,2*fileIndex+1));		
  1470 		
       
  1471 		aIcons.AppendL(bitmap);
   989 		aIcons.AppendL(bitmap);
  1472 		CleanupStack::Pop(bitmap);		
   990 		CleanupStack::Pop(bitmap);		
  1473 		}
   991 		}
  1474 	
   992 	
  1475 	CleanupStack::PopAndDestroy(&mbmFile); // close mbmFile	
   993 	CleanupStack::PopAndDestroy(&mbmFile); // close mbmFile