javacommons/utils/src.s60/formatternative.cpp
changeset 49 35baca0e7a2e
parent 21 2a9601315dfc
child 80 d6dafc5d983f
--- a/javacommons/utils/src.s60/formatternative.cpp	Fri Jun 11 13:33:44 2010 +0300
+++ b/javacommons/utils/src.s60/formatternative.cpp	Tue Jul 06 20:36:19 2010 +0300
@@ -16,13 +16,19 @@
 */
 
 
-//#include <avkon.rsg>
 #include <memory>
 #include <stringresourcereader.h>
 
+#ifdef RD_JAVA_UI_QT
+#include <QLocale>
+#else // RD_JAVA_UI_QT
+#include <AknUtils.h>
+#endif // RD_JAVA_UI_QT
+
 #include "com_nokia_mj_impl_utils_Formatter.h"
 #include "com_nokia_mj_impl_utils_ResourceLoader.h"
 #include "javajniutils.h"
+#include "s60commonutils.h"
 #include "logger.h"
 
 enum EDateTimeFormat
@@ -41,8 +47,8 @@
 // const TInt KMaxDateTimeStringSize = 50;
 const TInt KMaxDateFormatSize = 30;
 const TInt KMaxNumberFormatSize = 40;
+using namespace java::util;
 
-// _LIT( KAvkonResFile, "z:\\resource\\avkon.rsc" );
 
 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatInteger
 (JNIEnv *aJni, jobject, jint aNumber)
@@ -65,6 +71,10 @@
               "Cannot format %d to current locale. Error: %d", aNumber, error);
     }
 
+#ifndef RD_JAVA_UI_QT
+        AknTextUtils::LanguageSpecificNumberConversion( numberPtr );
+#endif // RD_JAVA_UI_QT
+
     return aJni->NewString(
                (const jchar*)numberPtr.Ptr(), numberPtr.Length());
 }
@@ -105,3 +115,31 @@
     return (jint)User::Language();
 }
 
+JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatDigits
+  (JNIEnv * aEnv, jclass, jstring str)
+{
+    jstring ret = str;
+    std::wstring wstr = JniUtils::jstringToWstring(aEnv, str);
+    HBufC* buf = S60CommonUtils::wstringToDes(wstr.c_str());
+    TPtr ptr(buf->Des());
+
+#ifndef RD_JAVA_UI_QT
+    AknTextUtils::LanguageSpecificNumberConversion( ptr );
+#endif // RD_JAVA_UI_QT
+    ret = S60CommonUtils::NativeToJavaString(*aEnv, ptr);
+    delete buf; buf = NULL;
+    return ret;
+}
+
+JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_ResourceLoader__1getLocaleIdQt
+  (JNIEnv *env, jclass)
+{
+#ifdef RD_JAVA_UI_QT
+    QString localeName = QLocale::system().name();
+    jstring loc = env->NewString(localeName.utf16(), localeName.size());
+    return loc;
+#else // RD_JAVA_UI_QT
+    (void)env;     // just to suppress a warning
+    return NULL;
+#endif // RD_JAVA_UI_QT
+}