javauis/mmapi_akn/baseline/src/cmmamidimetadatacontrol.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19: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:  CMMAMIDIMetaDataControl is a concrete class for getting
       
    15 *                metadata from midi engine.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //  INCLUDE FILES
       
    21 #include <jdebug.h>
       
    22 
       
    23 #include "cmmamidimetadatacontrol.h"
       
    24 
       
    25 CMMAMIDIMetaDataControl::CMMAMIDIMetaDataControl(
       
    26     CMMAMIDIPlayer* aPlayer)
       
    27         : iPlayer(aPlayer)
       
    28 {
       
    29     DEBUG("MMA::CMMAMIDIMetaDataControl constructor called.");
       
    30 }
       
    31 
       
    32 TInt CMMAMIDIMetaDataControl::KeyCountL()
       
    33 {
       
    34     DEBUG("MMA: CMMAMIDIMetaDataControl::KeyCountL");
       
    35     TInt entries = iPlayer->MidiClient()->NumberOfMetaDataEntriesL();
       
    36     return entries;
       
    37 }
       
    38 
       
    39 HBufC* CMMAMIDIMetaDataControl::KeyL(TInt aIndex)
       
    40 {
       
    41     DEBUG("MMA: CMMAMIDIMetaDataControl::KeyL");
       
    42     CMMFMetaDataEntry* currEntry =
       
    43         iPlayer->MidiClient()->GetMetaDataEntryL(aIndex);
       
    44     CleanupStack::PushL(currEntry);
       
    45     HBufC* key = currEntry->Name().AllocL();
       
    46     CleanupStack::PopAndDestroy(); // currEntry
       
    47     return key;
       
    48 }
       
    49 
       
    50 
       
    51 /*
       
    52  * Get the value of given midi metadata key. The ownership of the created value
       
    53  * (descriptor) is passed to the caller.
       
    54  */
       
    55 HBufC* CMMAMIDIMetaDataControl::KeyValueL(const TDesC& aKey)
       
    56 {
       
    57     DEBUG("MMA: CMMAMIDIMetaDataControl::KeyValueL");
       
    58 
       
    59     HBufC* retVal = NULL;
       
    60     CMMFMetaDataEntry* currEntry = NULL;
       
    61 
       
    62     TInt nEntries = iPlayer->MidiClient()->NumberOfMetaDataEntriesL();
       
    63 
       
    64     for (TInt i = 0; i < nEntries; ++i)
       
    65     {
       
    66         currEntry = iPlayer->MidiClient()->GetMetaDataEntryL(i);
       
    67 
       
    68         if (0 == aKey.Compare(currEntry->Name()))
       
    69         {
       
    70             CleanupStack::PushL(currEntry);
       
    71             retVal = currEntry->Value().AllocL();
       
    72             CleanupStack::PopAndDestroy(); // currEntry
       
    73             break;
       
    74         }
       
    75 
       
    76         delete currEntry;
       
    77     }
       
    78 
       
    79     User::LeaveIfNull(retVal);
       
    80     return retVal;
       
    81 }
       
    82 
       
    83 //  END OF FILE