equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 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". |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: MMAPIUtils |
15 * |
15 * |
16 */ |
16 */ |
|
17 |
17 #include "mmapiutils.h" |
18 #include "mmapiutils.h" |
18 #include "s60commonutils.h" |
19 #include "s60commonutils.h" |
19 using namespace java::util; |
20 using namespace java::util; |
20 |
21 |
21 enum TJavaArrayPanic |
22 enum TJavaArrayPanic |
22 { |
23 { |
23 EBadOffsetIntoJavaArray, |
24 EBadOffsetIntoJavaArray, |
24 EWritingOverEndOfJavaArray, |
25 EWritingOverEndOfJavaArray, |
25 EBadOffsetIntoJavaArrayForRead, |
26 EBadOffsetIntoJavaArrayForRead, |
30 /** |
31 /** |
31 * Copies data from the native to the Java array. |
32 * Copies data from the native to the Java array. |
32 * @return The number of bytes copied. |
33 * @return The number of bytes copied. |
33 */ |
34 */ |
34 TInt MMAPIUtils::CopyToJava(JNIEnv& aJni, const TDesC8& aNativeBuffer, |
35 TInt MMAPIUtils::CopyToJava(JNIEnv& aJni, const TDesC8& aNativeBuffer, |
35 jbyteArray aJavaBuffer, TInt aOffset, TInt aLength) |
36 jbyteArray aJavaBuffer, TInt aOffset, TInt aLength) |
36 { |
37 { |
37 __ASSERT_DEBUG(aOffset <= aJni.GetArrayLength(aJavaBuffer), |
38 __ASSERT_DEBUG(aOffset <= aJni.GetArrayLength(aJavaBuffer), |
38 User::Panic(_L("ArrayUtils"), EBadOffsetIntoJavaArray)); |
39 User::Panic(_L("ArrayUtils"), EBadOffsetIntoJavaArray)); |
39 __ASSERT_DEBUG(aLength <= aJni.GetArrayLength(aJavaBuffer) - aOffset, |
40 __ASSERT_DEBUG(aLength <= aJni.GetArrayLength(aJavaBuffer) - aOffset, |
40 User::Panic(_L("ArrayUtils"), EWritingOverEndOfJavaArray)); |
41 User::Panic(_L("ArrayUtils"), EWritingOverEndOfJavaArray)); |