mtpdataproviders/mtpfileandfolderdp/src/cmtpfiledpexclusionmgr.cpp
changeset 0 d0791faffa3f
child 15 f85613f12947
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <badesca.h>
       
    17 #include <mtp/cmtpdataproviderplugin.h>
       
    18 #include <mtp/mmtpdataproviderframework.h>
       
    19 
       
    20 
       
    21 #include "cmtpfiledpexclusionmgr.h"
       
    22 #include "rmtpfiledpsingletons.h"
       
    23 #include "cmtpfiledpconfigmgr.h"
       
    24 #include "cmtpextensionmapping.h"
       
    25 #include "cmtpdataprovidercontroller.h"
       
    26 #include "cmtpdataprovider.h"
       
    27 #include "mtpframeworkconst.h"
       
    28 
       
    29 
       
    30 CMTPFileDpExclusionMgr* CMTPFileDpExclusionMgr::NewL(MMTPDataProviderFramework& aFramework)
       
    31 	{
       
    32 	CMTPFileDpExclusionMgr* self = new (ELeave) CMTPFileDpExclusionMgr(aFramework);
       
    33 	CleanupStack::PushL(self);
       
    34 	self->ConstructL();
       
    35 	CleanupStack::Pop(self);
       
    36 	return self;
       
    37 	}
       
    38 	
       
    39 CMTPFileDpExclusionMgr::CMTPFileDpExclusionMgr(MMTPDataProviderFramework& aFramework) :
       
    40 	CMTPFSExclusionMgr(aFramework)
       
    41 	{
       
    42 	}
       
    43 	
       
    44 void CMTPFileDpExclusionMgr::ConstructL()
       
    45 	{
       
    46     iFrameworkSingletons.OpenL();
       
    47 
       
    48     RMTPFileDpSingletons singletons;
       
    49     singletons.OpenL(iFramework);
       
    50     CleanupClosePushL(singletons);
       
    51     singletons.FrameworkConfig().GetArrayValueL(CMTPFileDpConfigMgr::EFormatExclusionList, iExcludedFormats);
       
    52     CleanupStack::PopAndDestroy(&singletons);
       
    53     iDpSingletons.OpenL(iFramework);
       
    54 
       
    55 	}
       
    56 	
       
    57 CMTPFileDpExclusionMgr::~CMTPFileDpExclusionMgr()
       
    58     {
       
    59     iExcludedFormats.Close();
       
    60     iFrameworkSingletons.Close();
       
    61     iDpSingletons.Close();
       
    62 
       
    63     }
       
    64 		
       
    65 TBool CMTPFileDpExclusionMgr::IsFormatValid(TMTPFormatCode aFormat) const
       
    66 	{
       
    67 	TInt found = iExcludedFormats.FindInOrder(aFormat);
       
    68 	return (found == KErrNotFound);
       
    69 	}
       
    70 
       
    71 TBool CMTPFileDpExclusionMgr::IsExtensionValid(const TDesC& aPath) const
       
    72 	{
       
    73 	return IsFormatValid(iDpSingletons.MTPUtility().GetFormatByExtension(aPath));
       
    74 	}
       
    75 
       
    76 //Append all DPs format exclusion list strings in File DP
       
    77 void CMTPFileDpExclusionMgr::AppendFormatExclusionListL()
       
    78     {
       
    79     CMTPDataProviderController& dps(iFrameworkSingletons.DpController());
       
    80     TUint count = dps.Count();
       
    81     TUint currentDpIndex = 0, formatcode = 0;
       
    82     RArray<TUint> capFormatExclusionList;
       
    83     RArray<TUint> playbackFormatExclusionList;
       
    84     CleanupClosePushL(capFormatExclusionList);
       
    85     CleanupClosePushL(playbackFormatExclusionList);
       
    86     while (currentDpIndex < count)
       
    87         {
       
    88         CMTPDataProvider& dp(dps.DataProviderByIndexL(currentDpIndex));
       
    89         if(KMTPImplementationUidFileDp != dp.ImplementationUid().iUid)
       
    90             {	  		
       
    91             dp.Plugin().Supported(EObjectCaptureFormats, capFormatExclusionList);
       
    92             dp.Plugin().Supported(EObjectPlaybackFormats, playbackFormatExclusionList);
       
    93             capFormatExclusionList.Sort();
       
    94             for(TInt index = 0; index < playbackFormatExclusionList.Count(); ++index)
       
    95                 {
       
    96                 formatcode = playbackFormatExclusionList[index];
       
    97                 if(KErrNotFound == capFormatExclusionList.FindInOrder(formatcode))
       
    98                     {
       
    99                     capFormatExclusionList.InsertInOrder(formatcode);
       
   100                     }
       
   101                 }
       
   102 
       
   103             //Append all DPs format exclusion list in File DP
       
   104             for (TInt i = 0; i < capFormatExclusionList.Count(); ++i)
       
   105                 {
       
   106                 iExcludedFormats.InsertInOrder(capFormatExclusionList[i]);
       
   107                 }
       
   108             }
       
   109         currentDpIndex++;
       
   110         }
       
   111     CleanupStack::PopAndDestroy(&playbackFormatExclusionList);
       
   112     CleanupStack::PopAndDestroy(&capFormatExclusionList);
       
   113     }