equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
17 |
17 |
18 |
18 |
19 #include <memory> |
19 #include <memory> |
20 #include <stringresourcereader.h> |
20 #include <stringresourcereader.h> |
21 |
21 |
22 #ifdef RD_JAVA_UI_QT |
22 #ifndef RD_JAVA_UI_QT |
23 #include <QLocale> |
|
24 #else // RD_JAVA_UI_QT |
|
25 #include <AknUtils.h> |
23 #include <AknUtils.h> |
26 #endif // RD_JAVA_UI_QT |
24 #endif // RD_JAVA_UI_QT |
27 |
25 |
28 #include "com_nokia_mj_impl_utils_Formatter.h" |
26 #include "com_nokia_mj_impl_utils_FormatterAvkon.h" |
29 #include "com_nokia_mj_impl_utils_ResourceLoader.h" |
27 #include "com_nokia_mj_impl_utils_ResourceLoader.h" |
30 #include "javajniutils.h" |
28 #include "javajniutils.h" |
31 #include "s60commonutils.h" |
29 #include "s60commonutils.h" |
32 #include "logger.h" |
30 #include "logger.h" |
33 |
31 |
48 const TInt KMaxDateFormatSize = 30; |
46 const TInt KMaxDateFormatSize = 30; |
49 const TInt KMaxNumberFormatSize = 40; |
47 const TInt KMaxNumberFormatSize = 40; |
50 using namespace java::util; |
48 using namespace java::util; |
51 |
49 |
52 |
50 |
53 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatInteger |
51 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_FormatterAvkon__1formatInteger |
54 (JNIEnv *aJni, jobject, jint aNumber) |
52 (JNIEnv *aJni, jclass, jint aNumber) |
55 { |
53 { |
56 JELOG2(EUtils); |
54 JELOG2(EUtils); |
57 TReal64 realNumber = aNumber; |
55 TReal64 realNumber = aNumber; |
58 std::auto_ptr<HBufC> numberString(HBufC::New(KMaxNumberFormatSize)); |
56 std::auto_ptr<HBufC> numberString(HBufC::New(KMaxNumberFormatSize)); |
59 if (numberString.get() == 0) |
57 if (numberString.get() == 0) |
77 |
75 |
78 return aJni->NewString( |
76 return aJni->NewString( |
79 (const jchar*)numberPtr.Ptr(), numberPtr.Length()); |
77 (const jchar*)numberPtr.Ptr(), numberPtr.Length()); |
80 } |
78 } |
81 |
79 |
82 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatDate |
80 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_FormatterAvkon__1formatDate |
83 (JNIEnv * aJni, jobject, jlong timeInMillis) |
81 (JNIEnv * aJni, jclass, jlong timeInMillis) |
84 { |
82 { |
85 std::auto_ptr<HBufC> dateString(HBufC::New(KMaxDateFormatSize)); |
83 std::auto_ptr<HBufC> dateString(HBufC::New(KMaxDateFormatSize)); |
86 if (dateString.get() == 0) |
84 if (dateString.get() == 0) |
87 { |
85 { |
88 return 0; |
86 return 0; |
106 |
104 |
107 return aJni->NewString( |
105 return aJni->NewString( |
108 (const jchar*)datePtr.Ptr(), datePtr.Length()); |
106 (const jchar*)datePtr.Ptr(), datePtr.Length()); |
109 } |
107 } |
110 |
108 |
111 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_utils_ResourceLoader__1getLocaleId |
109 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_FormatterAvkon__1formatDigits |
112 (JNIEnv *, jobject) |
110 (JNIEnv * aEnv, jclass, jstring str) |
113 |
|
114 { |
|
115 return (jint)User::Language(); |
|
116 } |
|
117 |
|
118 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatDigits |
|
119 (JNIEnv * aEnv, jclass, jstring str) |
|
120 { |
111 { |
121 jstring ret = str; |
112 jstring ret = str; |
122 std::wstring wstr = JniUtils::jstringToWstring(aEnv, str); |
113 std::wstring wstr = JniUtils::jstringToWstring(aEnv, str); |
123 HBufC* buf = S60CommonUtils::wstringToDes(wstr.c_str()); |
114 HBufC* buf = S60CommonUtils::wstringToDes(wstr.c_str()); |
124 TPtr ptr(buf->Des()); |
115 TPtr ptr(buf->Des()); |
129 ret = S60CommonUtils::NativeToJavaString(*aEnv, ptr); |
120 ret = S60CommonUtils::NativeToJavaString(*aEnv, ptr); |
130 delete buf; buf = NULL; |
121 delete buf; buf = NULL; |
131 return ret; |
122 return ret; |
132 } |
123 } |
133 |
124 |
134 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_ResourceLoader__1getLocaleIdQt |
125 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_utils_ResourceLoader__1getLocaleId |
135 (JNIEnv *env, jclass) |
126 (JNIEnv *, jclass) |
136 { |
127 { |
137 #ifdef RD_JAVA_UI_QT |
128 return (jint)User::Language(); |
138 QString localeName = QLocale::system().name(); |
|
139 jstring loc = env->NewString(localeName.utf16(), localeName.size()); |
|
140 return loc; |
|
141 #else // RD_JAVA_UI_QT |
|
142 (void)env; // just to suppress a warning |
|
143 return NULL; |
|
144 #endif // RD_JAVA_UI_QT |
|
145 } |
129 } |