|
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: JNI implementation for ChannelImpl.java |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "sensorjniutils.h" |
|
19 #include "sensornativeconstants.h" |
|
20 #include "sensor.h" |
|
21 #include "sensorconnection.h" |
|
22 #include "com_nokia_mj_impl_sensor_ChannelImpl.h" |
|
23 #include "logger.h" |
|
24 |
|
25 /* |
|
26 * Class: com_nokia_mj_impl_sensor_ChannelImpl |
|
27 * Method: _addCondition |
|
28 * Signature: (IIDDII)I |
|
29 */ |
|
30 JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_sensor_ChannelImpl__1addCondition |
|
31 (JNIEnv* /*aJniEnv*/, jobject, jint aConnection, jint aChannel, |
|
32 jdouble aLowerLimit, jdouble aUpperLimit, jint aLowerOp, jint aUpperOp) |
|
33 { |
|
34 JELOG2(ESensor); |
|
35 SensorConnection* sc = reinterpret_cast< SensorConnection* >(aConnection); |
|
36 Sensor* sensor = sc->GetSensor(); |
|
37 |
|
38 void* conditionHandle = NULL; |
|
39 |
|
40 int err = sensor->AddCondition(&conditionHandle, |
|
41 aChannel, aLowerLimit, aUpperLimit, aLowerOp, aUpperOp); |
|
42 if (err != ERROR_NONE) |
|
43 { |
|
44 return err; |
|
45 } |
|
46 |
|
47 return reinterpret_cast< int >(conditionHandle); |
|
48 } |
|
49 |
|
50 /* |
|
51 * Class: com_nokia_mj_impl_sensor_ChannelImpl |
|
52 * Method: _removeCondition |
|
53 * Signature: (I)V |
|
54 */ |
|
55 JNIEXPORT int JNICALL Java_com_nokia_mj_impl_sensor_ChannelImpl__1removeCondition |
|
56 (JNIEnv *, jobject, jint aConnection, jint aConditionId) |
|
57 { |
|
58 JELOG2(ESensor); |
|
59 SensorConnection* sc = reinterpret_cast< SensorConnection* >(aConnection); |
|
60 Sensor* sensor = sc->GetSensor(); |
|
61 |
|
62 void* conditionHandle = reinterpret_cast< void* >(aConditionId); |
|
63 return sensor->RemoveCondition(conditionHandle); |
|
64 } |