installationservices/swi/source/apprscparser/apprscparser.cpp
changeset 60 245df5276b97
parent 42 d17dc5398051
child 75 2d2d25361590
--- a/installationservices/swi/source/apprscparser/apprscparser.cpp	Tue Jul 06 14:23:31 2010 +0300
+++ b/installationservices/swi/source/apprscparser/apprscparser.cpp	Wed Aug 18 09:55:45 2010 +0300
@@ -105,6 +105,7 @@
 	{
 	delete iAppBinaryFullName;		
 	iLocalizableRscArray.ResetAndDestroy();
+	iDeviceSupportedLanguages.Close();
 	
 	if (iUseRegFileHandle)
 	    delete iRegistrationFileName; // We had created the filename from the handle
@@ -156,6 +157,12 @@
 	// Check to see if we are only interested in any localized info
 	iReadOnlyOneLocalizedRscInfo = aAppLanguages.Count()?EFalse:ETrue;
 	
+	// We need to parse for all device supported languages. Populate iDeviceSupportedLanguages.
+	if (aAppLanguages.Count()>0)
+	    {             
+        GetInstalledLanguagesL();
+	    }
+
 	DEBUG_PRINTF2(_L("Opening rsc file %S"), iRegistrationFileName); //TODO
 	CResourceFile* registrationFile = NULL;
 	if (iUseRegFileHandle)
@@ -192,7 +199,7 @@
 		}
 	
 	TUint localizableResourceId = 1; // Only initialising this here to keep the compiler happy
-	TRAP(err, ReadNonLocalizableInfoL(resourceReader, localizableResourceId, aAppLanguages));
+	TRAP(err, ReadNonLocalizableInfoL(resourceReader, localizableResourceId, iDeviceSupportedLanguages));
 
 	if (!err)
 	    {
@@ -234,7 +241,8 @@
 		appRegInfo = Usif::CApplicationRegistrationData::NewL(iOwnedFileArray, iServiceArray, iLocalizableAppInfoArray, 
                                         appPropertiesArray, iOpaqueDataArray, iAppUid, *iAppBinaryFullName, iAppCharacteristics, iDefaultScreenNumber);
 		
-		DEBUG_PRINTF2(_L("Count Languages : %d"), aAppLanguages.Count());
+		DEBUG_PRINTF2(_L("Count Languages (from client) : %d"), aAppLanguages.Count());
+		DEBUG_PRINTF2(_L("Count Languages (after reset) : %d"), iDeviceSupportedLanguages.Count());
 		DEBUG_PRINTF2(_L("Count of Loc files parsed : %d"), iLocalizableRscArray.Count());
 		DEBUG_PRINTF2(_L("Count of Loc data passed to SWI : %d"), iLocalizableAppInfoArray.Count());				
 	   }
@@ -835,3 +843,59 @@
     _LIT(KSWIAppRegInfoReaderPanic,"SWIAppRegInfoReaderPanic");
     User::Panic(KSWIAppRegInfoReaderPanic, aPanic);
     }
+
+void CAppRegInfoReader::GetInstalledLanguagesL()
+    {
+    _LIT(KLanguagesIni, "z:\\resource\\bootdata\\languages.txt");
+    const TInt KReadBufSize = 10;
+    
+    iDeviceSupportedLanguages.Reset();
+    
+    RFile file;
+    TInt err = file.Open(iFs, KLanguagesIni, EFileRead|EFileShareReadersOnly);
+    if (KErrNone == err)
+        {
+        CleanupClosePushL(file);
+        
+        TFileText reader;
+        reader.Set(file);
+        err = reader.Seek(ESeekStart);
+        if (KErrNone == err)
+            {
+            TBuf<KReadBufSize> readBuf;
+            while(KErrNone == reader.Read(readBuf))
+                {
+                if (readBuf.Length() > 0)
+                    {
+                    TLex lex(readBuf);
+                    lex.SkipSpace();
+                    TInt language;
+                    err = lex.Val(language);
+                    if (KErrNone != err)
+                        {
+                        readBuf.Zero();
+                        continue; // Read the next line
+                        }
+                    iDeviceSupportedLanguages.AppendL((TLanguage)language);
+                    }
+                readBuf.Zero();
+                }
+            }
+        else
+            {
+            DEBUG_PRINTF3(_L("Reading %S failed with %d"), &KLanguagesIni, err);
+            }
+        
+        CleanupStack::PopAndDestroy(&file);
+        }
+    else
+        {
+        DEBUG_PRINTF3(_L("Opening %S failed with %d"), &KLanguagesIni, err);
+        }
+    
+    // If we are not able fetch the device languages, just parse for the current device language
+    if (0 == iDeviceSupportedLanguages.Count())
+        {
+        iDeviceSupportedLanguages.AppendL(User::Language());
+        }
+    }