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