upnpframework/upnpmusicadapter/src/upnplitecontainerfiller.cpp
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 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:  Provides services for filling MPX playlist
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "upnpresultcacheui.h"
       
    21 #include "upnplitecontainerfiller.h"
       
    22 
       
    23 // debug
       
    24 _LIT16( KComponentLogfile, "musicadapter.txt" );
       
    25 #include "upnplog.h"
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KMaxPlaylistSize = 500; // MAX container size to play
       
    29 
       
    30 // METHODS
       
    31 
       
    32 // --------------------------------------------------------------------------
       
    33 // CUPnPLiteSelectionFiller::NewL
       
    34 //---------------------------------------------------------------------------
       
    35 EXPORT_C CUPnPLiteContainerFiller* CUPnPLiteContainerFiller::NewL(
       
    36     const CUpnpAVDevice& aMediaServer,
       
    37     const CUpnpResultCacheUi& aResultCache )
       
    38     {
       
    39     CUPnPLiteContainerFiller* filler = 
       
    40         new(ELeave)CUPnPLiteContainerFiller( aResultCache );
       
    41     CleanupStack::PushL( filler );
       
    42     filler->ConstructL( aMediaServer );
       
    43     CleanupStack::Pop( filler );
       
    44     return filler;
       
    45     }
       
    46 
       
    47 // --------------------------------------------------------------------------
       
    48 // CUPnPLiteContainerFiller::FillL
       
    49 // Fill track data into the playlist
       
    50 // --------------------------------------------------------------------------
       
    51 //
       
    52 void CUPnPLiteContainerFiller::FillL(
       
    53     CUPnPMusicAdapter& aHost,
       
    54     CMPXMediaArray& aPlaylist )
       
    55     {
       
    56     __LOG( "CUPnPLiteContainerFiller::FillL" );
       
    57     SetHost( aHost );
       
    58 
       
    59     TUint count = iResultCache.TotalNumberOfItems();
       
    60     for( TUint i = 0; i < count; i++ )
       
    61 	    {
       
    62 	    // Convert to mpx media and add to the playlist.
       
    63     	FillItemMpxPlaylistL( aPlaylist, *iResultCache.ItemAt(i), 0 );
       
    64     	iPlaylistActualSize++;
       
    65 	    }
       
    66 
       
    67     DoComplete();
       
    68     __LOG( "CUPnPLiteContainerFiller::FillL - End" );
       
    69     }
       
    70 
       
    71 // --------------------------------------------------------------------------
       
    72 // CUPnPLiteContainerFiller::CancelFill
       
    73 // --------------------------------------------------------------------------
       
    74 //
       
    75 void CUPnPLiteContainerFiller::CancelFill()
       
    76     {
       
    77     // no implementation required
       
    78     // - this class does not have async nature
       
    79     }
       
    80 
       
    81 // --------------------------------------------------------------------------
       
    82 // CUPnPLiteContainerFiller::PlaylistSize
       
    83 // Returns the total playlist size
       
    84 // --------------------------------------------------------------------------
       
    85 //
       
    86 TInt CUPnPLiteContainerFiller::PlaylistSize()
       
    87     {
       
    88     return iPlaylistActualSize;
       
    89     }
       
    90 
       
    91 // --------------------------------------------------------------------------
       
    92 // CUPnPLiteContainerFiller::~CUPnPLiteContainerFiller
       
    93 //---------------------------------------------------------------------------
       
    94 EXPORT_C CUPnPLiteContainerFiller::~CUPnPLiteContainerFiller()
       
    95     {
       
    96     // None.
       
    97     }
       
    98 
       
    99 // --------------------------------------------------------------------------
       
   100 // CUPnPLiteContainerFiller::CUPnPCachePlaylistFiller
       
   101 // 1st phase constructor.
       
   102 // --------------------------------------------------------------------------
       
   103 //
       
   104 CUPnPLiteContainerFiller::CUPnPLiteContainerFiller( 
       
   105     const CUpnpResultCacheUi& aResultCache )
       
   106     : iResultCache( aResultCache )
       
   107     {
       
   108     // None.
       
   109     }
       
   110 
       
   111 // --------------------------------------------------------------------------
       
   112 // CUPnPLiteContainerFiller::ConstructL
       
   113 // 2nd phase constructor.
       
   114 // --------------------------------------------------------------------------
       
   115 // 
       
   116 void CUPnPLiteContainerFiller::ConstructL( 
       
   117     const CUpnpAVDevice& aMediaServer )
       
   118     {
       
   119     __LOG( "CUPnPLiteContainerFiller::ConstructL" );
       
   120     // Set device uid
       
   121     SetSourceDeviceL( aMediaServer );
       
   122     iPlaylistActualSize = 0;
       
   123     }
       
   124 
       
   125