javauis/mmapi_akn/baseline/src/metadatacontrol.cpp
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2002 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 CMMAMetaDataControl
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <jdebug.h>
       
    20 #include "com_nokia_microedition_media_control_MetaDataControl.h"
       
    21 
       
    22 #include "cmmaeventsource.h"
       
    23 #include "cmmametadatacontrol.h"
       
    24 
       
    25 
       
    26 /* ...getKeyCount
       
    27  *
       
    28  * Returns the number of metadata keys or symbian error code
       
    29  */
       
    30 
       
    31 JNIEXPORT jint JNICALL Java_com_nokia_microedition_media_control_MetaDataControl__1getKeysCount
       
    32 (JNIEnv* /*aJniEnv*/, jobject, jint aEventSourceHandle, jint aMetaDataControlHandle)
       
    33 {
       
    34     CMMAEventSource* eventSource =
       
    35         JavaUnhand< CMMAEventSource >(aEventSourceHandle);
       
    36 
       
    37     CMMAMetaDataControl* metaDataControl =
       
    38         JavaUnhand< CMMAMetaDataControl >(aMetaDataControlHandle);
       
    39 
       
    40     TInt keys;
       
    41     TInt err = eventSource->ExecuteTrap(&CMMAMetaDataControl::StaticKeysCountL, metaDataControl, &keys);
       
    42 
       
    43     return err == KErrNone ? keys : err;
       
    44 }
       
    45 
       
    46 
       
    47 /* ... getKey
       
    48  *
       
    49  * Get the key name at the given index from the actual native implementation. If no key is available,
       
    50  * return null.
       
    51  *
       
    52  * The ownership of the native data is received from the actual native implementation.
       
    53  * The data is duplicated to the Java side and the native data is destroyed here.
       
    54  */
       
    55 
       
    56 JNIEXPORT jstring JNICALL Java_com_nokia_microedition_media_control_MetaDataControl__1getKey
       
    57 (JNIEnv* aJniEnv, jobject, jint aEventSourceHandle, jint aMetaDataControlHandle, jint aIndex)
       
    58 {
       
    59     CMMAEventSource* eventSource =
       
    60         JavaUnhand< CMMAEventSource >(aEventSourceHandle);
       
    61 
       
    62     CMMAMetaDataControl* metaDataControl =
       
    63         JavaUnhand< CMMAMetaDataControl >(aMetaDataControlHandle);
       
    64 
       
    65     HBufC* key = NULL;
       
    66     jstring javaStr = NULL;
       
    67 
       
    68     TInt err = eventSource->ExecuteTrap(&CMMAMetaDataControl::StaticKeyL, metaDataControl, &key, aIndex);
       
    69 
       
    70     if (err == KErrNone)
       
    71     {
       
    72         javaStr = CreateJavaString(*aJniEnv, key->Des());
       
    73     }
       
    74     delete key;
       
    75 
       
    76     return javaStr;
       
    77 }
       
    78 
       
    79 /* ...getKeyValue
       
    80  *
       
    81  * Get the value of the given key from the actual native implementation. If no key is available,
       
    82  * return null (as specified in the MetaDataControl interface).
       
    83  *
       
    84  * The ownership of the native data is received from the actual native implementation.
       
    85  * The data is duplicated to the Java side and the native data is destroyed here.
       
    86  */
       
    87 
       
    88 JNIEXPORT jstring JNICALL Java_com_nokia_microedition_media_control_MetaDataControl__1getKeyValue
       
    89 (JNIEnv* aJniEnv, jobject, jint aEventSourceHandle, jint aMetaDataControlHandle, jstring aKey)
       
    90 {
       
    91     CMMAEventSource* eventSource =
       
    92         JavaUnhand< CMMAEventSource >(aEventSourceHandle);
       
    93 
       
    94     CMMAMetaDataControl* metaDataControl =
       
    95         JavaUnhand< CMMAMetaDataControl >(aMetaDataControlHandle);
       
    96 
       
    97     HBufC* value = NULL;
       
    98     RJString key(*aJniEnv, aKey);
       
    99 
       
   100     TInt retVal = eventSource->ExecuteTrap(
       
   101                       &CMMAMetaDataControl::StaticKeyValueL,
       
   102                       metaDataControl,
       
   103                       &value,
       
   104                       (TDesC*) &key);
       
   105 
       
   106     jstring retString = NULL;
       
   107 
       
   108     if (KErrNone == retVal)
       
   109     {
       
   110         retString = CreateJavaString(*aJniEnv, *value);
       
   111     }
       
   112 
       
   113     delete value;
       
   114 
       
   115     return retString;
       
   116 }
       
   117 
       
   118 //  END OF FILE