javauis/lcdui_akn/javalcdui/src.nokialcdui/DeviceControlImpl.cpp
changeset 21 2a9601315dfc
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*
       
     2 * Copyright (c) 2006 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 class for DeviceControlImpl.java.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "com_nokia_mid_ui_impl_DeviceControlImpl.h"
       
    20 #include "CMIDToolkit.h"
       
    21 #include "CMIDDeviceControl.h"
       
    22 
       
    23 /**
       
    24  * Class: com_nokia_mid_ui_impl_DeviceControlImpl
       
    25  * Method: _getUserInactivityTime
       
    26  * Signature: (II)I
       
    27  */
       
    28 JNIEXPORT jint JNICALL
       
    29 Java_com_nokia_mid_ui_impl_DeviceControlImpl__1getUserInactivityTime(
       
    30     JNIEnv* /* aJniEnv */, jobject /* aObject */,
       
    31     jint aToolkitHandle, jint aDeviceControlHandle)
       
    32 {
       
    33     CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle);
       
    34     CMIDDeviceControl* dc =
       
    35         MIDUnhand< CMIDDeviceControl >(aDeviceControlHandle);
       
    36     TBool retVal;
       
    37     toolkit->ExecuteV(&CMIDDeviceControl::StaticGetUserInactivityTimeL,
       
    38                       dc, &retVal);
       
    39 
       
    40     return retVal;
       
    41 }
       
    42 
       
    43 
       
    44 
       
    45 /**
       
    46  * Class: com_nokia_mid_ui_impl_DeviceControlImpl
       
    47  * Method: _resetUserInactivityTime
       
    48  * Signature: (II)I
       
    49  */
       
    50 JNIEXPORT jint JNICALL
       
    51 Java_com_nokia_mid_ui_impl_DeviceControlImpl__1resetUserInactivityTime(
       
    52     JNIEnv* /* aJniEnv */, jobject /* aObject */,
       
    53     jint aToolkitHandle, jint aDeviceControlHandle)
       
    54 {
       
    55     CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle);
       
    56     CMIDDeviceControl* dc =
       
    57         MIDUnhand< CMIDDeviceControl >(aDeviceControlHandle);
       
    58     TInt err = toolkit->ExecuteTrap(&CMIDDeviceControl::
       
    59                                     StaticResetUserInactivityTimeL, dc);
       
    60     return err;
       
    61 }
       
    62 
       
    63 
       
    64 /**
       
    65  * Class: com_nokia_mid_ui_impl_DeviceControlImpl
       
    66  * Method: _setLights
       
    67  * Signature: (III)I
       
    68  */
       
    69 JNIEXPORT jint JNICALL
       
    70 Java_com_nokia_mid_ui_impl_DeviceControlImpl__1setLights(
       
    71     JNIEnv* /* aJniEnv */, jobject /* aObject */,
       
    72     jint aToolkitHandle, jint aDeviceControlHandle, jint aLevel)
       
    73 {
       
    74     CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle);
       
    75     CMIDDeviceControl* dc =
       
    76         MIDUnhand< CMIDDeviceControl >(aDeviceControlHandle);
       
    77     TInt err = toolkit->ExecuteTrap(&CMIDDeviceControl::StaticSetLightL,
       
    78                                     dc, aLevel);
       
    79     return err;
       
    80 }
       
    81 
       
    82 /**
       
    83  * Class: com_nokia_mid_ui_impl_DeviceControlImpl
       
    84  * Method: _flashLights
       
    85  * Signature: (III)B
       
    86  */
       
    87 JNIEXPORT jboolean JNICALL
       
    88 Java_com_nokia_mid_ui_impl_DeviceControlImpl__1flashLights(
       
    89     JNIEnv* /* aJniEnv */, jobject /* aObject */,
       
    90     jint aToolkitHandle, jint aDeviceControlHandle, jint aDuration)
       
    91 {
       
    92     CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle);
       
    93     CMIDDeviceControl* dc =
       
    94         MIDUnhand< CMIDDeviceControl >(aDeviceControlHandle);
       
    95     TBool retVal;
       
    96     TInt err = toolkit->ExecuteTrap(&CMIDDeviceControl::StaticFlashBacklightL,
       
    97                                     dc, aDuration, &retVal);
       
    98     if (KErrNone != err)
       
    99     {
       
   100         return false;
       
   101     }
       
   102     return retVal;
       
   103 }
       
   104 
       
   105 /**
       
   106  * Class: com_nokia_mid_ui_impl_DeviceControlImpl
       
   107  * Method: _release
       
   108  * Signature: (II)V
       
   109  */
       
   110 JNIEXPORT void JNICALL
       
   111 Java_com_nokia_mid_ui_impl_DeviceControlImpl__1release(
       
   112     JNIEnv* /* aJniEnv */, jobject /* aObject */,
       
   113     jint aToolkitHandle, jint aDeviceControlHandle)
       
   114 {
       
   115     CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle);
       
   116     CMIDDeviceControl* dc =
       
   117         MIDUnhand< CMIDDeviceControl >(aDeviceControlHandle);
       
   118     toolkit->ExecuteV(&CMIDDeviceControl::StaticRelease, dc);
       
   119 }
       
   120 
       
   121 void CreateDeviceControlL(CMIDToolkit* aToolkit, TInt* aHandle)
       
   122 {
       
   123     CMIDDeviceControl* dc = CMIDDeviceControl::NewLC(*aToolkit->Env());
       
   124 
       
   125     *aHandle = aToolkit->RegisterComponentL(dc, NULL);
       
   126     CleanupStack::Pop(dc);
       
   127 }
       
   128 
       
   129 /**
       
   130  * Class: com_nokia_mid_ui_impl_DeviceControlImpl
       
   131  * Method: _createDeviceControl
       
   132  * Signature: (I)I
       
   133  */
       
   134 JNIEXPORT jint JNICALL
       
   135 Java_com_nokia_mid_ui_impl_DeviceControlImpl__1createDeviceControl(
       
   136     JNIEnv* /* aJniEnv */, jobject /* aObject */,
       
   137     jint aToolkitHandle)
       
   138 {
       
   139     CMIDToolkit* toolkit = JavaUnhand< CMIDToolkit >(aToolkitHandle);
       
   140     TInt handle = 0;
       
   141     TInt err = toolkit->ExecuteTrap(&CreateDeviceControlL, toolkit,
       
   142                                     &handle);
       
   143     return err == KErrNone ? handle : err;
       
   144 }
       
   145 
       
   146 
       
   147