installationservices/swi/source/apprscparser/apprscparser.cpp
changeset 60 245df5276b97
parent 42 d17dc5398051
child 75 2d2d25361590
equal deleted inserted replaced
53:ae54820ef82c 60:245df5276b97
   103 
   103 
   104 EXPORT_C CAppRegInfoReader::~CAppRegInfoReader()
   104 EXPORT_C CAppRegInfoReader::~CAppRegInfoReader()
   105 	{
   105 	{
   106 	delete iAppBinaryFullName;		
   106 	delete iAppBinaryFullName;		
   107 	iLocalizableRscArray.ResetAndDestroy();
   107 	iLocalizableRscArray.ResetAndDestroy();
       
   108 	iDeviceSupportedLanguages.Close();
   108 	
   109 	
   109 	if (iUseRegFileHandle)
   110 	if (iUseRegFileHandle)
   110 	    delete iRegistrationFileName; // We had created the filename from the handle
   111 	    delete iRegistrationFileName; // We had created the filename from the handle
   111 	}
   112 	}
   112 
   113 
   154 	// Set the TUidType for the app binary
   155 	// Set the TUidType for the app binary
   155 	iAppBinaryUidType = TUidType(firstUid, middleUid, iAppUid);
   156 	iAppBinaryUidType = TUidType(firstUid, middleUid, iAppUid);
   156 	// Check to see if we are only interested in any localized info
   157 	// Check to see if we are only interested in any localized info
   157 	iReadOnlyOneLocalizedRscInfo = aAppLanguages.Count()?EFalse:ETrue;
   158 	iReadOnlyOneLocalizedRscInfo = aAppLanguages.Count()?EFalse:ETrue;
   158 	
   159 	
       
   160 	// We need to parse for all device supported languages. Populate iDeviceSupportedLanguages.
       
   161 	if (aAppLanguages.Count()>0)
       
   162 	    {             
       
   163         GetInstalledLanguagesL();
       
   164 	    }
       
   165 
   159 	DEBUG_PRINTF2(_L("Opening rsc file %S"), iRegistrationFileName); //TODO
   166 	DEBUG_PRINTF2(_L("Opening rsc file %S"), iRegistrationFileName); //TODO
   160 	CResourceFile* registrationFile = NULL;
   167 	CResourceFile* registrationFile = NULL;
   161 	if (iUseRegFileHandle)
   168 	if (iUseRegFileHandle)
   162 	    {
   169 	    {
   163 	    fileLength = 0;        
   170 	    fileLength = 0;        
   190 		CleanupStack::PopAndDestroy(2, registrationFile); // resourceReader
   197 		CleanupStack::PopAndDestroy(2, registrationFile); // resourceReader
   191 		User::Leave(err); // Might have read something, but failed to setup enough info to make it worthwhile trying to read any more
   198 		User::Leave(err); // Might have read something, but failed to setup enough info to make it worthwhile trying to read any more
   192 		}
   199 		}
   193 	
   200 	
   194 	TUint localizableResourceId = 1; // Only initialising this here to keep the compiler happy
   201 	TUint localizableResourceId = 1; // Only initialising this here to keep the compiler happy
   195 	TRAP(err, ReadNonLocalizableInfoL(resourceReader, localizableResourceId, aAppLanguages));
   202 	TRAP(err, ReadNonLocalizableInfoL(resourceReader, localizableResourceId, iDeviceSupportedLanguages));
   196 
   203 
   197 	if (!err)
   204 	if (!err)
   198 	    {
   205 	    {
   199         // Open the localizable resource file for identified languages
   206         // Open the localizable resource file for identified languages
   200         for (TInt i=0; i < iLocalizableRscArray.Count(); ++i)
   207         for (TInt i=0; i < iLocalizableRscArray.Count(); ++i)
   232 	    {	    
   239 	    {	    
   233 	    RPointerArray<Usif::CPropertyEntry> appPropertiesArray;	    	    
   240 	    RPointerArray<Usif::CPropertyEntry> appPropertiesArray;	    	    
   234 		appRegInfo = Usif::CApplicationRegistrationData::NewL(iOwnedFileArray, iServiceArray, iLocalizableAppInfoArray, 
   241 		appRegInfo = Usif::CApplicationRegistrationData::NewL(iOwnedFileArray, iServiceArray, iLocalizableAppInfoArray, 
   235                                         appPropertiesArray, iOpaqueDataArray, iAppUid, *iAppBinaryFullName, iAppCharacteristics, iDefaultScreenNumber);
   242                                         appPropertiesArray, iOpaqueDataArray, iAppUid, *iAppBinaryFullName, iAppCharacteristics, iDefaultScreenNumber);
   236 		
   243 		
   237 		DEBUG_PRINTF2(_L("Count Languages : %d"), aAppLanguages.Count());
   244 		DEBUG_PRINTF2(_L("Count Languages (from client) : %d"), aAppLanguages.Count());
       
   245 		DEBUG_PRINTF2(_L("Count Languages (after reset) : %d"), iDeviceSupportedLanguages.Count());
   238 		DEBUG_PRINTF2(_L("Count of Loc files parsed : %d"), iLocalizableRscArray.Count());
   246 		DEBUG_PRINTF2(_L("Count of Loc files parsed : %d"), iLocalizableRscArray.Count());
   239 		DEBUG_PRINTF2(_L("Count of Loc data passed to SWI : %d"), iLocalizableAppInfoArray.Count());				
   247 		DEBUG_PRINTF2(_L("Count of Loc data passed to SWI : %d"), iLocalizableAppInfoArray.Count());				
   240 	   }
   248 	   }
   241 	else
   249 	else
   242 	    {
   250 	    {
   833 void CAppRegInfoReader::Panic(TInt aPanic)
   841 void CAppRegInfoReader::Panic(TInt aPanic)
   834     {
   842     {
   835     _LIT(KSWIAppRegInfoReaderPanic,"SWIAppRegInfoReaderPanic");
   843     _LIT(KSWIAppRegInfoReaderPanic,"SWIAppRegInfoReaderPanic");
   836     User::Panic(KSWIAppRegInfoReaderPanic, aPanic);
   844     User::Panic(KSWIAppRegInfoReaderPanic, aPanic);
   837     }
   845     }
       
   846 
       
   847 void CAppRegInfoReader::GetInstalledLanguagesL()
       
   848     {
       
   849     _LIT(KLanguagesIni, "z:\\resource\\bootdata\\languages.txt");
       
   850     const TInt KReadBufSize = 10;
       
   851     
       
   852     iDeviceSupportedLanguages.Reset();
       
   853     
       
   854     RFile file;
       
   855     TInt err = file.Open(iFs, KLanguagesIni, EFileRead|EFileShareReadersOnly);
       
   856     if (KErrNone == err)
       
   857         {
       
   858         CleanupClosePushL(file);
       
   859         
       
   860         TFileText reader;
       
   861         reader.Set(file);
       
   862         err = reader.Seek(ESeekStart);
       
   863         if (KErrNone == err)
       
   864             {
       
   865             TBuf<KReadBufSize> readBuf;
       
   866             while(KErrNone == reader.Read(readBuf))
       
   867                 {
       
   868                 if (readBuf.Length() > 0)
       
   869                     {
       
   870                     TLex lex(readBuf);
       
   871                     lex.SkipSpace();
       
   872                     TInt language;
       
   873                     err = lex.Val(language);
       
   874                     if (KErrNone != err)
       
   875                         {
       
   876                         readBuf.Zero();
       
   877                         continue; // Read the next line
       
   878                         }
       
   879                     iDeviceSupportedLanguages.AppendL((TLanguage)language);
       
   880                     }
       
   881                 readBuf.Zero();
       
   882                 }
       
   883             }
       
   884         else
       
   885             {
       
   886             DEBUG_PRINTF3(_L("Reading %S failed with %d"), &KLanguagesIni, err);
       
   887             }
       
   888         
       
   889         CleanupStack::PopAndDestroy(&file);
       
   890         }
       
   891     else
       
   892         {
       
   893         DEBUG_PRINTF3(_L("Opening %S failed with %d"), &KLanguagesIni, err);
       
   894         }
       
   895     
       
   896     // If we are not able fetch the device languages, just parse for the current device language
       
   897     if (0 == iDeviceSupportedLanguages.Count())
       
   898         {
       
   899         iDeviceSupportedLanguages.AppendL(User::Language());
       
   900         }
       
   901     }