|
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: Orientation JNI context |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INTERNAL INCLUDES |
|
20 #include "javax_microedition_location_Orientation.h" |
|
21 #include "corientation.h" |
|
22 #include "sensrvmagneticnorthsensor.h" |
|
23 #include "locationfunctionserver.h" |
|
24 #include "fs_methodcall.h" |
|
25 |
|
26 // EXTERNAL INCLUDES |
|
27 #include <e32def.h> |
|
28 |
|
29 using namespace java::location; |
|
30 |
|
31 /* |
|
32 * Class: javax_microedition_location_Orientation |
|
33 * Method: _createNativeHandle |
|
34 * Signature: (I)I |
|
35 */ |
|
36 JNIEXPORT jint |
|
37 JNICALL Java_javax_microedition_location_Orientation__1createNativeHandle( |
|
38 JNIEnv* /*aJniEnv*/, |
|
39 jobject /*aPeer*/, |
|
40 jint /*aFunctionServerHandle*/ |
|
41 ) |
|
42 { |
|
43 TInt handle(0); |
|
44 TRAPD(err, COrientation::NewL(&handle)); |
|
45 |
|
46 if (err < KErrNone) |
|
47 { |
|
48 handle = err; |
|
49 } |
|
50 |
|
51 return handle; |
|
52 } |
|
53 |
|
54 /* |
|
55 * Class: javax_microedition_location_Orientation |
|
56 * Method: _getAzimuthData |
|
57 * Signature: (JI)I |
|
58 */ |
|
59 JNIEXPORT jint |
|
60 JNICALL Java_javax_microedition_location_Orientation__1getAzimuthData( |
|
61 JNIEnv* /*aJniEnv*/, |
|
62 jclass, |
|
63 jint aFunctionServerHandle, |
|
64 jint aHandle) |
|
65 { |
|
66 LocationFunctionServer *server = |
|
67 reinterpret_cast<LocationFunctionServer *>(aFunctionServerHandle); |
|
68 |
|
69 // Native Handle |
|
70 COrientation* Orientation = reinterpret_cast< COrientation *>(aHandle); |
|
71 |
|
72 Orientation->ichannelInfo.iChannelType = |
|
73 KSensrvChannelTypeIdMagneticNorthData; |
|
74 |
|
75 Orientation->mFunctionServer = server; |
|
76 TInt error = KErrNone; |
|
77 TRAPD(err,CallMethodL(error, Orientation,&COrientation::GetOrientationL,server)); |
|
78 |
|
79 if (error < KErrNone) |
|
80 { |
|
81 err = error; |
|
82 } |
|
83 |
|
84 return err; |
|
85 } |
|
86 |
|
87 /* |
|
88 * Class: javax_microedition_location_Orientation |
|
89 * Method: _getData |
|
90 * Signature: (I)F |
|
91 */ |
|
92 JNIEXPORT jfloat JNICALL Java_javax_microedition_location_Orientation__1getData( |
|
93 JNIEnv*, |
|
94 jclass, |
|
95 jint aHandle) |
|
96 { |
|
97 // Native Handle |
|
98 COrientation* iOrientation = reinterpret_cast< COrientation *>(aHandle); |
|
99 |
|
100 jfloat azimuth = static_cast<jfloat>(iOrientation->mAzimuth); |
|
101 |
|
102 return azimuth; |
|
103 } |
|
104 |
|
105 LOCAL_C void DisposeOrientationObject(COrientation* aOrientation) |
|
106 { |
|
107 delete aOrientation; |
|
108 } |
|
109 |
|
110 /* |
|
111 * Class: javax_microedition_location_Orientation |
|
112 * Method: _dispose |
|
113 * Signature: (II)V |
|
114 */ |
|
115 JNIEXPORT void JNICALL Java_javax_microedition_location_Orientation__1dispose( |
|
116 JNIEnv* /*aJniEnv*/, |
|
117 jobject /*aPeer*/, |
|
118 jint aFunctionServerHandle, |
|
119 jint aHandle) |
|
120 { |
|
121 // Native Handle |
|
122 COrientation* iOrientation = reinterpret_cast< COrientation *>(aHandle); |
|
123 |
|
124 // Function Server |
|
125 LocationFunctionServer *server = |
|
126 reinterpret_cast<LocationFunctionServer *>(aFunctionServerHandle); |
|
127 |
|
128 CallMethod(DisposeOrientationObject, iOrientation, server); |
|
129 } |
|
130 // End of File |