Nokia N97 SDK
Example Applications Guide

CCEPostFilter.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : CCEPostFilter.cpp
00004 *  Part of     : Content Listing Framework Sample Application
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 
00017 // INCLUDE FILES
00018 #include "CCEPostFilter.h"
00019 
00020 #include "CLFExample.hrh"
00021 
00022 #include <MCLFContentListingEngine.h>
00023 #include <ContentListingFactory.h>
00024 #include <MCLFItem.h>
00025 #include <CLFContentListing.hrh>
00026 #include <CLFExample.rsg>
00027 
00028 // ============================ MEMBER FUNCTIONS ===============================
00029 
00030 // -----------------------------------------------------------------------------
00031 // CCEPostFilter::CCEPostFilter
00032 // C++ default constructor can NOT contain any code, that
00033 // might leave.
00034 // -----------------------------------------------------------------------------
00035 //
00036 CCEPostFilter::CCEPostFilter( const TCLFDefaultFieldId aFilterCriteria )
00037     : iFilterCriteria( aFilterCriteria )
00038     {
00039     }
00040 
00041 // -----------------------------------------------------------------------------
00042 // CCEPostFilter::ConstructL
00043 // Symbian 2nd phase constructor can leave.
00044 // -----------------------------------------------------------------------------
00045 //
00046 void CCEPostFilter::ConstructL( const TDesC& aFilterParameter )
00047     {
00048     iFilterParameter = aFilterParameter.AllocL();
00049     }
00050 
00051 // -----------------------------------------------------------------------------
00052 // CCEPostFilter::NewL
00053 // Two-phased constructor.
00054 // -----------------------------------------------------------------------------
00055 //
00056 CCEPostFilter* CCEPostFilter::NewL(
00057                             const TCLFDefaultFieldId aFilterCriteria,
00058                                 const TDesC& aFilterParameter )
00059     {
00060     CCEPostFilter* self =
00061         CCEPostFilter::NewLC( aFilterCriteria, aFilterParameter );
00062     CleanupStack::Pop( self );
00063     return self;
00064     }
00065 
00066 // -----------------------------------------------------------------------------
00067 // CCEPostFilter::NewLC
00068 // Two-phased constructor, pointer is left to the CleanupStack.
00069 // -----------------------------------------------------------------------------
00070 //
00071 CCEPostFilter* CCEPostFilter::NewLC(
00072                             const TCLFDefaultFieldId aFilterCriteria,
00073                                 const TDesC& aFilterParameter )
00074     {
00075     CCEPostFilter* self = new (ELeave) CCEPostFilter( aFilterCriteria );
00076     CleanupStack::PushL( self );
00077     self->ConstructL( aFilterParameter );
00078     return self;
00079     }
00080 
00081 // Destructor
00082 CCEPostFilter::~CCEPostFilter()
00083     {
00084     delete iFilterParameter;
00085     }
00086 
00087 // -----------------------------------------------------------------------------
00088 // CCEPostFilter::FilterItemsL
00089 // Method for filtering the source list.
00090 // -----------------------------------------------------------------------------
00091 //
00092 void CCEPostFilter::FilterItemsL( const TArray<MCLFItem*>& aItemList,
00093                                   RPointerArray<MCLFItem>& aFilteredItemList )
00094     {
00095     // Process all items in the item list
00096     TInt count( aItemList.Count() );
00097     for( TInt i = 0; i < count; ++i )
00098         {
00099         // Get value of the field defined in iFilterCriteria.
00100         // For example, if iFilterCriteria contains ECLFFieldIdAlbum,
00101         // name of the album is stored to fieldValue variable.
00102         TPtrC fieldValue;
00103         MCLFItem* currentItem = aItemList[i];
00104         TInt error( currentItem->GetField(
00105             iFilterCriteria, fieldValue ) );
00106 
00107         // Add the music file to the filtered list,
00108         // if value of of the field is same as iFilterParameter.
00109         // For example, if it is from the desired album.
00110         if( error == KErrNone )
00111             {
00112             if( fieldValue == iFilterParameter->Des() )
00113                 {
00114                 aFilteredItemList.AppendL( currentItem );
00115                 }
00116             }
00117         }
00118     }
00119 
00120 //  End of File

© Nokia 2009

Back to top