diff -r 0fd27995241b -r 9ac0a0a7da70 javauis/mmapi_qt/utils/src/mmapiutils.cpp --- a/javauis/mmapi_qt/utils/src/mmapiutils.cpp Tue May 11 16:07:20 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -#include "mmapiutils.h" -#include "s60commonutils.h" -using namespace java::util; - -enum TJavaArrayPanic -{ - EBadOffsetIntoJavaArray, - EWritingOverEndOfJavaArray, - EBadOffsetIntoJavaArrayForRead, - EReadingOverEndOfJavaArray, -}; - - -/** - * Copies data from the native to the Java array. - * @return The number of bytes copied. - */ -TInt MMAPIUtils::CopyToJava(JNIEnv& aJni, const TDesC8& aNativeBuffer, - jbyteArray aJavaBuffer, TInt aOffset, TInt aLength) -{ - __ASSERT_DEBUG(aOffset <= aJni.GetArrayLength(aJavaBuffer), - User::Panic(_L("ArrayUtils"), EBadOffsetIntoJavaArray)); - __ASSERT_DEBUG(aLength <= aJni.GetArrayLength(aJavaBuffer) - aOffset, - User::Panic(_L("ArrayUtils"), EWritingOverEndOfJavaArray)); - - TInt nativeBufferLength = aNativeBuffer.Length(); - TInt length = (nativeBufferLength < aLength) ? nativeBufferLength : aLength; - TUint8* nativeBufferPtr = const_cast(aNativeBuffer.Ptr()); - jbyte* jNativeBufferPtr = reinterpret_cast(nativeBufferPtr); - aJni.SetByteArrayRegion(aJavaBuffer, aOffset, length, jNativeBufferPtr); - return length; -} - -jobjectArray MMAPIUtils::CopyToNewJavaStringArrayL(JNIEnv& aJni, const CDesCArray& aNativeArray) -{ - jclass stringClass = aJni.FindClass("java/lang/String"); - User::LeaveIfNull(stringClass); - // - jobjectArray result = aJni.NewObjectArray(aNativeArray.Count(), stringClass, NULL); - if (result != NULL) - { - TPtrC item; - for (int i=0; i