|
1 /* |
|
2 * Copyright (c) 2005-2007 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: JNI for EffectControl |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //#include <jutils.h> |
|
20 #include <logger.h> |
|
21 |
|
22 #include "com_nokia_amms_control_EffectControl.h" |
|
23 #include <mmafunctionserver.h> |
|
24 #include "cammseffectcontrolgroup.h" |
|
25 #include "jstringutils.h" |
|
26 #include "s60commonutils.h" |
|
27 using namespace java::util; |
|
28 #include <JniEnvWrapper.h> |
|
29 |
|
30 /** |
|
31 * wrapper for CAMMSEffectControlGroup::PresetNamesL() |
|
32 */ |
|
33 LOCAL_C void GetPresetNamesL(CAMMSEffectControlGroup* aControl, |
|
34 JNIEnv* aJni, |
|
35 jobjectArray* aArray) |
|
36 { |
|
37 // JNI interface pointer can't be passed to different thread, so |
|
38 // it is needed to get valid JNI interface pointer for Event Server thread |
|
39 //aJni = JniEnvWrapper::GetValidJniRef(); |
|
40 |
|
41 // Create new java String array and copy values from the values array |
|
42 *aArray = MMAPIUtils::CopyToNewJavaStringArrayL(*aJni, aControl->PresetNamesL()); |
|
43 } |
|
44 |
|
45 /** |
|
46 * wrapper for CAMMSEffectControlGroup::PresetL() |
|
47 */ |
|
48 static void GetPresetL( |
|
49 CAMMSEffectControlGroup* aControl, |
|
50 TDes* aPreset) |
|
51 { |
|
52 aControl->GetPresetL(*aPreset); |
|
53 } |
|
54 |
|
55 /** |
|
56 * wrapper for CAMMSEffectControlGroup::SetEnabledL() |
|
57 */ |
|
58 static void SetEnabledL(CAMMSEffectControlGroup* aControl, TBool aEnabled) |
|
59 { |
|
60 aControl->SetEnabledL(aEnabled); |
|
61 } |
|
62 |
|
63 /** |
|
64 * wrapper for CAMMSEffectControlGroup::SetScopeL() |
|
65 */ |
|
66 static void SetScopeL(CAMMSEffectControlGroup* aControl, TInt aScope) |
|
67 { |
|
68 aControl->SetScopeL((CAMMSEffectControlGroup::TEffectScope) aScope); |
|
69 } |
|
70 |
|
71 /** |
|
72 * wrapper for CAMMSEffectControlGroup::SetEnforcedL() |
|
73 */ |
|
74 static void SetEnforcedL(CAMMSEffectControlGroup* aControl, TBool aEnforced) |
|
75 { |
|
76 aControl->SetEnforcedL(aEnforced); |
|
77 } |
|
78 |
|
79 /** |
|
80 * wrapper for CAMMSEffectControlGroup::SetPresetL() |
|
81 */ |
|
82 static void SetPresetL(CAMMSEffectControlGroup* aControl, TDesC* aPreset) |
|
83 { |
|
84 aControl->SetPresetL(*aPreset); |
|
85 } |
|
86 |
|
87 /* |
|
88 * Class: com_nokia_amms_control_EffectControl |
|
89 * Method: _isEnabled |
|
90 * Signature: (II)I |
|
91 */ |
|
92 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_EffectControl__1isEnabled( |
|
93 JNIEnv*, jclass, jint, jint aControl) |
|
94 { |
|
95 |
|
96 CAMMSEffectControlGroup* control = static_cast<CAMMSEffectControlGroup*>( |
|
97 reinterpret_cast< CAMMSControlGroup* >(aControl)); |
|
98 |
|
99 return control->Enabled(); |
|
100 } |
|
101 |
|
102 /* |
|
103 * Class: com_nokia_amms_control_EffectControl |
|
104 * Method: _isEnforced |
|
105 * Signature: (II)I |
|
106 */ |
|
107 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_EffectControl__1isEnforced( |
|
108 JNIEnv*, jclass, jint, jint aControl) |
|
109 { |
|
110 |
|
111 CAMMSEffectControlGroup* control = static_cast<CAMMSEffectControlGroup*>( |
|
112 reinterpret_cast< CAMMSControlGroup* >(aControl)); |
|
113 |
|
114 return control->Enforced(); |
|
115 } |
|
116 |
|
117 /* |
|
118 * Class: com_nokia_amms_control_EffectControl |
|
119 * Method: _getPresetNames |
|
120 * Signature: (II[Ljava/lang/String;)I |
|
121 */ |
|
122 JNIEXPORT jobjectArray JNICALL Java_com_nokia_amms_control_EffectControl__1getPresetNames( |
|
123 JNIEnv* aJni, |
|
124 jclass, |
|
125 jint aEventSource, |
|
126 jint aControl) |
|
127 { |
|
128 MMAFunctionServer* eventSource = |
|
129 reinterpret_cast< MMAFunctionServer* >(aEventSource); |
|
130 |
|
131 CAMMSEffectControlGroup* control = static_cast<CAMMSEffectControlGroup*>( |
|
132 reinterpret_cast< CAMMSControlGroup* >(aControl)); |
|
133 |
|
134 jobjectArray presetNames = NULL; |
|
135 |
|
136 TInt error = eventSource->ExecuteTrap(GetPresetNamesL, |
|
137 control, |
|
138 aJni, |
|
139 &presetNames); |
|
140 |
|
141 // If an error happened, return null to Java |
|
142 if (error != KErrNone) |
|
143 { |
|
144 presetNames = NULL; |
|
145 } |
|
146 return presetNames; |
|
147 } |
|
148 |
|
149 /* |
|
150 * Class: com_nokia_amms_control_EffectControl |
|
151 * Method: _getPreset |
|
152 * Signature: (II[Ljava/lang/String;)I |
|
153 */ |
|
154 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_EffectControl__1getPreset( |
|
155 JNIEnv* aJni, |
|
156 jclass, |
|
157 jint aEventSource, |
|
158 jint aControl, |
|
159 jobjectArray aPreset) |
|
160 { |
|
161 MMAFunctionServer* eventSource = |
|
162 reinterpret_cast< MMAFunctionServer *>(aEventSource); |
|
163 |
|
164 CAMMSEffectControlGroup* control = static_cast<CAMMSEffectControlGroup*>( |
|
165 reinterpret_cast< CAMMSControlGroup* >(aControl)); |
|
166 |
|
167 TInt error; |
|
168 TBuf< KAMMSMaxPresetNameLength > preset; |
|
169 |
|
170 error = eventSource->ExecuteTrap(GetPresetL, control, (TDes*) &preset); |
|
171 |
|
172 if (error == KErrNone) |
|
173 { |
|
174 // return NULL if there is no preset set in the native class |
|
175 if (preset == KNullDesC) |
|
176 { |
|
177 aJni->SetObjectArrayElement(aPreset, 0, NULL); |
|
178 } |
|
179 else |
|
180 { |
|
181 jstring javaStr = S60CommonUtils::NativeToJavaString(*aJni, preset); |
|
182 if (!javaStr) |
|
183 { |
|
184 return KErrNoMemory; |
|
185 } |
|
186 |
|
187 aJni->SetObjectArrayElement(aPreset, 0, javaStr); |
|
188 } |
|
189 } |
|
190 |
|
191 return error; |
|
192 } |
|
193 |
|
194 /* |
|
195 * Class: com_nokia_amms_control_EffectControl |
|
196 * Method: _setScope |
|
197 * Signature: (III)I |
|
198 */ |
|
199 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_EffectControl__1setScope( |
|
200 JNIEnv*, jclass, jint aEventSource, jint aControl, jint aScope) |
|
201 { |
|
202 MMAFunctionServer* eventSource = |
|
203 reinterpret_cast< MMAFunctionServer *>(aEventSource); |
|
204 |
|
205 CAMMSEffectControlGroup* control = static_cast<CAMMSEffectControlGroup*>( |
|
206 reinterpret_cast< CAMMSControlGroup *>(aControl)); |
|
207 |
|
208 TInt error; |
|
209 error = eventSource->ExecuteTrap(SetScopeL, control, aScope); |
|
210 return error; |
|
211 } |
|
212 |
|
213 /* |
|
214 * Class: com_nokia_amms_control_EffectControl |
|
215 * Method: _setEnabled |
|
216 * Signature: (IIZ)I |
|
217 */ |
|
218 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_EffectControl__1setEnabled( |
|
219 JNIEnv*, jclass, jint aEventSource, jint aControl, jboolean aEnabled) |
|
220 { |
|
221 MMAFunctionServer* eventSource = |
|
222 reinterpret_cast< MMAFunctionServer* >(aEventSource); |
|
223 |
|
224 CAMMSEffectControlGroup* control = static_cast<CAMMSEffectControlGroup*>( |
|
225 reinterpret_cast< CAMMSControlGroup* >(aControl)); |
|
226 |
|
227 TInt error; |
|
228 error = eventSource->ExecuteTrap(SetEnabledL, control, (TBool) aEnabled); |
|
229 return error; |
|
230 } |
|
231 |
|
232 /* |
|
233 * Class: com_nokia_amms_control_EffectControl |
|
234 * Method: _getScope |
|
235 * Signature: (II)I |
|
236 */ |
|
237 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_EffectControl__1getScope( |
|
238 JNIEnv*, jclass, jint, jint aControl) |
|
239 { |
|
240 CAMMSEffectControlGroup* control = static_cast<CAMMSEffectControlGroup*>( |
|
241 reinterpret_cast< CAMMSControlGroup* >(aControl)); |
|
242 |
|
243 return control->Scope(); |
|
244 } |
|
245 |
|
246 /* |
|
247 * Class: com_nokia_amms_control_EffectControl |
|
248 * Method: _setPreset |
|
249 * Signature: (IILjava/lang/String;)I |
|
250 */ |
|
251 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_EffectControl__1setPreset( |
|
252 JNIEnv* aJni, jclass, jint aEventSource, jint aControl, jstring aPreset) |
|
253 { |
|
254 MMAFunctionServer* eventSource = |
|
255 reinterpret_cast< MMAFunctionServer *>(aEventSource); |
|
256 |
|
257 CAMMSEffectControlGroup* control = static_cast<CAMMSEffectControlGroup*>( |
|
258 reinterpret_cast< CAMMSControlGroup* >(aControl)); |
|
259 |
|
260 TInt error; |
|
261 JStringUtils preset(*aJni, aPreset); |
|
262 error = eventSource->ExecuteTrap(SetPresetL, control, (TDesC*) &preset); |
|
263 |
|
264 ELOG1( EJavaAMMS, "AMMS:JNI:EffectControl:setPreset, err=%d", error); |
|
265 |
|
266 return error; |
|
267 } |
|
268 |
|
269 /* |
|
270 * Class: com_nokia_amms_control_EffectControl |
|
271 * Method: _setEnforced |
|
272 * Signature: (IIZ)I |
|
273 */ |
|
274 JNIEXPORT jint JNICALL Java_com_nokia_amms_control_EffectControl__1setEnforced( |
|
275 JNIEnv*, jclass, jint aEventSource, jint aControl, jboolean aEnforced) |
|
276 { |
|
277 MMAFunctionServer* eventSource = |
|
278 reinterpret_cast< MMAFunctionServer* >(aEventSource); |
|
279 |
|
280 CAMMSEffectControlGroup* control = static_cast<CAMMSEffectControlGroup*>( |
|
281 reinterpret_cast< CAMMSControlGroup *>(aControl)); |
|
282 |
|
283 TInt error; |
|
284 error = eventSource->ExecuteTrap( |
|
285 SetEnforcedL, |
|
286 control, |
|
287 (TBool) aEnforced); |
|
288 return error; |
|
289 } |
|
290 |
|
291 |
|
292 |
|
293 // End of File |