1 /* |
|
2 * Copyright (c) 2005-2006 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 methods |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CM2GEventSource.h" |
|
20 #include "com_nokia_microedition_m2g_M2GDocument.h" |
|
21 #include "MM2GSVGProxy.h" |
|
22 |
|
23 M2G_NS_START |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 |
|
27 // EXTERNAL FUNCTION PROTOTYPES |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // LOCAL CONSTANTS AND MACROS |
|
34 |
|
35 // MODULE DATA STRUCTURES |
|
36 |
|
37 // LOCAL FUNCTION PROTOTYPES |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 // ================================ FUNCTIONS ================================== |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // Java_com_nokia_microedition_m2g_M2GDocument::_createDocument |
|
47 // ----------------------------------------------------------------------------- |
|
48 /** |
|
49 * Calls MM2GSVGProxy::CreateDocumentL method. |
|
50 * @since Series S60 3.0 |
|
51 * @param aProxy Proxy instance. |
|
52 * @param aData Document data |
|
53 * @param aHandle Document handle to be returned |
|
54 * @throws Exception if not ok |
|
55 */ |
|
56 JNIEXPORT jint JNICALL |
|
57 Java_com_nokia_microedition_m2g_M2GDocument__1createDocument( |
|
58 JNIEnv* aJni, |
|
59 jclass, |
|
60 jint aSvgProxyHandle, |
|
61 jstring aData) |
|
62 { |
|
63 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _createDocument - begin"); |
|
64 |
|
65 TInt handle = M2G_INVALID_HANDLE; |
|
66 TInt err = KM2GNotOk; |
|
67 RJString data(*aJni, aData); |
|
68 TPtrC16* bData = STATIC_CAST(TPtrC16*, &data); |
|
69 |
|
70 M2G_DO_LOCK |
|
71 if (aSvgProxyHandle) |
|
72 { |
|
73 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
74 TRAP(err,aProxy->CreateDocumentL(*bData, handle);); |
|
75 } |
|
76 M2G_DO_UNLOCK(aJni) |
|
77 |
|
78 handle = M2GGeneral::CheckErrorCodeAndHandle(aJni, err, handle, M2G_INVALID_HANDLE); |
|
79 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _createDocument: %d - end", handle); |
|
80 return handle; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // Java_com_nokia_microedition_m2g_M2GDocument::_createElementNS |
|
85 // ----------------------------------------------------------------------------- |
|
86 /** |
|
87 * Calls MM2GSVGProxy::CreateElementNsL method. |
|
88 * @since Series S60 3.0 |
|
89 * @param aProxy Proxy instance. |
|
90 * @param aType Element type id. |
|
91 * @param aDocumentHandle Document handle. |
|
92 * @param aHandle Element handle to be returned |
|
93 * @throws Exception if not ok |
|
94 */ |
|
95 JNIEXPORT jint JNICALL |
|
96 Java_com_nokia_microedition_m2g_M2GDocument__1createElementNS( |
|
97 JNIEnv* aJni, |
|
98 jclass, |
|
99 jint aSvgProxyHandle, |
|
100 jshort aType, |
|
101 jint aDocumentHandle) |
|
102 { |
|
103 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _createElementNS - begin"); |
|
104 |
|
105 // Execute native engine method |
|
106 TInt handle = M2G_INVALID_HANDLE; |
|
107 TInt err = KM2GNotOk; |
|
108 |
|
109 M2G_DO_LOCK |
|
110 if (aSvgProxyHandle) |
|
111 { |
|
112 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
113 TRAP(err,aProxy->CreateElementNsL( |
|
114 aType, |
|
115 aDocumentHandle, |
|
116 handle); ); |
|
117 |
|
118 } |
|
119 M2G_DO_UNLOCK(aJni) |
|
120 |
|
121 M2GGeneral::CheckErrorCode(aJni, err); |
|
122 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _createElementNS: %d - end", handle); |
|
123 return handle; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // Java_com_nokia_microedition_m2g_M2GDocument::_deleteDocument |
|
128 // ----------------------------------------------------------------------------- |
|
129 /** |
|
130 * Calls MM2GSVGProxy::DeleteDocumentL method. |
|
131 * @since Series S60 3.0 |
|
132 * @param aProxy Proxy instance. |
|
133 * @param aDocumentHandle Document handle |
|
134 * @throws Exception if not ok |
|
135 */ |
|
136 JNIEXPORT void JNICALL |
|
137 Java_com_nokia_microedition_m2g_M2GDocument__1deleteDocument( |
|
138 JNIEnv* aJni, |
|
139 jclass, |
|
140 jint aSvgProxyHandle, |
|
141 jint aDocumentHandle ) |
|
142 { |
|
143 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _deleteDocument - begin"); |
|
144 TInt err = KM2GNotOk; |
|
145 |
|
146 M2G_DO_LOCK |
|
147 // Extract the SVGProxy handle |
|
148 if (aSvgProxyHandle) |
|
149 { |
|
150 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
151 TRAP(err,aProxy->DeleteDocumentL(aDocumentHandle);); |
|
152 } |
|
153 M2G_DO_UNLOCK(aJni) |
|
154 |
|
155 M2GGeneral::CheckErrorCode(aJni, err); |
|
156 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _deleteDocument - end"); |
|
157 } |
|
158 |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // Java_com_nokia_microedition_m2g_M2GDocument::_getElementById |
|
162 // ----------------------------------------------------------------------------- |
|
163 /** |
|
164 * Calls MM2GSVGProxy::GetElementByIdL method. |
|
165 * @since Series S60 3.0 |
|
166 * @param aProxy Proxy instance. |
|
167 * @param aDocumentHandle Document pointer. |
|
168 * @param aId Element ID. |
|
169 * @param aHandle Element handle to be returned. |
|
170 */ |
|
171 JNIEXPORT jint JNICALL |
|
172 Java_com_nokia_microedition_m2g_M2GDocument__1getElementById( |
|
173 JNIEnv* aJni, |
|
174 jclass, |
|
175 jint aSvgProxyHandle, |
|
176 jint aDocumentHandle, |
|
177 jstring aId) |
|
178 { |
|
179 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _getElementById - begin"); |
|
180 TInt handle = M2G_INVALID_HANDLE; |
|
181 TInt err = KM2GNotOk; |
|
182 RJString id(*aJni, aId); |
|
183 TPtrC16* lId = STATIC_CAST(TPtrC16*, &id); |
|
184 |
|
185 M2G_DO_LOCK |
|
186 if (aSvgProxyHandle) |
|
187 { |
|
188 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
189 TRAP(err,aProxy->GetElementByIdL(aDocumentHandle, *lId, handle);); |
|
190 } |
|
191 M2G_DO_UNLOCK(aJni) |
|
192 |
|
193 M2GGeneral::CheckErrorCode(aJni, err); |
|
194 |
|
195 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _getElementById: %d - end", handle); |
|
196 return handle; |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // Java_com_nokia_microedition_m2g_M2GDocument::_getViewportHeight |
|
201 // ----------------------------------------------------------------------------- |
|
202 /** |
|
203 * Calls MM2GSVGProxy::GetViewportHeightL method. |
|
204 * @since Series S60 3.0 |
|
205 * @param aProxy Proxy instance. |
|
206 * @param aDocumentHandle Document pointer. |
|
207 * @param aHeight Height to be returned. |
|
208 */ |
|
209 JNIEXPORT jint JNICALL |
|
210 Java_com_nokia_microedition_m2g_M2GDocument__1getViewportHeight( |
|
211 JNIEnv* aJni, |
|
212 jclass, |
|
213 jint aSvgProxyHandle, |
|
214 jint aDocumentHandle) |
|
215 { |
|
216 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _getViewportHeight - begin"); |
|
217 TInt err = KM2GNotOk; |
|
218 TInt height = 0; |
|
219 |
|
220 M2G_DO_LOCK |
|
221 if (aSvgProxyHandle) |
|
222 { |
|
223 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
224 TRAP(err,aProxy->GetViewportHeightL(aDocumentHandle, height);); |
|
225 } |
|
226 M2G_DO_UNLOCK(aJni) |
|
227 |
|
228 M2GGeneral::CheckErrorCode(aJni, err); |
|
229 |
|
230 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _getViewportHeight: %d - end", height); |
|
231 return height; |
|
232 } |
|
233 // ----------------------------------------------------------------------------- |
|
234 // Java_com_nokia_microedition_m2g_M2GDocument::_getViewportWidth |
|
235 // ----------------------------------------------------------------------------- |
|
236 /** |
|
237 * Calls MM2GSVGProxy::GetViewportWidthL method. |
|
238 * @since Series S60 3.0 |
|
239 * @param aProxy Proxy instance. |
|
240 * @param aDocumentHandle Document pointer. |
|
241 * @param aWidth Width to be returned. |
|
242 * Class: com_nokia_microedition_m2g_M2GDocument |
|
243 * Method: _getViewportWidth |
|
244 * Signature: |
|
245 */ |
|
246 JNIEXPORT jint JNICALL |
|
247 Java_com_nokia_microedition_m2g_M2GDocument__1getViewportWidth( |
|
248 JNIEnv* aJni, |
|
249 jclass, |
|
250 jint aSvgProxyHandle, |
|
251 jint aDocumentHandle) |
|
252 { |
|
253 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _getViewportWidth - begin"); |
|
254 TInt err = KM2GNotOk; |
|
255 TInt width = 0; |
|
256 |
|
257 M2G_DO_LOCK |
|
258 if (aSvgProxyHandle) |
|
259 { |
|
260 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
261 TRAP(err,aProxy->GetViewportWidthL(aDocumentHandle, width);); |
|
262 } |
|
263 M2G_DO_UNLOCK(aJni) |
|
264 |
|
265 M2GGeneral::CheckErrorCode(aJni, err); |
|
266 |
|
267 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _getViewportWidth: %d - end", width); |
|
268 return width; |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // Java_com_nokia_microedition_m2g_M2GDocument::_isElementInDom |
|
273 // ----------------------------------------------------------------------------- |
|
274 /** |
|
275 * Calls MM2GSVGProxy::IsElementInDomL method. |
|
276 * @since Series S60 3.0 |
|
277 * @param aProxy Proxy instance. |
|
278 * @param aDocumentHandle Document pointer. |
|
279 * @param aElementHandle Element pointer. |
|
280 * @param aIsElementInDom Result |
|
281 */ |
|
282 JNIEXPORT jint JNICALL |
|
283 Java_com_nokia_microedition_m2g_M2GDocument__1isElementInDOM( |
|
284 JNIEnv* aJni, |
|
285 jclass, |
|
286 jint aSvgProxyHandle, |
|
287 jint aDocumentHandle, |
|
288 jint aElementHandle) |
|
289 { |
|
290 M2G_DEBUG_0("M2G_DEBUG: JNI _isElementInDOM - begin"); |
|
291 TInt isElementInDom = -1; |
|
292 TInt err = KM2GNotOk; |
|
293 |
|
294 M2G_DO_LOCK |
|
295 if (aSvgProxyHandle) |
|
296 { |
|
297 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
298 TRAP(err,aProxy->IsElementInDomL( |
|
299 aDocumentHandle, aElementHandle, isElementInDom);); |
|
300 } |
|
301 M2G_DO_UNLOCK(aJni) |
|
302 |
|
303 M2GGeneral::CheckErrorCode(aJni, err); |
|
304 |
|
305 M2G_DEBUG_1("M2G_DEBUG: JNI _isElementInDOM: %d - end", isElementInDom); |
|
306 return isElementInDom; |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // Java_com_nokia_microedition_m2g_M2GDocument::_requestCompleted |
|
311 // ----------------------------------------------------------------------------- |
|
312 /** |
|
313 * Calls MM2GSVGProxy::RequestCompletedL method. |
|
314 * @since Series S60 3.0 |
|
315 * @param aProxy Proxy instance. |
|
316 * @param aDocumentHandle Document pointer. |
|
317 * @param aURI Resource uri |
|
318 * @param aResourceData Resource data |
|
319 * @param aCompleted Result |
|
320 */ |
|
321 JNIEXPORT jint JNICALL |
|
322 Java_com_nokia_microedition_m2g_M2GDocument__1requestCompleted( |
|
323 JNIEnv* aJni, |
|
324 jclass, |
|
325 jint aSvgProxyHandle, |
|
326 jint aDocumentHandle, |
|
327 jstring aURI, |
|
328 jbyteArray aResourceData) |
|
329 { |
|
330 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _requestCompleted - begin"); |
|
331 |
|
332 RJString uri(*aJni, aURI); |
|
333 TInt err = KM2GNotOk; |
|
334 TPtrC8 lResData8; |
|
335 jbyte* resBytes = NULL; |
|
336 |
|
337 if (aResourceData) |
|
338 { |
|
339 resBytes = aJni->GetByteArrayElements(aResourceData, NULL); |
|
340 lResData8.Set(REINTERPRET_CAST(TUint8*, resBytes), aJni->GetArrayLength(aResourceData)); |
|
341 } |
|
342 |
|
343 TInt completed = -1; |
|
344 TPtrC16* pUri = STATIC_CAST(TPtrC16*, &uri); |
|
345 |
|
346 M2G_DO_LOCK |
|
347 |
|
348 if (aSvgProxyHandle) |
|
349 { |
|
350 |
|
351 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
352 |
|
353 TRAP(err, aProxy->RequestCompletedL( |
|
354 aDocumentHandle, |
|
355 *pUri, |
|
356 lResData8, |
|
357 completed);); |
|
358 } |
|
359 M2G_DO_UNLOCK(aJni) |
|
360 |
|
361 M2GGeneral::CheckErrorCode(aJni, err); |
|
362 if (aResourceData) |
|
363 { |
|
364 aJni->ReleaseByteArrayElements(aResourceData, resBytes, JNI_ABORT); // don't copy back |
|
365 } |
|
366 |
|
367 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _requestCompleted: %d - end", completed); |
|
368 |
|
369 return completed; |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // Java_com_nokia_microedition_m2g_M2GDocument::_setViewportHeight |
|
374 // ----------------------------------------------------------------------------- |
|
375 /** |
|
376 * Calls MM2GSVGProxy::SetViewportHeightL method. |
|
377 * @since Series S60 3.0 |
|
378 * @param aProxy Proxy instance. |
|
379 * @param aDocumentHandle Document pointer. |
|
380 * @param aHeight Height |
|
381 * JNI method |
|
382 */ |
|
383 JNIEXPORT void JNICALL |
|
384 Java_com_nokia_microedition_m2g_M2GDocument__1setViewportHeight( |
|
385 JNIEnv* aJni, |
|
386 jclass, |
|
387 jint aSvgProxyHandle, |
|
388 jint aDocumentHandle, |
|
389 jint aHeight) |
|
390 { |
|
391 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _setViewportHeight - begin"); |
|
392 TInt err = KM2GNotOk; |
|
393 |
|
394 M2G_DO_LOCK |
|
395 if (aSvgProxyHandle) |
|
396 { |
|
397 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
398 TRAP(err,aProxy->SetViewportHeightL( |
|
399 (TM2GSvgDocumentHandle)aDocumentHandle, aHeight);); |
|
400 } |
|
401 M2G_DO_UNLOCK(aJni) |
|
402 |
|
403 M2GGeneral::CheckErrorCode(aJni, err); |
|
404 |
|
405 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _setViewportHeight - end"); |
|
406 } |
|
407 // ----------------------------------------------------------------------------- |
|
408 // Java_com_nokia_microedition_m2g_M2GDocument::_setViewportWidth |
|
409 // ----------------------------------------------------------------------------- |
|
410 /** |
|
411 * Calls MM2GSVGProxy::SetViewportWidthL method. |
|
412 * @since Series S60 3.0 |
|
413 * @param aProxy Proxy instance. |
|
414 * @param aDocumentHandle Document pointer. |
|
415 * @param aWidth Width |
|
416 * JNI method |
|
417 */ |
|
418 JNIEXPORT void JNICALL |
|
419 Java_com_nokia_microedition_m2g_M2GDocument__1setViewportWidth( |
|
420 JNIEnv* aJni, |
|
421 jclass, |
|
422 jint aSvgProxyHandle, |
|
423 jint aDocumentHandle, |
|
424 jint aWidth) |
|
425 { |
|
426 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _setViewportWidth - begin"); |
|
427 TInt err = KM2GNotOk; |
|
428 |
|
429 M2G_DO_LOCK |
|
430 if (aSvgProxyHandle) |
|
431 { |
|
432 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
433 TRAP(err, aProxy->SetViewportWidthL( |
|
434 (TM2GSvgDocumentHandle)aDocumentHandle, aWidth);); |
|
435 } |
|
436 M2G_DO_UNLOCK(aJni) |
|
437 |
|
438 M2GGeneral::CheckErrorCode(aJni, err); |
|
439 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _setViewportWidth - end"); |
|
440 } |
|
441 |
|
442 M2G_NS_END |
|