upnpframework/upnpmusicadapter/inc/upnplitefiller.h
changeset 0 7f85d04be362
equal deleted inserted replaced
-1:000000000000 0:7f85d04be362
       
     1 /*
       
     2 * Copyright (c) 2005-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 #ifndef UPNPLITEFILLER_H
       
    20 #define UPNPLITEFILLER_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "upnpplaylistfiller.h"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CUpnpAVDevice;
       
    28 class CUPnPMusicAdapter;
       
    29 class CMPXMediaArray;
       
    30 class CUpnpObjectLite;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35  * A base class providing services for filling MPX playlist
       
    36  *
       
    37  * @lib upnpmusicadapter.lib
       
    38  * @since S60 3.2
       
    39  */
       
    40 class CUPnPLiteFiller : public CBase,
       
    41                         public MUPnPPlaylistFiller
       
    42     {
       
    43 
       
    44 public: // static factory construction
       
    45 
       
    46     /**
       
    47      * 1st phase constructor
       
    48      *
       
    49      * @since Series 60 3.2
       
    50      * @return a new CUPnPLiteFiller instance
       
    51      */
       
    52      static CUPnPLiteFiller* NewL();
       
    53         
       
    54     /**
       
    55      * Sets the index (starting from zero = the first inserted item)
       
    56      * of selected item. Playback will begin from the selected item.
       
    57      * If no item is selected, the first item is selected by default.
       
    58      * Note that this method must be called AFTER inserting the objects.
       
    59      *
       
    60      * @param aSelectedIndex index of the item selected
       
    61      * @since Series 60 3.2
       
    62      */
       
    63     IMPORT_C void SetSelectedIndex( TInt aSelectedIndex );
       
    64     
       
    65     /**
       
    66      * Set Source media server. Device id is needed for creating uri
       
    67      * @param aDevice source media server
       
    68      * @since Series 60 3.2
       
    69      */
       
    70     void SetSourceDeviceL( const CUpnpAVDevice& aDevice );
       
    71     
       
    72     /**
       
    73      * Sets the host for this filler
       
    74      *
       
    75      * @param aHost pointer to the music adapter in which context the
       
    76      * filler is running
       
    77      */
       
    78     void SetHost( CUPnPMusicAdapter& aHost );
       
    79 
       
    80     /**
       
    81      * The music adapter that hosts this filler
       
    82      *
       
    83      * @return the host music adapter
       
    84      */
       
    85     CUPnPMusicAdapter& Host() const;
       
    86 
       
    87     /**
       
    88      * Completes the filler, resulting it to be deleted
       
    89      */    
       
    90     void DoComplete();
       
    91 
       
    92     /**
       
    93      * See MUPnPPlaylistFiller
       
    94      */
       
    95     void FillL( CUPnPMusicAdapter& aHost, CMPXMediaArray& aPlaylist );
       
    96 
       
    97     /**
       
    98      * See MUPnPPlaylistFiller
       
    99      */
       
   100     void CancelFill();
       
   101 
       
   102     /**
       
   103      * See MUPnPPlaylistFiller
       
   104      */
       
   105     TInt PlaylistSize();
       
   106     
       
   107     /**
       
   108      * Index of selected item (where playback should start)
       
   109      *
       
   110      * @return the selected index
       
   111      */
       
   112     TInt SelectedIndex() const;
       
   113 
       
   114 public: // construction/destruction
       
   115 
       
   116     /**
       
   117      * Destructor
       
   118      * @since Series 60 3.2
       
   119      */
       
   120     IMPORT_C virtual ~CUPnPLiteFiller();
       
   121 
       
   122 public:
       
   123     /**
       
   124      * Fills a single item with given index into a mpx playlist.
       
   125      * if item is not an audio item, does not fill. Checks current
       
   126      * selected index and adjusts it if necessary.
       
   127      *
       
   128      * @param aPlaylist the MPX playlist
       
   129      * @param aItem the object to fill
       
   130      * @param aIndex playlist index of the item being added
       
   131      * @return void
       
   132      */
       
   133     void FillItemMpxPlaylistL( CMPXMediaArray& aPlaylist,
       
   134         const CUpnpObjectLite& aItem, TInt aIndex );
       
   135 
       
   136 protected:
       
   137 
       
   138     /**
       
   139      * Default constructor
       
   140      *
       
   141      * @since Series 60 3.2
       
   142      */
       
   143     CUPnPLiteFiller();
       
   144 
       
   145 private:
       
   146     /**
       
   147      * 2nd phase constructor
       
   148      *
       
   149      * @param aMediaServer External Media Server device
       
   150      * @param aObjectList Object to be filled
       
   151      * @since Series 60 3.2
       
   152      */
       
   153     void ConstructL();
       
   154     
       
   155     /**
       
   156      * Convert UPnP item to playlist item URI string
       
   157      * URI string format is upnp:<device_id>*<object_id>
       
   158      * 
       
   159      * @param aDeviceUid the UID of the device, in string form
       
   160      * @param aItem browsed UPnP item to be converted
       
   161      * @param aBuffer the buffer for result URI
       
   162      * @return playlist item descriptor
       
   163      */
       
   164     void ConvertToURI( const TDesC& aDeviceUid,
       
   165         const CUpnpObjectLite& aItem, TDes& aBuffer );
       
   166 
       
   167 private: // data
       
   168 
       
   169     /**
       
   170      * The host music adapter in which context the
       
   171      * filler is running (not owned)
       
   172      */
       
   173     CUPnPMusicAdapter*                    iHost;
       
   174 
       
   175     /**
       
   176      * The media server we are playing on (not owned)
       
   177      */
       
   178     const CUpnpAVDevice*                  iSourceDevice;
       
   179 
       
   180     /**
       
   181      * Media server device id
       
   182      * (Owned)
       
   183      */
       
   184     HBufC*                                iDeviceUid;
       
   185 
       
   186     /**
       
   187      * index of selected item
       
   188      */
       
   189     TInt                                  iSelectedIndex;
       
   190 
       
   191     /**
       
   192      * Temporary buffer for 8->16-bit conversion
       
   193      */
       
   194     TBuf<KMaxUriSize>                     iTempBuf;
       
   195 
       
   196     };
       
   197 
       
   198 #endif  // UPNPLITEFILLER_H
       
   199 
       
   200 // End of File
       
   201 
       
   202