|
1 /* |
|
2 * Copyright (c) 2008 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: Positioner JNI context |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32def.h> |
|
20 #include <lbs.h> |
|
21 #include "com_nokia_mj_impl_location_Positioner.h" |
|
22 #include "clocationprovider.h" |
|
23 #include "cpositioner.h" |
|
24 #include "fs_methodcall.h" |
|
25 #include "logger.h" |
|
26 |
|
27 using namespace java::location; |
|
28 |
|
29 /* |
|
30 * Class: com_nokia_mj_impl_location_Positioner |
|
31 * Method: _getLocation |
|
32 * Signature: (JII)I |
|
33 */ |
|
34 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_location_Positioner__1getLocation( |
|
35 JNIEnv* /*aJni*/, |
|
36 jobject /*aPositioner*/, |
|
37 jint aFunctionServerHandle, |
|
38 jint aPositionerHandle, |
|
39 jint aTimeout) |
|
40 { |
|
41 JELOG2(EJavaLocation); |
|
42 LocationFunctionServer *server = |
|
43 reinterpret_cast<LocationFunctionServer *>(aFunctionServerHandle); |
|
44 |
|
45 CPositioner* positioner = reinterpret_cast< CPositioner *>(aPositionerHandle); |
|
46 |
|
47 TInt error = KErrNone; |
|
48 |
|
49 TRAPD(err, CallMethod(error, positioner, &CPositioner::GetLocation, aTimeout, server)); |
|
50 |
|
51 if (err < KErrNone) |
|
52 { |
|
53 error = err; |
|
54 } |
|
55 |
|
56 return error; |
|
57 } |
|
58 |
|
59 /* |
|
60 * Class: com_nokia_mj_impl_location_Positioner |
|
61 * Method: _createPositioner |
|
62 * Signature: (JI)I |
|
63 */ |
|
64 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_location_Positioner__1createPositioner( |
|
65 JNIEnv* aJni, |
|
66 jobject aPositioner, |
|
67 jint aFunctionServerHandle, |
|
68 jint aLocationProviderHandle) |
|
69 { |
|
70 JELOG2(EJavaLocation); |
|
71 |
|
72 LocationFunctionServer *server = |
|
73 reinterpret_cast<LocationFunctionServer *>(aFunctionServerHandle); |
|
74 |
|
75 CLocationProvider* locationProvider = |
|
76 reinterpret_cast<CLocationProvider *>(aLocationProviderHandle); |
|
77 |
|
78 TInt positionerHandle = KErrNotFound; |
|
79 jobject jpositioner = aJni->NewWeakGlobalRef(aPositioner); |
|
80 |
|
81 TRAPD(err, CLocationProvider::StaticCreatePositionerL(aJni, jpositioner, locationProvider, &positionerHandle, server)); |
|
82 |
|
83 if (err != KErrNone) |
|
84 { |
|
85 aJni->DeleteGlobalRef(jpositioner); |
|
86 return err; |
|
87 } |
|
88 |
|
89 return positionerHandle; |
|
90 } |
|
91 |
|
92 /* |
|
93 * Class: com_nokia_mj_impl_location_Positioner |
|
94 * Method: _cancel |
|
95 * Signature: (JI)V |
|
96 */ |
|
97 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_location_Positioner__1cancel |
|
98 (JNIEnv*, jobject, jint aFunctionServerHandle, jint aPositionerHandle) |
|
99 { |
|
100 JELOG2(EJavaLocation); |
|
101 |
|
102 LocationFunctionServer *server = |
|
103 reinterpret_cast<LocationFunctionServer *>(aFunctionServerHandle); |
|
104 |
|
105 CPositioner* positioner = reinterpret_cast< CPositioner *>(aPositionerHandle); |
|
106 |
|
107 CallMethod(positioner, &CPositioner::StaticCancel, positioner, server); |
|
108 } |
|
109 |
|
110 LOCAL_C void DisposeObject(CPositioner* aPositioner) |
|
111 { |
|
112 delete aPositioner; |
|
113 } |
|
114 |
|
115 /* |
|
116 * Class: com_nokia_mj_impl_location_Positioner |
|
117 * Method: _dispose |
|
118 * Signature: (JI)V |
|
119 */ |
|
120 JNIEXPORT void JNICALL Java_com_nokia_mj_impl_location_Positioner__1dispose |
|
121 (JNIEnv*, jobject, jint aFunctionServerHandle, jint aPositionerHandle) |
|
122 { |
|
123 JELOG2(EJavaLocation); |
|
124 |
|
125 LocationFunctionServer *server = |
|
126 reinterpret_cast<LocationFunctionServer *>(aFunctionServerHandle); |
|
127 |
|
128 CPositioner* positioner = reinterpret_cast< CPositioner *>(aPositionerHandle); |
|
129 |
|
130 CallMethod(DisposeObject, positioner, server); |
|
131 |
|
132 } |