author | William Roberts <williamr@symbian.org> |
Fri, 18 Jun 2010 16:25:31 +0100 | |
branch | GCC_SURGE |
changeset 40 | c6043ea9b06a |
parent 21 | 2a9601315dfc |
parent 35 | 85266cc22c7f |
child 55 | d93ef1df440d |
permissions | -rw-r--r-- |
35
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
* |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
* |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
* |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
#include "javax_microedition_m3g_Interface.h" |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
|
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
|
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
/*! |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
* \brief Error handler for the Java interface |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
* |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
* Converts M3G errors to exceptions and throws them automatically. |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
24 |
*/ |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
static void errorHandler(M3Genum errorCode, M3GInterface /*m3g*/) |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
{ |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
CSynchronization::InstanceL()->SetErrorCode(errorCode); |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
} |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
|
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
30 |
/* |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
31 |
static int createInterface(M3Gparams* aCs) |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
32 |
{ |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
33 |
return ((unsigned) m3gCreateInterface(aCs)); |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
34 |
} |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
*/ |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
36 |
|
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
37 |
/* |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
38 |
* Must be executed in UI thread |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
*/ |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Interface__1ctor(JNIEnv* aEnv, jclass) |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
{ |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
M3Gparams cs; |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
memset(&cs, 0, sizeof(cs)); |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
44 |
cs.mallocFunc = malloc; |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
cs.freeFunc = free; |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
46 |
cs.errorFunc = errorHandler; |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
47 |
|
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
48 |
M3G_DO_LOCK |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
49 |
/* Call to the Eventserver side */ |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
50 |
//CJavaM3GEventSource* eventSource = JavaUnhand<CJavaM3GEventSource>(aEventSourceHandle); |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
51 |
//jint handle = eventSource->Execute(&createInterface, &cs); |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
52 |
jint handle = (unsigned)m3gCreateInterface(&cs); |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
M3G_DO_UNLOCK(aEnv); |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
return handle; |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
55 |
} |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
56 |
|
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
57 |
JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Interface__1getClassID |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
58 |
(JNIEnv* aEnv, jclass, jint aHObject) |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
59 |
{ |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
M3G_DO_LOCK |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
61 |
jint handle = m3gGetClass((M3GObject)aHObject); |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
62 |
M3G_DO_UNLOCK(aEnv); |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
63 |
return handle; |
85266cc22c7f
Revision: v2.2.1
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
64 |
} |