javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/utils/SysUtil.java
branchRCL_3
changeset 60 6c158198356e
parent 24 0fd27995241b
child 83 26b2b12093af
--- a/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/utils/SysUtil.java	Thu Jul 15 18:31:06 2010 +0300
+++ b/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/utils/SysUtil.java	Thu Aug 19 09:48:13 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -359,11 +359,12 @@
                                              " drives failed with code " + ret);
         }
         // Save the drives so that next time they are not fetched again.
-        iUserVisibleDrives = new Vector();
+        Vector drivesVector = new Vector();
         for (int i = 0; i < aVisibleDrives.size(); i++)
         {
-            iUserVisibleDrives.addElement(aVisibleDrives.elementAt(i));
+            drivesVector.addElement(aVisibleDrives.elementAt(i));
         }
+        iUserVisibleDrives = drivesVector;
     }
 
     /**
@@ -441,6 +442,44 @@
         return ret;
     }
 
+    /**
+     * Maps given ISO language/country code to Symbian TLanguage.
+     *
+     * @param aLocale ISO language/country code
+     * @return Symbian TLanguage value, or -1 if no matching language is found.
+     */
+    public static int isoToLang(String aLocale)
+    {
+        // Replace possible dash with underscore.
+        aLocale = aLocale.replace('-', '_');
+        // Get language and country parts.
+        String lang = aLocale.toLowerCase();
+        String country = null;
+        int sepIndex = aLocale.indexOf("_");
+        if (sepIndex >= 0)
+        {
+            lang = aLocale.substring(0, sepIndex).toLowerCase();
+            country = aLocale.substring(sepIndex + 1).toUpperCase();
+        }
+        // Map locale to Symbian TLanguage using native service.
+        int result = -1;
+        if (country == null)
+        {
+            result = _isoToLang(lang);
+        }
+        else
+        {
+            result = _isoToLang(lang + "_" + country);
+            if (result == -1)
+            {
+                // No result for language and country, try using language only.
+                result = _isoToLang(lang);
+            }
+        }
+        //Log.log("SysUtil.isoToLang: " + aLocale + " ==> " + result);
+        return result;
+    }
+
     /*** ---------------------------- PROTECTED --------------------------- */
     /*** ----------------------------- PACKAGE ---------------------------- */
     /*** ----------------------------- PRIVATE ---------------------------- */
@@ -648,6 +687,14 @@
     private static native int _getScreenHeight();
 
     /**
+     * Maps given ISO language/country code to Symbian TLanguage.
+     *
+     * @param aLocale ISO language/country code
+     * @return Symbian TLanguage value, or -1 if no matching language is found.
+     */
+    private static native int _isoToLang(String aLocale);
+
+    /**
      * Class for holding return value from native side.
      */
     private static class IntValue