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 <logger.h> |
|
18 |
|
19 #include <JniEnvWrapper.h> |
|
20 |
|
21 #include "com_nokia_microedition_media_protocol_EMCSourceInfo.h" |
|
22 #include "cmmamanager.h" |
|
23 |
|
24 LOCAL_C void SetHeaderDataL( |
|
25 CMMAManager* aManager, |
|
26 const TUint8* aHeader, |
|
27 TInt aLength) |
|
28 { |
|
29 aManager->SetSourceInfoL(aHeader, aLength); |
|
30 } |
|
31 |
|
32 /* |
|
33 * Class: com_nokia_microedition_media_protocol_http_EMCSourceInfo |
|
34 * Method: _writeHeaderData |
|
35 * Signature: (II[B)V |
|
36 */ |
|
37 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_protocol_EMCSourceInfo__1writeHeaderData |
|
38 (JNIEnv* aJni, jobject, jint aEventSourceHandle, jint aManagerHandle, jbyteArray aHeader) |
|
39 { |
|
40 // Development time check. |
|
41 __ASSERT_DEBUG((aEventSourceHandle > 0) && (aManagerHandle > 0), User::Invariant()); |
|
42 |
|
43 MMAFunctionServer* eventSource = |
|
44 reinterpret_cast< MMAFunctionServer* >(aEventSourceHandle); |
|
45 CMMAManager* manager = reinterpret_cast< CMMAManager* >(aManagerHandle); |
|
46 |
|
47 if (aHeader) |
|
48 { |
|
49 // Get pointer to Java header data |
|
50 jbyte* data = aJni->GetByteArrayElements(aHeader, NULL); |
|
51 |
|
52 // if data is null Java data could not be obtained to native and |
|
53 // KErrNoMemory is returned to Java |
|
54 if (!data) |
|
55 { |
|
56 return KErrNoMemory; |
|
57 } |
|
58 |
|
59 TInt headerDataLength = aJni->GetArrayLength(aHeader); |
|
60 |
|
61 TInt err = eventSource->ExecuteTrap(&SetHeaderDataL, |
|
62 manager, |
|
63 (const TUint8*)data, |
|
64 headerDataLength); |
|
65 |
|
66 // release bytes got with GetByteArrayElements |
|
67 aJni->ReleaseByteArrayElements(aHeader, |
|
68 data, |
|
69 0); |
|
70 |
|
71 return err; |
|
72 } |
|
73 else |
|
74 { |
|
75 // if aHeader is NULL, this method should not have been called |
|
76 // from java |
|
77 return KErrBadHandle; |
|
78 } |
|
79 } |
|