javauis/mmapi_akn/baseline/src/volumecontrol.cpp
branchRCL_3
changeset 26 2455ef1f5bbc
equal deleted inserted replaced
25:ae942d28ec0e 26:2455ef1f5bbc
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  This class has JNI wrappers for CMMAVolumeControl
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <jutils.h>
       
    20 
       
    21 #include "com_nokia_microedition_media_control_VolumeControl.h"
       
    22 #include "cmmaeventsource.h"
       
    23 #include "cmmavolumecontrol.h"
       
    24 
       
    25 
       
    26 /*
       
    27  * Class:     com_nokia_microedition_media_control_VolumeControl
       
    28  * Method:    _setLevel
       
    29  * Signature: (III)I
       
    30  */
       
    31 
       
    32 JNIEXPORT int JNICALL Java_com_nokia_microedition_media_control_VolumeControl__1setLevel
       
    33 (JNIEnv *, jclass , jint aEventSource, jint aVolumeControl, jint aLevel)
       
    34 {
       
    35     CMMAEventSource* eventSource =
       
    36         JavaUnhand< CMMAEventSource >(aEventSource);
       
    37 
       
    38     CMMAVolumeControl* volumeControl =
       
    39         JavaUnhand< CMMAVolumeControl >(aVolumeControl);
       
    40 
       
    41     TInt error = eventSource->ExecuteTrap(&CMMAVolumeControl::StaticSetLevelL,
       
    42                                           volumeControl,
       
    43                                           aLevel);
       
    44     return error;
       
    45 }
       
    46 
       
    47 /*
       
    48  * Class:     com_nokia_microedition_media_control_VolumeControl
       
    49  * Method:    _getLevel
       
    50  * Signature: (II)I
       
    51  */
       
    52 
       
    53 JNIEXPORT int JNICALL Java_com_nokia_microedition_media_control_VolumeControl__1getLevel
       
    54 (JNIEnv *, jclass , jint aEventSource, jint aVolumeControl)
       
    55 {
       
    56     CMMAEventSource* eventSource =
       
    57         JavaUnhand< CMMAEventSource >(aEventSource);
       
    58 
       
    59     CMMAVolumeControl* volumeControl =
       
    60         JavaUnhand< CMMAVolumeControl >(aVolumeControl);
       
    61 
       
    62     TInt level(0);
       
    63     TInt error = eventSource->ExecuteTrap(&CMMAVolumeControl::StaticGetLevelL,
       
    64                                           volumeControl, &level);
       
    65     if (error == KErrNone)
       
    66     {
       
    67         return level;
       
    68     }
       
    69     return error;
       
    70 }
       
    71 
       
    72 /**
       
    73  * Local function which can be used to call CMMAVolumeControl class methods.
       
    74  *
       
    75  * @param aControl CMMAVolumeControl pointer.
       
    76  */
       
    77 LOCAL_C void SetProfileBasedMutingL(CMMAVolumeControl* aControl)
       
    78 {
       
    79     aControl->SetProfilesBasedSoundMutingL();
       
    80 }
       
    81 
       
    82 /*
       
    83  * Class:     com_nokia_microedition_media_control_VolumeControl
       
    84  * Method:    _setProfilesBasedSoundMuting
       
    85  * Signature: (I)V
       
    86  */
       
    87 
       
    88 JNIEXPORT int JNICALL Java_com_nokia_microedition_media_control_VolumeControl__1setProfilesBasedSoundMuting
       
    89 (JNIEnv *, jclass , jint aEventSource, jint aVolumeControl)
       
    90 {
       
    91     CMMAEventSource* eventSource =
       
    92         JavaUnhand< CMMAEventSource >(aEventSource);
       
    93 
       
    94     CMMAVolumeControl* volumeControl =
       
    95         JavaUnhand< CMMAVolumeControl >(aVolumeControl);
       
    96 
       
    97     TInt error = eventSource->ExecuteTrap(&SetProfileBasedMutingL,volumeControl);
       
    98     return error;
       
    99 }
       
   100 
       
   101 //  END OF FILE