photosgallery/viewframework/commandhandlers/commandhandlerbase/src/glxmedialistcommandhandler.cpp
changeset 0 4e91876724a2
child 14 ce1c7ad1f18b
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Media List Command Handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <e32base.h>
       
    22 
       
    23 #include "glxmedialistcommandhandler.h"
       
    24 
       
    25 #include <eikprogi.h>
       
    26 #include <mpxmediageneraldefs.h>
       
    27 #include <mpxmediadrmdefs.h>
       
    28 #include <mpxmessagegeneraldefs.h>
       
    29 #include <mpxmessageprogressdefs.h>
       
    30 #include <StringLoader.h>
       
    31 
       
    32 #include <glxattributecontext.h>
       
    33 #include <glxattributeretriever.h>
       
    34 #include <glxfetchcontextremover.h>
       
    35 #include <glxgeneraluiutilities.h>
       
    36 #include <glxuiutility.h>
       
    37 #include <glxmediageneraldefs.h>
       
    38 #include <glxuistd.h>
       
    39 #include <mglxmedialist.h>
       
    40 #include <glxcommandhandlers.hrh>
       
    41 
       
    42 #include "mglxmedialistprovider.h"
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // Constructor for command info
       
    46 // -----------------------------------------------------------------------------
       
    47 //	
       
    48 EXPORT_C CGlxMediaListCommandHandler::TCommandInfo::TCommandInfo(TInt aCommandId) 
       
    49     {
       
    50     // Set command id 
       
    51     iCommandId = aCommandId;
       
    52 
       
    53     // Do not stop animation before execution
       
    54     iStopAnimationForExecution = EFalse;
       
    55 
       
    56     // Disable for system items
       
    57     iDisallowSystemItems = EFalse;
       
    58 
       
    59     // Disable for DRM protected items
       
    60     iDisallowDRM = EFalse;
       
    61 
       
    62     // Set selection length requirement so that it does not filter
       
    63     iMinSelectionLength = 0;
       
    64     iMaxSelectionLength = KMaxTInt;
       
    65 
       
    66     // default minimum item count
       
    67     iMinSlideshowPlayableContainedItemCount = 0;
       
    68 
       
    69     // Disable for animated GIFs
       
    70     iDisallowAnimatedGIFs = EFalse;
       
    71 
       
    72     // Default item category is "none"
       
    73     iCategoryFilter = EMPXNoCategory;    
       
    74 
       
    75     // Don't apply category filter
       
    76     iCategoryRule = EIgnore;
       
    77     
       
    78     // Set the default viewing state
       
    79     iViewingState = EViewingStateUndefined;
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // Constructor
       
    84 // -----------------------------------------------------------------------------
       
    85 //	
       
    86 EXPORT_C CGlxMediaListCommandHandler::CGlxMediaListCommandHandler(
       
    87 	MGlxMediaListProvider* aMediaListProvider,
       
    88 	TBool aHasToolbarItem):CGlxCommandHandler(aHasToolbarItem)
       
    89 	{
       
    90 	iMediaListProvider = aMediaListProvider;
       
    91 	iCurrentViewingState = TCommandInfo::EViewingStateUndefined;
       
    92 	}
       
    93 	
       
    94 // -----------------------------------------------------------------------------
       
    95 // Destructor
       
    96 // -----------------------------------------------------------------------------
       
    97 //	
       
    98 EXPORT_C CGlxMediaListCommandHandler::~CGlxMediaListCommandHandler()
       
    99 	{
       
   100 	iCommandInfoArray.Reset();
       
   101 	}
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // ExecuteL
       
   105 // -----------------------------------------------------------------------------
       
   106 //	
       
   107 EXPORT_C TBool CGlxMediaListCommandHandler::ExecuteL(TInt aCommandId)
       
   108     {
       
   109     TBool consume = EFalse;
       
   110     
       
   111     switch (aCommandId)
       
   112         {
       
   113         case EGlxCmdStateBrowse:
       
   114             iCurrentViewingState = TCommandInfo::EViewingStateBrowse;
       
   115             break;
       
   116             
       
   117         case EGlxCmdStateView:
       
   118             iCurrentViewingState = TCommandInfo::EViewingStateView;
       
   119             break;
       
   120 
       
   121         default:                    // Do nothing
       
   122             break;
       
   123         }
       
   124     /// @todo Consume the state command. This requires changing derived classes so that they do not 
       
   125     /// receive the state commands, but use the TCommandInfo filtering for state. Too risky change
       
   126     /// to do for inc6.1.
       
   127         
       
   128     if ( BypassFiltersForExecute() )
       
   129         {
       
   130         MGlxMediaList& list = MediaList();
       
   131         
       
   132         consume = DoExecuteL(aCommandId, list);
       
   133         }
       
   134     else
       
   135         {
       
   136         // Is this command handled by this command handler
       
   137         if ( IsSupported( aCommandId ) )
       
   138             {
       
   139             MGlxMediaList& list = MediaList();
       
   140             
       
   141             // Do not consume if the command is disabled
       
   142             if ( !IsDisabledL(aCommandId, list) )
       
   143                 {
       
   144                 // Ask deriving class to execute
       
   145                 consume = DoExecuteL(aCommandId, list);
       
   146                 }
       
   147             }
       
   148         }
       
   149         
       
   150     return consume;
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // DynInitMenuPaneL
       
   155 // -----------------------------------------------------------------------------
       
   156 //	
       
   157 EXPORT_C void CGlxMediaListCommandHandler::DynInitMenuPaneL(TInt aResourceId, 
       
   158         CEikMenuPane* aMenuPane)
       
   159 	{
       
   160 	if ( aMenuPane )
       
   161 	    {
       
   162 	    if ( BypassFiltersForMenu() )
       
   163 	        {
       
   164 			DoDynInitMenuPaneL(aResourceId, aMenuPane);
       
   165 	        }
       
   166 	    else
       
   167 	        {
       
   168     		TInt num_items = aMenuPane->NumberOfItemsInPane();
       
   169     		TBool atLeastOneEnabledSupportedItem = EFalse;
       
   170     		
       
   171     		//CGlxUiUtility* uiUtility  = CGlxUiUtility::UtilityL();
       
   172             //CleanupClosePushL(*uiUtility);
       
   173             
       
   174     		// Iterate through menu pane
       
   175     		for ( TInt i = 0; i < num_items; i++)
       
   176     			{
       
   177     			CEikMenuPaneItem::SData& item = aMenuPane->ItemDataByIndexL(i);
       
   178 
       
   179         	    // Check if the menu command is know to this command handler
       
   180         	    if ( IsSupported( item.iCommandId ) )
       
   181         	        {
       
   182         	        TBool isDisabled = IsDisabledL(item.iCommandId, MediaList());
       
   183         	        
       
   184         	        if( !isDisabled && 
       
   185         	            iCurrentViewingState == TCommandInfo::EViewingStateView )
       
   186         	            {
       
   187                         //isDisabled = sf.IsActivePaletteItemVisible( item.iCommandId );
       
   188         	            }
       
   189         	        // Check visibility of the menu item
       
   190     				aMenuPane->SetItemDimmed( item.iCommandId, isDisabled);
       
   191     				
       
   192     				atLeastOneEnabledSupportedItem = atLeastOneEnabledSupportedItem || (!isDisabled);
       
   193         	        }
       
   194     			}
       
   195     			
       
   196     	   // CleanupStack::PopAndDestroy(uiUtility);
       
   197     			
       
   198     	    if ( atLeastOneEnabledSupportedItem )
       
   199     	        {
       
   200     			DoDynInitMenuPaneL(aResourceId, aMenuPane);
       
   201     			}
       
   202     	    }
       
   203 	    }
       
   204 	}
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // ActivateL
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 EXPORT_C void CGlxMediaListCommandHandler::DoActivateL(TInt /*aViewId*/)
       
   211     {
       
   212     
       
   213     }
       
   214 	
       
   215 // ---------------------------------------------------------------------------
       
   216 // Default implementation does nothing
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 EXPORT_C void CGlxMediaListCommandHandler::Deactivate()
       
   220     {
       
   221     // Do nothing
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // OfferKeyEventL
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 EXPORT_C TKeyResponse CGlxMediaListCommandHandler::OfferKeyEventL(
       
   229         const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/)
       
   230     {
       
   231     return EKeyWasNotConsumed;
       
   232     }
       
   233     
       
   234 // ---------------------------------------------------------------------------
       
   235 // PreDynInitMenuPaneL
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 EXPORT_C void CGlxMediaListCommandHandler::PreDynInitMenuPaneL( TInt /*aResourceId*/ )
       
   239     {
       
   240     // No implementation
       
   241     }
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // CGlxMediaListCommandHandler::GetRequiredAttributesL
       
   245 // ---------------------------------------------------------------------------
       
   246 //
       
   247 EXPORT_C void CGlxMediaListCommandHandler::GetRequiredAttributesL(
       
   248 		                            RArray< TMPXAttribute >& aAttributes, 
       
   249             		                TBool aFilterUsingSelection, 
       
   250             		                TBool aFilterUsingCommandId,
       
   251                                     TInt aCommandId) const
       
   252     {
       
   253     if (!aFilterUsingCommandId || IsSupported(aCommandId))
       
   254     	{
       
   255     	GetRequiredAttributesL(aAttributes, aFilterUsingSelection);
       
   256     	}
       
   257     }
       
   258     
       
   259 // -----------------------------------------------------------------------------
       
   260 // Check if command is currently disabled
       
   261 // -----------------------------------------------------------------------------
       
   262 //	
       
   263 EXPORT_C TBool CGlxMediaListCommandHandler::IsDisabledL(TInt aCommandId, 
       
   264         MGlxMediaList& aMediaList) const 
       
   265     {
       
   266     __ASSERT_DEBUG(IsSupported(aCommandId), Panic(EGlxPanicIllegalArgument));
       
   267     const TCommandInfo& info = CommandInfo(aCommandId);
       
   268     
       
   269     // Perform expensive checks only if necessary
       
   270     TBool isDisabled = IsDisabled(info);
       
   271     
       
   272     if (!isDisabled)
       
   273         {
       
   274         	/** 
       
   275             * The disabling check must be done so that we go through the selection 
       
   276             * and check each item separately against all filter rules.
       
   277             *
       
   278             * There can for example be a filter that does not allow system items, 
       
   279             * anim gifs or videos. Now if the selection contains 10 items and 3 of 
       
   280             * them are system items, 4 are anim gifs and 3 are videos we need to disable the 
       
   281             * command. If that selection contained 1 "normal" image we must enable
       
   282             * the command accordingly.
       
   283             */
       
   284 	        // assume this item is not disabled
       
   285 	        
       
   286     
       
   287 	        // Check through all selected items, if no selection then the focused item
       
   288             TGlxSelectionIterator iterator;
       
   289             iterator.SetToFirst( &aMediaList );
       
   290             // Loop until iterator does not give any more indexes 
       
   291             TInt index = KErrNotFound;
       
   292             while ( KErrNotFound != (index = iterator++ ) )
       
   293                 {
       
   294                 // get the media item
       
   295                 const TGlxMedia& item = aMediaList.Item( index );
       
   296 
       
   297                 // check category rule first
       
   298                 TMPXGeneralCategory cat = item.Category();
       
   299                 if( ( TCommandInfo::EIgnore != info.iCategoryRule )&&
       
   300                     ( cat != EMPXNoCategory ) )
       
   301                     {
       
   302                     // get category attribute
       
   303                     // did we want to deny all items of this type
       
   304                     if( TCommandInfo::EForbidAll == info.iCategoryRule )
       
   305                         {
       
   306                         // disable if the category was same
       
   307                         isDisabled = (info.iCategoryFilter == cat);
       
   308                         }
       
   309                     else
       
   310                         {
       
   311                         // assign the value
       
   312                         isDisabled = info.iCategoryFilter != cat;
       
   313                         // disable if the category was not same
       
   314                         if( isDisabled )
       
   315                             {
       
   316                             // we found first that is not same so end the loop
       
   317                             break;
       
   318                             }
       
   319                         }
       
   320                     }
       
   321                 // Check system item if not yet disabled by previous rules
       
   322                 TBool isSystemItem = EFalse;
       
   323                 if( ( !isDisabled )&&( info.iDisallowSystemItems )&&
       
   324                     ( item.GetSystemItem(isSystemItem) ) )
       
   325                     {
       
   326                     // disable if this was system item
       
   327                     isDisabled = isSystemItem;
       
   328                     }
       
   329                 // Check DRM if not yet disabled by previous rules
       
   330                 if( (!isDisabled )&&( info.iDisallowDRM ) )
       
   331                     {
       
   332                     // disable if DRM protected
       
   333                     isDisabled = item.IsDrmProtected();
       
   334                     }
       
   335                 // Check animated GIF if not yet disabled by previous rules
       
   336                 TInt frameCount(0);
       
   337                 if( ( !isDisabled )&&( info.iDisallowAnimatedGIFs )&&
       
   338                     ( item.GetFrameCount(frameCount) ) )
       
   339                     {
       
   340                     // disable if framecount is greater than one
       
   341                     isDisabled = ( 1 < frameCount );
       
   342                     }
       
   343                 // Check minimum item count if not yet disabled by previous rules
       
   344                 TInt count(0);
       
   345                 if( ( !isDisabled )&&( info.iMinSlideshowPlayableContainedItemCount )&&
       
   346                     ( item.GetSlideshowPlayableContainedItemCount(count) ) )
       
   347                     {
       
   348                     // disable if less than required amount of items in container (ignore non-containers, i.e. -1)
       
   349                     if( count != -1 )
       
   350                         {
       
   351                         isDisabled = ( count < info.iMinSlideshowPlayableContainedItemCount );
       
   352                         }
       
   353                     }
       
   354                 // when we find the first item for which the command is not disabled
       
   355                 // we can end the loop unless the category rule states we need to check them all
       
   356                 if( ( !isDisabled )&&( TCommandInfo::ERequireAll != info.iCategoryRule ) )
       
   357                     {
       
   358                     // this is the exit of the loop in case there is an item to enable for
       
   359                     break;
       
   360                     }
       
   361                 }
       
   362 
       
   363             // Check deriving class if we are still not disabled
       
   364             if ( !isDisabled )
       
   365                 {
       
   366                 isDisabled = DoIsDisabled( aCommandId, aMediaList );
       
   367                 }
       
   368             }
       
   369     return isDisabled;
       
   370     }
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // MediaList
       
   374 // -----------------------------------------------------------------------------
       
   375 //	
       
   376 EXPORT_C MGlxMediaList& CGlxMediaListCommandHandler::MediaList()
       
   377 	{
       
   378 	return iMediaListProvider->MediaList();
       
   379 	}
       
   380 	
       
   381 // -----------------------------------------------------------------------------
       
   382 // MediaList
       
   383 // -----------------------------------------------------------------------------
       
   384 //	
       
   385 EXPORT_C const MGlxMediaList& CGlxMediaListCommandHandler::MediaList() const
       
   386 	{
       
   387 	return const_cast<CGlxMediaListCommandHandler*>(this)->MediaList();
       
   388 	//return iMediaListProvider->MediaList();
       
   389 	}
       
   390 
       
   391 // -----------------------------------------------------------------------------
       
   392 // Default implementation of elaborate filtering returns EFalse for "not disabled"
       
   393 // -----------------------------------------------------------------------------
       
   394 //
       
   395 EXPORT_C TBool CGlxMediaListCommandHandler::DoIsDisabled(TInt /*aCommandId*/, 
       
   396         MGlxMediaList& /*aList*/) const
       
   397     {
       
   398     return EFalse;
       
   399     }
       
   400     
       
   401 // -----------------------------------------------------------------------------
       
   402 // Return selection length. Length is zero if static item is focused
       
   403 // -----------------------------------------------------------------------------
       
   404 //
       
   405 EXPORT_C TInt CGlxMediaListCommandHandler::SelectionLength() const
       
   406     {
       
   407     const MGlxMediaList& ml = MediaList();
       
   408     
       
   409     TInt selectionLength = ml.SelectionCount();
       
   410 
       
   411     // If there is no selection, treat the focused item as selected, unless
       
   412     // it is a static item
       
   413     if ( 0 == selectionLength )
       
   414         {
       
   415         if (ml.Count() > 0) 
       
   416             {
       
   417             // see if item is a static item
       
   418             // get focussed item
       
   419             const TGlxMedia&  item = ml.Item(ml.FocusIndex());
       
   420             if(!item.IsStatic())
       
   421                 {
       
   422                 // not static item - set selection length to 1
       
   423                 selectionLength = 1;
       
   424                 }
       
   425             }
       
   426         }
       
   427 
       
   428     return selectionLength;
       
   429     }
       
   430     
       
   431 // -----------------------------------------------------------------------------
       
   432 // Add the command to command array
       
   433 // -----------------------------------------------------------------------------
       
   434 //	
       
   435 EXPORT_C void CGlxMediaListCommandHandler::AddCommandL(
       
   436         const CGlxMediaListCommandHandler::TCommandInfo& aCommand)
       
   437 	{
       
   438 	// Make sure command not already added
       
   439 	__ASSERT_DEBUG(!IsSupported(aCommand.iCommandId), Panic(EGlxPanicAlreadyAdded));
       
   440 
       
   441 	// This function is rarely called, so copying the object should be ok
       
   442 	iCommandInfoArray.AppendL(aCommand);
       
   443 	}
       
   444 
       
   445 // -----------------------------------------------------------------------------
       
   446 // Return index of command info by command id
       
   447 // -----------------------------------------------------------------------------
       
   448 //	
       
   449 EXPORT_C TInt CGlxMediaListCommandHandler::CommandInfoIndex(TInt aCommandId) const
       
   450 	{
       
   451 	// Find the index of the command
       
   452 	TInt index = KErrNotFound;
       
   453     TInt count = iCommandInfoArray.Count();
       
   454     for (TInt i = 0; i < count; i++)
       
   455         {
       
   456         if (iCommandInfoArray[i].iCommandId == aCommandId)
       
   457             {
       
   458             index = i;
       
   459             break;
       
   460             }
       
   461         }
       
   462         
       
   463     return index;
       
   464 	}
       
   465 
       
   466 
       
   467 // -----------------------------------------------------------------------------
       
   468 // DoDynInitMenuPaneL
       
   469 // -----------------------------------------------------------------------------
       
   470 //	
       
   471 EXPORT_C void CGlxMediaListCommandHandler::DoDynInitMenuPaneL(TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/)
       
   472     {
       
   473     // No implementation by default
       
   474     }
       
   475 
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // Return command info by id
       
   479 // -----------------------------------------------------------------------------
       
   480 //	 
       
   481 EXPORT_C CGlxMediaListCommandHandler::TCommandInfo& 
       
   482         CGlxMediaListCommandHandler::CommandInfo(TInt aCommandId)  
       
   483     {
       
   484     // Assuming the deriving class knows the command ids it supports
       
   485     __ASSERT_DEBUG(IsSupported(aCommandId), Panic(EGlxPanicIllegalArgument));
       
   486     return iCommandInfoArray[CommandInfoIndex(aCommandId)];
       
   487     }
       
   488 
       
   489 // -----------------------------------------------------------------------------
       
   490 // Return command info by id
       
   491 // -----------------------------------------------------------------------------
       
   492 //	 
       
   493 const CGlxMediaListCommandHandler::TCommandInfo& 
       
   494         CGlxMediaListCommandHandler::CommandInfo(TInt aCommandId) const
       
   495     {
       
   496     // Assuming the deriving class knows the command ids it supports
       
   497     __ASSERT_DEBUG(IsSupported(aCommandId), Panic(EGlxPanicIllegalArgument));
       
   498     return iCommandInfoArray[CommandInfoIndex(aCommandId)];
       
   499     }
       
   500     
       
   501 // -----------------------------------------------------------------------------
       
   502 // return ETrue if command is handled by this command handler
       
   503 // -----------------------------------------------------------------------------
       
   504 //	
       
   505 EXPORT_C TBool CGlxMediaListCommandHandler::IsSupported(TInt aCommandId) const
       
   506     {
       
   507     return CommandInfoIndex(aCommandId) != KErrNotFound;
       
   508     }
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // BypassFiltersForExecute
       
   512 // -----------------------------------------------------------------------------
       
   513 //	
       
   514 EXPORT_C TBool CGlxMediaListCommandHandler::BypassFiltersForExecute() const
       
   515     {
       
   516     // Return false by default: should only return true in special circumstances
       
   517     return EFalse;
       
   518     }
       
   519 
       
   520 // -----------------------------------------------------------------------------
       
   521 // CGlxMediaListCommandHandler::DoGetRequiredAttributesL
       
   522 // -----------------------------------------------------------------------------
       
   523 //	
       
   524 EXPORT_C void CGlxMediaListCommandHandler::
       
   525         DoGetRequiredAttributesL( RArray<TMPXAttribute>& /*aAttributes*/, TBool /*aFilterUsingSelection*/) const
       
   526     {
       
   527     // No implementation required
       
   528     }
       
   529 
       
   530 // -----------------------------------------------------------------------------
       
   531 // BypassFiltersForMenu
       
   532 // -----------------------------------------------------------------------------
       
   533 //	
       
   534 EXPORT_C TBool CGlxMediaListCommandHandler::BypassFiltersForMenu() const
       
   535     {
       
   536     // Return false by default: should only return true in special circumstances
       
   537     return EFalse;
       
   538     }
       
   539             		                
       
   540 // -----------------------------------------------------------------------------
       
   541 // ViewingState
       
   542 // -----------------------------------------------------------------------------
       
   543 //	
       
   544 EXPORT_C CGlxMediaListCommandHandler::TCommandInfo::TViewingState
       
   545 						CGlxMediaListCommandHandler::ViewingState() const
       
   546     {
       
   547     return iCurrentViewingState;
       
   548     }
       
   549 
       
   550 // -----------------------------------------------------------------------------
       
   551 // IsViewable
       
   552 // -----------------------------------------------------------------------------
       
   553 //	
       
   554 TBool CGlxMediaListCommandHandler::IsViewable(const TCommandInfo& aInfo) const
       
   555     {
       
   556     return aInfo.iViewingState & iCurrentViewingState;
       
   557     }
       
   558 
       
   559 // -----------------------------------------------------------------------------
       
   560 // CGlxMediaListCommandHandler::IsDisabled
       
   561 // -----------------------------------------------------------------------------
       
   562 //	
       
   563 TBool CGlxMediaListCommandHandler::IsDisabled(const TCommandInfo& aInfo) const
       
   564 	{
       
   565     // Check selection length validitity first, because it is a very fast check,
       
   566     // and covers so many situations
       
   567     TInt selectionLength = SelectionLength();
       
   568     return (selectionLength < aInfo.iMinSelectionLength ||
       
   569                        selectionLength > aInfo.iMaxSelectionLength) ||
       
   570                        !IsViewable(aInfo);
       
   571 
       
   572 	}
       
   573 
       
   574 // ---------------------------------------------------------------------------
       
   575 // CGlxMediaListCommandHandler::GetRequiredAttributesL
       
   576 // ---------------------------------------------------------------------------
       
   577 //
       
   578 void CGlxMediaListCommandHandler::GetRequiredAttributesL(
       
   579 		                            RArray< TMPXAttribute >& aAttributes, 
       
   580             		                TBool aFilterUsingSelection) const
       
   581 	{
       
   582     // Check selection length validitity first, because it is a very fast check,
       
   583     // and covers so many situations
       
   584 
       
   585     
       
   586     TInt commandCount = iCommandInfoArray.Count();
       
   587     
       
   588     TBool requireMediaGeneralCategory = EFalse;
       
   589     TBool requireMediaDrmProtected = EFalse;
       
   590     TBool requireMediaGeneralSystemItem = EFalse;
       
   591     TBool requireMediaGeneralFramecount = EFalse;
       
   592     TBool requireMediaGeneralSlideshowableContent = EFalse;
       
   593     
       
   594     for (TInt i = 0; i < commandCount; i++)
       
   595         {
       
   596         
       
   597         if (aFilterUsingSelection && IsDisabled(iCommandInfoArray[i]))
       
   598         	{
       
   599         	continue; // No need to add attributes if we already know that the command handler is disabled.
       
   600         	}
       
   601         
       
   602         // request category if matters
       
   603         if (TCommandInfo::EIgnore != iCommandInfoArray[i].iCategoryRule)
       
   604         	{
       
   605         	requireMediaGeneralCategory = ETrue;
       
   606         	}
       
   607         
       
   608         // request drm info if matters
       
   609         if (iCommandInfoArray[i].iDisallowDRM)
       
   610             {
       
   611             requireMediaDrmProtected = ETrue;
       
   612             }
       
   613     	
       
   614         // request system item info if matters
       
   615         if (iCommandInfoArray[i].iDisallowSystemItems)
       
   616             {
       
   617             requireMediaGeneralSystemItem = ETrue;
       
   618             }
       
   619         
       
   620         // request animated GIFs if matters
       
   621         if (iCommandInfoArray[i].iDisallowAnimatedGIFs )
       
   622             {
       
   623             requireMediaGeneralFramecount = ETrue;
       
   624             }
       
   625 
       
   626         // request item count if this filter is specified
       
   627         if (iCommandInfoArray[i].iMinSlideshowPlayableContainedItemCount )
       
   628             {
       
   629             requireMediaGeneralSlideshowableContent = ETrue;
       
   630             }
       
   631         }
       
   632     
       
   633     if (requireMediaGeneralCategory)
       
   634         {
       
   635         aAttributes.AppendL(KMPXMediaGeneralCategory);
       
   636         }
       
   637     
       
   638     if (requireMediaDrmProtected)
       
   639         {
       
   640         aAttributes.AppendL(KMPXMediaDrmProtected);
       
   641         }
       
   642     
       
   643     if (requireMediaGeneralSystemItem)
       
   644         {
       
   645         aAttributes.AppendL(KGlxMediaGeneralSystemItem);
       
   646         }
       
   647     
       
   648     if (requireMediaGeneralFramecount)
       
   649         {
       
   650         aAttributes.AppendL(KGlxMediaGeneralFramecount);
       
   651         }
       
   652     
       
   653     if (requireMediaGeneralSlideshowableContent)
       
   654         {
       
   655         aAttributes.AppendL(KGlxMediaGeneralSlideshowableContent);
       
   656         }
       
   657     	
       
   658     DoGetRequiredAttributesL(aAttributes, aFilterUsingSelection);
       
   659 	}