|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include <jdebug.h> |
|
18 #include <JniEnvWrapper.h> |
|
19 |
|
20 #include "com_nokia_microedition_media_protocol_EMCSourceInfo.h" |
|
21 #include "cmmamanager.h" |
|
22 |
|
23 LOCAL_C void SetHeaderDataL( |
|
24 CMMAManager* aManager, |
|
25 const TUint8* aHeader, |
|
26 TInt aLength) |
|
27 { |
|
28 aManager->SetSourceInfoL(aHeader, aLength); |
|
29 } |
|
30 |
|
31 /* |
|
32 * Class: com_nokia_microedition_media_protocol_http_EMCSourceInfo |
|
33 * Method: _writeHeaderData |
|
34 * Signature: (II[B)V |
|
35 */ |
|
36 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_protocol_EMCSourceInfo__1writeHeaderData |
|
37 (JNIEnv* aJni, jobject, jint aEventSourceHandle, jint aManagerHandle, jbyteArray aHeader) |
|
38 { |
|
39 // Development time check. |
|
40 __ASSERT_DEBUG((aEventSourceHandle > 0) && (aManagerHandle > 0), User::Invariant()); |
|
41 |
|
42 CMMAEventSource* eventSource = |
|
43 JavaUnhand< CMMAEventSource >(aEventSourceHandle); |
|
44 CMMAManager* manager = JavaUnhand< CMMAManager >(aManagerHandle); |
|
45 |
|
46 if (aHeader) |
|
47 { |
|
48 // Get pointer to Java header data |
|
49 jbyte* data = aJni->GetByteArrayElements(aHeader, NULL); |
|
50 |
|
51 // if data is null Java data could not be obtained to native and |
|
52 // KErrNoMemory is returned to Java |
|
53 if (!data) |
|
54 { |
|
55 return KErrNoMemory; |
|
56 } |
|
57 |
|
58 TInt headerDataLength = aJni->GetArrayLength(aHeader); |
|
59 |
|
60 TInt err = eventSource->ExecuteTrap(&SetHeaderDataL, |
|
61 manager, |
|
62 (const TUint8*)data, |
|
63 headerDataLength); |
|
64 |
|
65 // release bytes got with GetByteArrayElements |
|
66 aJni->ReleaseByteArrayElements(aHeader, |
|
67 data, |
|
68 0); |
|
69 |
|
70 return err; |
|
71 } |
|
72 else |
|
73 { |
|
74 // if aHeader is NULL, this method should not have been called |
|
75 // from java |
|
76 return KErrBadHandle; |
|
77 } |
|
78 } |