|
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 #include <methodwrappers.h> |
|
23 |
|
24 M2G_NS_START |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // LOCAL CONSTANTS AND MACROS |
|
35 |
|
36 // MODULE DATA STRUCTURES |
|
37 |
|
38 // LOCAL FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 // ================================ FUNCTIONS ================================== |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // Java_com_nokia_microedition_m2g_M2GDocument::_createDocument |
|
48 // ----------------------------------------------------------------------------- |
|
49 /** |
|
50 * Calls MM2GSVGProxy::CreateDocumentL method. |
|
51 * @since Series S60 3.0 |
|
52 * @param aProxy Proxy instance. |
|
53 * @param aData Document data |
|
54 * @param aHandle Document handle to be returned |
|
55 * @throws Exception if not ok |
|
56 */ |
|
57 LOCAL_C void DoCreateDocumentL( |
|
58 MM2GSVGProxy* aProxy, |
|
59 TPtrC16* aData, |
|
60 TInt* aHandle) |
|
61 { |
|
62 aProxy->CreateDocumentL(*aData, *aHandle); |
|
63 } |
|
64 |
|
65 /** |
|
66 * |
|
67 */ |
|
68 JNIEXPORT jint JNICALL |
|
69 Java_com_nokia_microedition_m2g_M2GDocument__1createDocument( |
|
70 JNIEnv* aJni, |
|
71 jclass, |
|
72 jint aEventSourceHandle, |
|
73 jint aSvgProxyHandle, |
|
74 jstring aData, |
|
75 jboolean aUiToolkit) |
|
76 { |
|
77 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _createDocument - begin"); |
|
78 TInt handle = M2G_INVALID_HANDLE; |
|
79 TInt err = KM2GNotOk; |
|
80 RJString data(*aJni, aData); |
|
81 |
|
82 if (aUiToolkit) // If eSWT is the current toolkit |
|
83 { |
|
84 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
85 if (client && aSvgProxyHandle) |
|
86 { |
|
87 typedef void (MM2GSVGProxy::*pCreateDocumentL)(const TPtrC16& ,TInt&); |
|
88 pCreateDocumentL CreateDocumentL = &MM2GSVGProxy::CreateDocumentL; |
|
89 TPtrC16* aData = STATIC_CAST(TPtrC16*, &data); |
|
90 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
91 TMethodWrapper2<MM2GSVGProxy, const TPtrC16&, TInt& > DoCreateDocument( |
|
92 *aProxy, |
|
93 CreateDocumentL, |
|
94 *aData, |
|
95 handle); |
|
96 err = client->Execute(DoCreateDocument); |
|
97 } |
|
98 } |
|
99 else |
|
100 { |
|
101 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
102 |
|
103 // RJString is a subclass of TPtrC16 |
|
104 RJString data(*aJni, aData); |
|
105 |
|
106 if (eventSource && aSvgProxyHandle) |
|
107 { |
|
108 err = eventSource->ExecuteTrap( |
|
109 &DoCreateDocumentL, |
|
110 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
111 STATIC_CAST(TPtrC16*, &data), |
|
112 &handle); |
|
113 } |
|
114 |
|
115 } |
|
116 handle = M2GGeneral::CheckErrorCodeAndHandle(aJni, err, handle, M2G_INVALID_HANDLE); |
|
117 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _createDocument: %d - end", handle); |
|
118 return handle; |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // Java_com_nokia_microedition_m2g_M2GDocument::_createElementNS |
|
123 // ----------------------------------------------------------------------------- |
|
124 /** |
|
125 * Calls MM2GSVGProxy::CreateElementNsL method. |
|
126 * @since Series S60 3.0 |
|
127 * @param aProxy Proxy instance. |
|
128 * @param aType Element type id. |
|
129 * @param aDocumentHandle Document handle. |
|
130 * @param aHandle Element handle to be returned |
|
131 * @throws Exception if not ok |
|
132 */ |
|
133 LOCAL_C void DoCreateElementNsL( |
|
134 MM2GSVGProxy* aProxy, |
|
135 TInt16 aType, |
|
136 TInt aDocumentHandle, |
|
137 TInt* aHandle) |
|
138 { |
|
139 aProxy->CreateElementNsL( |
|
140 aType, |
|
141 aDocumentHandle, |
|
142 *aHandle); |
|
143 } |
|
144 |
|
145 /** |
|
146 * |
|
147 */ |
|
148 JNIEXPORT jint JNICALL |
|
149 Java_com_nokia_microedition_m2g_M2GDocument__1createElementNS( |
|
150 JNIEnv* aJni, |
|
151 jclass, |
|
152 jint aEventSourceHandle, |
|
153 jint aSvgProxyHandle, |
|
154 jshort aType, |
|
155 jint aDocumentHandle, |
|
156 jboolean aUiToolkit) |
|
157 { |
|
158 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _createElementNS - begin"); |
|
159 |
|
160 // Execute native engine method |
|
161 TInt handle = M2G_INVALID_HANDLE; |
|
162 TInt err = KM2GNotOk; |
|
163 if (aUiToolkit) // If eSWT is the current toolkit |
|
164 { |
|
165 // get access to function server |
|
166 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
167 if (client && aSvgProxyHandle) |
|
168 { |
|
169 // Original function prototype |
|
170 typedef void (MM2GSVGProxy::*pCreateElementNsL)(const TInt16& ,const TInt&, TInt&); |
|
171 pCreateElementNsL CreateElementNsL = &MM2GSVGProxy::CreateElementNsL; |
|
172 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
173 TMethodWrapper3<MM2GSVGProxy, const TInt16&, const TInt&, TInt& > DoCreateElementNs( |
|
174 *aProxy, |
|
175 CreateElementNsL, |
|
176 aType, |
|
177 aDocumentHandle, |
|
178 handle); |
|
179 // call 'DoCreateElementNsL' on aSvgProxyHandle |
|
180 err = client->Execute(DoCreateElementNs); |
|
181 } |
|
182 } |
|
183 else |
|
184 { |
|
185 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
186 if (eventSource && aSvgProxyHandle) |
|
187 { |
|
188 err = eventSource->ExecuteTrap( |
|
189 &DoCreateElementNsL, |
|
190 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
191 aType, |
|
192 aDocumentHandle, |
|
193 &handle); |
|
194 |
|
195 } |
|
196 } |
|
197 M2GGeneral::CheckErrorCode(aJni, err); |
|
198 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _createElementNS: %d - end", handle); |
|
199 return handle; |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // Java_com_nokia_microedition_m2g_M2GDocument::_deleteDocument |
|
204 // ----------------------------------------------------------------------------- |
|
205 /** |
|
206 * Calls MM2GSVGProxy::DeleteDocumentL method. |
|
207 * @since Series S60 3.0 |
|
208 * @param aProxy Proxy instance. |
|
209 * @param aDocumentHandle Document handle |
|
210 * @throws Exception if not ok |
|
211 */ |
|
212 LOCAL_C void DoDeleteDocumentL(MM2GSVGProxy* aProxy, TInt aDocumentHandle) |
|
213 { |
|
214 aProxy->DeleteDocumentL(aDocumentHandle); |
|
215 } |
|
216 |
|
217 /** |
|
218 * JNI method |
|
219 */ |
|
220 JNIEXPORT void JNICALL |
|
221 Java_com_nokia_microedition_m2g_M2GDocument__1deleteDocument( |
|
222 JNIEnv* aJni, |
|
223 jclass, |
|
224 jint aEventSourceHandle, |
|
225 jint aSvgProxyHandle, |
|
226 jint aDocumentHandle, |
|
227 jboolean aUiToolkit) |
|
228 { |
|
229 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _deleteDocument - begin"); |
|
230 TInt err = KM2GNotOk; |
|
231 if (aUiToolkit) // If eSWT is the current toolkit |
|
232 { |
|
233 // get access to function server |
|
234 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
235 |
|
236 if (client && aSvgProxyHandle) |
|
237 { |
|
238 // Original function prototype |
|
239 typedef void (MM2GSVGProxy::*pDeleteDocumentL)(const TInt&); |
|
240 |
|
241 // Get member function address |
|
242 pDeleteDocumentL DeleteDocumentL = &MM2GSVGProxy::DeleteDocumentL; |
|
243 |
|
244 // Extract the SVGProxy handle |
|
245 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
246 |
|
247 // Use the Method wrapper for 1 Arg |
|
248 TMethodWrapper1<MM2GSVGProxy, const TInt& > DeleteDocument( |
|
249 *aProxy, |
|
250 DeleteDocumentL, |
|
251 aDocumentHandle); |
|
252 // call 'DeleteDocumentL' on aSvgProxyHandle |
|
253 err = client->Execute(DeleteDocument); |
|
254 } |
|
255 |
|
256 } |
|
257 else |
|
258 { |
|
259 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
260 if (eventSource && aSvgProxyHandle && aDocumentHandle) |
|
261 { |
|
262 // Execute native engine method |
|
263 err = eventSource->ExecuteTrap( |
|
264 &DoDeleteDocumentL, |
|
265 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
266 aDocumentHandle); |
|
267 |
|
268 } |
|
269 } |
|
270 M2GGeneral::CheckErrorCode(aJni, err); |
|
271 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _deleteDocument - end"); |
|
272 } |
|
273 |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // Java_com_nokia_microedition_m2g_M2GDocument::_getElementById |
|
277 // ----------------------------------------------------------------------------- |
|
278 /** |
|
279 * Calls MM2GSVGProxy::GetElementByIdL method. |
|
280 * @since Series S60 3.0 |
|
281 * @param aProxy Proxy instance. |
|
282 * @param aDocumentHandle Document pointer. |
|
283 * @param aId Element ID. |
|
284 * @param aHandle Element handle to be returned. |
|
285 */ |
|
286 LOCAL_C void DoGetElementByIdL( |
|
287 MM2GSVGProxy* aProxy, |
|
288 TInt aDocumentHandle, |
|
289 TPtrC16* aId, |
|
290 TInt* aHandle) |
|
291 { |
|
292 aProxy->GetElementByIdL(aDocumentHandle, *aId, *aHandle); |
|
293 } |
|
294 |
|
295 /** |
|
296 * JNI method |
|
297 */ |
|
298 JNIEXPORT jint JNICALL |
|
299 Java_com_nokia_microedition_m2g_M2GDocument__1getElementById( |
|
300 JNIEnv* aJni, |
|
301 jclass, |
|
302 jint aEventSourceHandle, |
|
303 jint aSvgProxyHandle, |
|
304 jint aDocumentHandle, |
|
305 jstring aId, |
|
306 jboolean aUiToolkit) |
|
307 { |
|
308 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _getElementById - begin"); |
|
309 TInt handle = M2G_INVALID_HANDLE; |
|
310 TInt err = KM2GNotOk; |
|
311 RJString id(*aJni, aId); |
|
312 if (aUiToolkit) |
|
313 { |
|
314 // get access to function server |
|
315 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
316 if (client && aSvgProxyHandle) |
|
317 { |
|
318 typedef void (MM2GSVGProxy::*pGetElementByIdL)(const TInt&, const TPtrC16& ,TInt&); |
|
319 pGetElementByIdL GetElementByIdL = &MM2GSVGProxy::GetElementByIdL; |
|
320 TPtrC16* lId = STATIC_CAST(TPtrC16*, &id); |
|
321 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
322 TMethodWrapper3<MM2GSVGProxy, const TInt&, const TPtrC16&, TInt& > GetElementById( |
|
323 *aProxy, |
|
324 GetElementByIdL, |
|
325 aDocumentHandle, |
|
326 *lId, |
|
327 handle); |
|
328 err = client->Execute(GetElementById); |
|
329 } |
|
330 } |
|
331 else |
|
332 { |
|
333 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
334 if (eventSource && aSvgProxyHandle) |
|
335 { |
|
336 err = eventSource->ExecuteTrap( |
|
337 &DoGetElementByIdL, |
|
338 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
339 aDocumentHandle, |
|
340 STATIC_CAST(TPtrC16*, &id), |
|
341 &handle); |
|
342 } |
|
343 } |
|
344 M2GGeneral::CheckErrorCode(aJni, err); |
|
345 |
|
346 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _getElementById: %d - end", handle); |
|
347 return handle; |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // Java_com_nokia_microedition_m2g_M2GDocument::_getViewportHeight |
|
352 // ----------------------------------------------------------------------------- |
|
353 /** |
|
354 * Calls MM2GSVGProxy::GetViewportHeightL method. |
|
355 * @since Series S60 3.0 |
|
356 * @param aProxy Proxy instance. |
|
357 * @param aDocumentHandle Document pointer. |
|
358 * @param aHeight Height to be returned. |
|
359 */ |
|
360 LOCAL_C void DoGetViewportHeightL( |
|
361 MM2GSVGProxy* aProxy, |
|
362 TInt aDocumentHandle, |
|
363 TInt* aHeight) |
|
364 { |
|
365 aProxy->GetViewportHeightL(aDocumentHandle, *aHeight); |
|
366 } |
|
367 |
|
368 /** |
|
369 * JNI method |
|
370 */ |
|
371 JNIEXPORT jint JNICALL |
|
372 Java_com_nokia_microedition_m2g_M2GDocument__1getViewportHeight( |
|
373 JNIEnv* aJni, |
|
374 jclass, |
|
375 jint aEventSourceHandle, |
|
376 jint aSvgProxyHandle, |
|
377 jint aDocumentHandle, |
|
378 jboolean aUiToolkit) |
|
379 { |
|
380 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _getViewportHeight - begin"); |
|
381 TInt err = KM2GNotOk; |
|
382 TInt height = 0; |
|
383 if (aUiToolkit) |
|
384 { |
|
385 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
386 if (client && aSvgProxyHandle) |
|
387 { |
|
388 // Original function prototype |
|
389 typedef void (MM2GSVGProxy::*pGetViewportHeightL)(const TInt& ,TInt&); |
|
390 pGetViewportHeightL GetViewportHeightL = &MM2GSVGProxy::GetViewportHeightL; |
|
391 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
392 TMethodWrapper2<MM2GSVGProxy, const TInt& ,TInt& > GetViewportHeight( |
|
393 *aProxy, |
|
394 GetViewportHeightL, |
|
395 aDocumentHandle, |
|
396 height); |
|
397 err = client->Execute(GetViewportHeight); |
|
398 } |
|
399 } |
|
400 else |
|
401 { |
|
402 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
403 |
|
404 if (eventSource && aSvgProxyHandle) |
|
405 { |
|
406 err = eventSource->ExecuteTrap( |
|
407 &DoGetViewportHeightL, |
|
408 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
409 aDocumentHandle, |
|
410 &height); |
|
411 } |
|
412 } |
|
413 M2GGeneral::CheckErrorCode(aJni, err); |
|
414 |
|
415 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _getViewportHeight: %d - end", height); |
|
416 return height; |
|
417 } |
|
418 |
|
419 |
|
420 // ----------------------------------------------------------------------------- |
|
421 // Java_com_nokia_microedition_m2g_M2GDocument::_getViewportWidth |
|
422 // ----------------------------------------------------------------------------- |
|
423 /** |
|
424 * Calls MM2GSVGProxy::GetViewportWidthL method. |
|
425 * @since Series S60 3.0 |
|
426 * @param aProxy Proxy instance. |
|
427 * @param aDocumentHandle Document pointer. |
|
428 * @param aWidth Width to be returned. |
|
429 */ |
|
430 LOCAL_C void DoGetViewportWidthL( |
|
431 MM2GSVGProxy* aProxy, |
|
432 TInt aDocumentHandle, |
|
433 TInt* aWidth) |
|
434 { |
|
435 aProxy->GetViewportWidthL(aDocumentHandle, *aWidth); |
|
436 } |
|
437 |
|
438 /** |
|
439 * Class: com_nokia_microedition_m2g_M2GDocument |
|
440 * Method: _getViewportWidth |
|
441 * Signature: |
|
442 */ |
|
443 JNIEXPORT jint JNICALL |
|
444 Java_com_nokia_microedition_m2g_M2GDocument__1getViewportWidth( |
|
445 JNIEnv* aJni, |
|
446 jclass, |
|
447 jint aEventSourceHandle, |
|
448 jint aSvgProxyHandle, |
|
449 jint aDocumentHandle, |
|
450 jboolean aUiToolkit) |
|
451 { |
|
452 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _getViewportWidth - begin"); |
|
453 TInt err = KM2GNotOk; |
|
454 TInt width = 0; |
|
455 if (aUiToolkit) |
|
456 { |
|
457 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
458 if (client && aSvgProxyHandle) |
|
459 { |
|
460 typedef void (MM2GSVGProxy::*pGetViewportWidthL)(const TInt& ,TInt&); |
|
461 pGetViewportWidthL GetViewportWidthL = &MM2GSVGProxy::GetViewportWidthL; |
|
462 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
463 TMethodWrapper2<MM2GSVGProxy, const TInt& ,TInt& > GetViewportWidth( |
|
464 *aProxy, |
|
465 GetViewportWidthL, |
|
466 aDocumentHandle, |
|
467 width); |
|
468 err = client->Execute(GetViewportWidth); |
|
469 } |
|
470 } |
|
471 else |
|
472 { |
|
473 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
474 |
|
475 if (eventSource && aSvgProxyHandle) |
|
476 { |
|
477 err = eventSource->ExecuteTrap( |
|
478 &DoGetViewportWidthL, |
|
479 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
480 aDocumentHandle, |
|
481 &width); |
|
482 } |
|
483 } |
|
484 M2GGeneral::CheckErrorCode(aJni, err); |
|
485 |
|
486 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _getViewportWidth: %d - end", width); |
|
487 return width; |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // Java_com_nokia_microedition_m2g_M2GDocument::_isElementInDom |
|
492 // ----------------------------------------------------------------------------- |
|
493 /** |
|
494 * Calls MM2GSVGProxy::IsElementInDomL method. |
|
495 * @since Series S60 3.0 |
|
496 * @param aProxy Proxy instance. |
|
497 * @param aDocumentHandle Document pointer. |
|
498 * @param aElementHandle Element pointer. |
|
499 * @param aIsElementInDom Result |
|
500 */ |
|
501 LOCAL_C void DoIsElementInDomL( |
|
502 MM2GSVGProxy* aProxy, |
|
503 TInt aDocumentHandle, |
|
504 TInt aElementHandle, |
|
505 TInt* aIsElementInDom) |
|
506 { |
|
507 aProxy->IsElementInDomL( |
|
508 aDocumentHandle, aElementHandle, *aIsElementInDom); |
|
509 } |
|
510 |
|
511 /** |
|
512 * JNI method. |
|
513 */ |
|
514 JNIEXPORT jint JNICALL |
|
515 Java_com_nokia_microedition_m2g_M2GDocument__1isElementInDOM( |
|
516 JNIEnv* aJni, |
|
517 jclass, |
|
518 jint aEventSourceHandle, |
|
519 jint aSvgProxyHandle, |
|
520 jint aDocumentHandle, |
|
521 jint aElementHandle, |
|
522 jboolean aUiToolkit) |
|
523 { |
|
524 M2G_DEBUG_0("M2G_DEBUG: JNI _isElementInDOM - begin"); |
|
525 TInt isElementInDom = -1; |
|
526 TInt err = KM2GNotOk; |
|
527 if (aUiToolkit) |
|
528 { |
|
529 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
530 if (client && aSvgProxyHandle) |
|
531 { |
|
532 typedef void (MM2GSVGProxy::*pIsElementInDomL)(const TInt& ,const TInt&, TInt&); |
|
533 pIsElementInDomL IsElementInDomL = &MM2GSVGProxy::IsElementInDomL; |
|
534 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
535 TMethodWrapper3<MM2GSVGProxy, const TInt& ,const TInt&, TInt& > IsElementInDom( |
|
536 *aProxy, |
|
537 IsElementInDomL, |
|
538 aDocumentHandle, |
|
539 aElementHandle, |
|
540 isElementInDom); |
|
541 err = client->Execute(IsElementInDom); |
|
542 } |
|
543 } |
|
544 else |
|
545 { |
|
546 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
547 |
|
548 if (eventSource && aSvgProxyHandle) |
|
549 { |
|
550 err = eventSource->ExecuteTrap( |
|
551 &DoIsElementInDomL, |
|
552 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
553 aDocumentHandle, |
|
554 aElementHandle, |
|
555 &isElementInDom); |
|
556 } |
|
557 } |
|
558 M2GGeneral::CheckErrorCode(aJni, err); |
|
559 |
|
560 M2G_DEBUG_1("M2G_DEBUG: JNI _isElementInDOM: %d - end", isElementInDom); |
|
561 return isElementInDom; |
|
562 } |
|
563 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // Java_com_nokia_microedition_m2g_M2GDocument::_requestCompleted |
|
566 // ----------------------------------------------------------------------------- |
|
567 /** |
|
568 * Calls MM2GSVGProxy::RequestCompletedL method. |
|
569 * @since Series S60 3.0 |
|
570 * @param aProxy Proxy instance. |
|
571 * @param aDocumentHandle Document pointer. |
|
572 * @param aURI Resource uri |
|
573 * @param aResourceData Resource data |
|
574 * @param aCompleted Result |
|
575 */ |
|
576 LOCAL_C void DoRequestCompletedL( |
|
577 MM2GSVGProxy* aProxy, |
|
578 TM2GSvgDocumentHandle aDocumentHandle, |
|
579 TPtrC16* aURI, |
|
580 TPtrC8* aResourceData, |
|
581 TInt* aCompleted) |
|
582 { |
|
583 aProxy->RequestCompletedL( |
|
584 aDocumentHandle, |
|
585 *aURI, |
|
586 *aResourceData, |
|
587 *aCompleted); |
|
588 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) DoRequestCompletedL: %d - end", *aCompleted); |
|
589 } |
|
590 |
|
591 /** |
|
592 * JNI method |
|
593 */ |
|
594 JNIEXPORT jint JNICALL |
|
595 Java_com_nokia_microedition_m2g_M2GDocument__1requestCompleted( |
|
596 JNIEnv* aJni, |
|
597 jclass, |
|
598 jint aEventSourceHandle, |
|
599 jint aSvgProxyHandle, |
|
600 jint aDocumentHandle, |
|
601 jstring aURI, |
|
602 jbyteArray aResourceData, |
|
603 jboolean aUiToolkit) |
|
604 { |
|
605 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _requestCompleted - begin"); |
|
606 |
|
607 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
608 RJString uri(*aJni, aURI); |
|
609 TInt err = KM2GNotOk; |
|
610 TPtrC8 lResData8; |
|
611 jbyte* resBytes = NULL; |
|
612 |
|
613 if (aResourceData) |
|
614 { |
|
615 resBytes = aJni->GetByteArrayElements(aResourceData, NULL); |
|
616 lResData8.Set(REINTERPRET_CAST(TUint8*, resBytes), aJni->GetArrayLength(aResourceData)); |
|
617 } |
|
618 |
|
619 TInt completed = -1; |
|
620 if (aUiToolkit) |
|
621 { |
|
622 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
623 if (client && aSvgProxyHandle) |
|
624 { |
|
625 TPtrC16* pUri = STATIC_CAST(TPtrC16*, &uri); |
|
626 typedef void (MM2GSVGProxy::*pRequestCompletedL)(const TInt& ,const TPtrC16&, const TPtrC8&, TInt&); |
|
627 pRequestCompletedL RequestCompletedL = &MM2GSVGProxy::RequestCompletedL; |
|
628 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
629 TMethodWrapper4<MM2GSVGProxy, const TInt& ,const TPtrC16&, const TPtrC8&, TInt& > RequestCompleted( |
|
630 *aProxy, |
|
631 RequestCompletedL, |
|
632 aDocumentHandle, |
|
633 *pUri, |
|
634 lResData8, |
|
635 completed); |
|
636 err = client->Execute(RequestCompleted); |
|
637 } |
|
638 } |
|
639 else |
|
640 { |
|
641 if (eventSource && aSvgProxyHandle) |
|
642 { |
|
643 err = eventSource->ExecuteTrap( |
|
644 &DoRequestCompletedL, |
|
645 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
646 aDocumentHandle, |
|
647 STATIC_CAST(TPtrC16*, &uri), |
|
648 &lResData8, |
|
649 &completed); |
|
650 |
|
651 } |
|
652 |
|
653 } |
|
654 M2GGeneral::CheckErrorCode(aJni, err); |
|
655 if (aResourceData) |
|
656 { |
|
657 aJni->ReleaseByteArrayElements(aResourceData, resBytes, JNI_ABORT); // don't copy back |
|
658 } |
|
659 |
|
660 M2G_DEBUG_1("M2G_DEBUG: JNI ( M2GDocument ) _requestCompleted: %d - end", completed); |
|
661 |
|
662 return completed; |
|
663 } |
|
664 |
|
665 // ----------------------------------------------------------------------------- |
|
666 // Java_com_nokia_microedition_m2g_M2GDocument::_setViewportHeight |
|
667 // ----------------------------------------------------------------------------- |
|
668 /** |
|
669 * Calls MM2GSVGProxy::SetViewportHeightL method. |
|
670 * @since Series S60 3.0 |
|
671 * @param aProxy Proxy instance. |
|
672 * @param aDocumentHandle Document pointer. |
|
673 * @param aHeight Height |
|
674 */ |
|
675 LOCAL_C void DoSetViewportHeightL( |
|
676 MM2GSVGProxy* aProxy, |
|
677 TInt aDocumentHandle, |
|
678 TInt aHeight) |
|
679 { |
|
680 aProxy->SetViewportHeightL( |
|
681 (TM2GSvgDocumentHandle)aDocumentHandle, aHeight); |
|
682 } |
|
683 |
|
684 /** |
|
685 * JNI method |
|
686 */ |
|
687 JNIEXPORT void JNICALL |
|
688 Java_com_nokia_microedition_m2g_M2GDocument__1setViewportHeight( |
|
689 JNIEnv* aJni, |
|
690 jclass, |
|
691 jint aEventSourceHandle, |
|
692 jint aSvgProxyHandle, |
|
693 jint aDocumentHandle, |
|
694 jint aHeight, |
|
695 jboolean aUiToolkit) |
|
696 { |
|
697 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _setViewportHeight - begin"); |
|
698 TInt err = KM2GNotOk; |
|
699 if (aUiToolkit) |
|
700 { |
|
701 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
702 if (client && aSvgProxyHandle) |
|
703 { |
|
704 typedef void (MM2GSVGProxy::*pSetViewportHeightL)(const TInt& ,TInt); |
|
705 pSetViewportHeightL SetViewportHeightL = &MM2GSVGProxy::SetViewportHeightL; |
|
706 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
707 TMethodWrapper2<MM2GSVGProxy, const TInt& ,TInt > SetViewportHeight( |
|
708 *aProxy, |
|
709 SetViewportHeightL, |
|
710 aDocumentHandle, |
|
711 aHeight); |
|
712 err = client->Execute(SetViewportHeight); |
|
713 } |
|
714 } |
|
715 else |
|
716 { |
|
717 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
718 if (eventSource && aSvgProxyHandle) |
|
719 { |
|
720 err = eventSource->ExecuteTrap( |
|
721 &DoSetViewportHeightL, |
|
722 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
723 aDocumentHandle, |
|
724 aHeight); |
|
725 } |
|
726 } |
|
727 M2GGeneral::CheckErrorCode(aJni, err); |
|
728 |
|
729 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _setViewportHeight - end"); |
|
730 } |
|
731 |
|
732 // ----------------------------------------------------------------------------- |
|
733 // Java_com_nokia_microedition_m2g_M2GDocument::_setViewportWidth |
|
734 // ----------------------------------------------------------------------------- |
|
735 /** |
|
736 * Calls MM2GSVGProxy::SetViewportWidthL method. |
|
737 * @since Series S60 3.0 |
|
738 * @param aProxy Proxy instance. |
|
739 * @param aDocumentHandle Document pointer. |
|
740 * @param aWidth Width |
|
741 */ |
|
742 LOCAL_C void DoSetViewportWidthL( |
|
743 MM2GSVGProxy* aProxy, |
|
744 TInt aDocumentHandle, |
|
745 TInt aWidth) |
|
746 { |
|
747 aProxy->SetViewportWidthL( |
|
748 (TM2GSvgDocumentHandle)aDocumentHandle, aWidth); |
|
749 } |
|
750 |
|
751 /** |
|
752 * JNI method |
|
753 */ |
|
754 JNIEXPORT void JNICALL |
|
755 Java_com_nokia_microedition_m2g_M2GDocument__1setViewportWidth( |
|
756 JNIEnv* aJni, |
|
757 jclass, |
|
758 jint aEventSourceHandle, |
|
759 jint aSvgProxyHandle, |
|
760 jint aDocumentHandle, |
|
761 jint aWidth, |
|
762 jboolean aUiToolkit) |
|
763 { |
|
764 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _setViewportWidth - begin"); |
|
765 TInt err = KM2GNotOk; |
|
766 if (aUiToolkit) |
|
767 { |
|
768 MSwtClient* client = reinterpret_cast< MSwtClient* >(aEventSourceHandle); |
|
769 if (client && aSvgProxyHandle) |
|
770 { |
|
771 typedef void (MM2GSVGProxy::*pSetViewportWidthL)(const TInt& ,TInt); |
|
772 pSetViewportWidthL SetViewportWidthL = &MM2GSVGProxy::SetViewportWidthL; |
|
773 MM2GSVGProxy* aProxy = JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle); |
|
774 TMethodWrapper2<MM2GSVGProxy, const TInt& ,TInt > SetViewportWidth( |
|
775 *aProxy, |
|
776 SetViewportWidthL, |
|
777 aDocumentHandle, |
|
778 aWidth); |
|
779 err = client->Execute(SetViewportWidth); |
|
780 } |
|
781 } |
|
782 else |
|
783 { |
|
784 CM2GEventSource* eventSource = JavaUnhand< CM2GEventSource >(aEventSourceHandle); |
|
785 if (eventSource && aSvgProxyHandle) |
|
786 { |
|
787 err = eventSource->ExecuteTrap( |
|
788 &DoSetViewportWidthL, |
|
789 JavaUnhand<MM2GSVGProxy>(aSvgProxyHandle), |
|
790 aDocumentHandle, |
|
791 aWidth); |
|
792 |
|
793 } |
|
794 } |
|
795 M2GGeneral::CheckErrorCode(aJni, err); |
|
796 M2G_DEBUG_0("M2G_DEBUG: JNI ( M2GDocument ) _setViewportWidth - end"); |
|
797 } |
|
798 |
|
799 M2G_NS_END |