|
1 /* |
|
2 * Copyright (c) 2002 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: This class has JNI wrappers for CMMATempoControl |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <jutils.h> |
|
19 |
|
20 #include "com_nokia_microedition_media_control_TempoControl.h" |
|
21 #include "cmmaeventsource.h" |
|
22 #include "cmmamiditempocontrol.h" |
|
23 #include <jdebug.h> |
|
24 |
|
25 // |
|
26 // Wrapper functions which are needed in event source execution. |
|
27 // If method to be called can leave ExecuteTrap must be used, |
|
28 // otherwise Execute and ExecuteV can be used. |
|
29 // |
|
30 // |
|
31 |
|
32 /** |
|
33 * Local function which can be used to call CMMATempoControl class methods. |
|
34 * Type of of the function pointer must be |
|
35 * TInt CMMATempoControl::aFunc( TInt aData ) |
|
36 * |
|
37 * @param aTempoControl CMMATempoControl pointer. |
|
38 * @param aFunc Pointer to the CMMATempoControl method. |
|
39 * @param aData Parameter to passed to the aFunc method |
|
40 * @param aReturnValue The return value of the aFunc will |
|
41 * be assigned to this parameter. |
|
42 */ |
|
43 LOCAL_C void ReturnIntParamIntFuncL(CMMAMIDITempoControl* aTempoControl, |
|
44 TInt(CMMAMIDITempoControl::*aFuncL)(TInt), |
|
45 TInt aData, |
|
46 TInt* aReturnValue) |
|
47 { |
|
48 // call TInt CMMATempoControl::aFunc( TInt aData ) method. |
|
49 *aReturnValue = (aTempoControl->*aFuncL)(aData); |
|
50 } |
|
51 |
|
52 /** |
|
53 * Local function which can be used to call CMMATempoControl class methods. |
|
54 * Type of of the function pointer must be |
|
55 * TInt CMMATempoControl::aFunc() |
|
56 * |
|
57 * @param aTempoControl CMMATempoControl pointer. |
|
58 * @param aFunc Pointer to the CMMATempoControl method. |
|
59 * @param aReturnValue The return value of the aFunc will |
|
60 * be assigned to this parameter. |
|
61 */ |
|
62 LOCAL_C void ReturnIntFuncL(CMMAMIDITempoControl* aTempoControl, |
|
63 TInt(CMMAMIDITempoControl::*aFuncL)(), |
|
64 TInt* aReturnValue) |
|
65 { |
|
66 // call TInt CMMATempoControl::aFunc() method. |
|
67 *aReturnValue = (aTempoControl->*aFuncL)(); |
|
68 } |
|
69 |
|
70 // |
|
71 // JNI functions. Prototypes are generated and commented in Java class |
|
72 // com_nokia_microedition_media_control_TempoControl |
|
73 // |
|
74 |
|
75 /** |
|
76 * JNI function from com.nokia.microedition.media.control.TempoControl |
|
77 */ |
|
78 JNIEXPORT jint JNICALL |
|
79 Java_com_nokia_microedition_media_control_TempoControl__1setTempo |
|
80 (JNIEnv*, |
|
81 jobject, |
|
82 jint aControlHandle, |
|
83 jint aEventSourceHandle, |
|
84 jint aTempo) // parameter boundary is checked in Java side. |
|
85 { |
|
86 // Get pointer to native event source. |
|
87 CMMAEventSource* eventSource = |
|
88 JavaUnhand< CMMAEventSource >(aEventSourceHandle); |
|
89 |
|
90 CMMAMIDITempoControl* tempoControl = |
|
91 JavaUnhand< CMMAMIDITempoControl >(aControlHandle); |
|
92 |
|
93 // Value returned from SetTempo method will be assigned to returnValue. |
|
94 TInt returnValue = 0; |
|
95 |
|
96 // Setting tempo will not leave, it just assigns default |
|
97 // value to the returnValue variable. |
|
98 TInt error; |
|
99 error = eventSource->ExecuteTrap(&ReturnIntParamIntFuncL, |
|
100 tempoControl, |
|
101 &CMMAMIDITempoControl::SetTempoL, |
|
102 aTempo, |
|
103 &returnValue); |
|
104 |
|
105 DEBUG_INT("TempoControl__1setTempo return value %d", returnValue); |
|
106 |
|
107 return (error == KErrNone) ? returnValue : error; |
|
108 } |
|
109 |
|
110 /** |
|
111 * JNI function from com.nokia.microedition.media.control.TempoControl |
|
112 */ |
|
113 JNIEXPORT jint JNICALL |
|
114 Java_com_nokia_microedition_media_control_TempoControl__1getTempo |
|
115 (JNIEnv*, |
|
116 jobject, |
|
117 jint aControlHandle, |
|
118 jint aEventSourceHandle) |
|
119 { |
|
120 // Get pointer to native event source. |
|
121 CMMAEventSource* eventSource = |
|
122 JavaUnhand< CMMAEventSource >(aEventSourceHandle); |
|
123 |
|
124 CMMAMIDITempoControl* tempoControl = |
|
125 JavaUnhand< CMMAMIDITempoControl >(aControlHandle); |
|
126 |
|
127 TInt returnValue = 0; |
|
128 TInt error; |
|
129 |
|
130 error = eventSource->ExecuteTrap(&ReturnIntFuncL, |
|
131 tempoControl, |
|
132 &CMMAMIDITempoControl::TempoL, |
|
133 &returnValue); |
|
134 |
|
135 DEBUG_INT("TempoControl__1getTempo return value %d", returnValue); |
|
136 |
|
137 return (error == KErrNone) ? returnValue : error; |
|
138 } |
|
139 // END OF FILE |