profilesservices/ProfileEngine/WrapperSrc/CProEngPostFilter.cpp
changeset 0 8c5d936e5675
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     1 /*
       
     2 * Copyright (c) 2005 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: Implementation of CProEngPostFilter.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CProEngPostFilter.h"
       
    22 
       
    23 #include <MCLFItem.h>
       
    24 #include "CProEngMediaVariation.h"
       
    25 #include "CProEngDrmCommonWrapper.h"
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CProEngPostFilter::CProEngPostFilter
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CProEngPostFilter::CProEngPostFilter()
       
    36     {
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CProEngPostFilter::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void CProEngPostFilter::ConstructL()
       
    45     {
       
    46     iMediaVariation = CProEngMediaVariation::NewL();
       
    47     iDrmWrapper = CProEngDrmCommonWrapper::NewL();
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------------------------
       
    51 // CProEngPostFilter::NewL
       
    52 // Two-phased constructor.
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CProEngPostFilter* CProEngPostFilter::NewL()
       
    56     {
       
    57     CProEngPostFilter* self = new (ELeave) CProEngPostFilter();
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop( self );
       
    61     return self;
       
    62     }
       
    63 
       
    64 // Destructor
       
    65 CProEngPostFilter::~CProEngPostFilter()
       
    66     {
       
    67     delete iDrmWrapper;
       
    68     delete iMediaVariation;
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CProEngPostFilter::FilterItemsL
       
    73 // Method for filtering the source list.
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void CProEngPostFilter::FilterItemsL( const TArray<MCLFItem*>& aItemList,
       
    77                                   RPointerArray<MCLFItem>& aFilteredItemList )
       
    78     {
       
    79     // Process all items in the item list
       
    80     TInt count( aItemList.Count() );
       
    81     for( TInt i = 0; i < count; i++ )
       
    82         {
       
    83         MCLFItem* currentItem = aItemList[i];
       
    84         // Get the path of the media file from the item
       
    85         TPtrC fileNameAndPath;
       
    86         TInt error( currentItem->GetField( ECLFFieldIdFileNameAndPath,
       
    87                                        fileNameAndPath ) );
       
    88         
       
    89         // Add the alert tone file to the filtered list,
       
    90         // if it is OK according to the Media variation
       
    91         if( error == KErrNone )
       
    92             {
       
    93             TBuf< KMaxDataTypeLength > dataType;
       
    94             iMediaVariation->GetDataTypeL( fileNameAndPath, dataType );
       
    95             TBool isSupported( iMediaVariation->IsSupported( dataType ) );
       
    96             TBool isProtected( iDrmWrapper->IsProtected( fileNameAndPath ) );
       
    97             if( ( isProtected &&
       
    98                   iMediaVariation->IsAllowedProtected( dataType ) ) ||
       
    99                 ( !isProtected &&
       
   100                      iMediaVariation->IsAllowedUnProtected( dataType ) ) )
       
   101                 {
       
   102                 aFilteredItemList.AppendL( currentItem );
       
   103                 }
       
   104             }
       
   105         }
       
   106     }
       
   107 
       
   108 //  End of File
       
   109