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