photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandleraiwassign.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:    AIW assign command handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxcommandhandleraiwassign.h"
       
    22 
       
    23 #include <eikmenup.h> 
       
    24 #include <StringLoader.h>
       
    25 #include <glxattributecontext.h>
       
    26 #include <glxcommandhandlers.hrh>
       
    27 #include <glxmedia.h>
       
    28 #include <glxtracer.h>
       
    29 #include <mglxmedialist.h>
       
    30 #include <glxuiutilities.rsg>
       
    31 #include <glxnavigationalstate.h>
       
    32 #include <mpxcollectionpath.h>
       
    33 #include <glxcollectionpluginimageviewer.hrh>
       
    34 #include "glxaiwservicehandler.h"
       
    35 
       
    36 const TInt KGlxAiwAssignCommandSpace = 0x00000100;
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // NewL
       
    40 // -----------------------------------------------------------------------------
       
    41 //	
       
    42 EXPORT_C CGlxCommandHandlerAiwAssign* CGlxCommandHandlerAiwAssign::NewL(
       
    43         MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource)
       
    44     {
       
    45     TRACER("CGlxCommandHandlerAiwAssign* CGlxCommandHandlerAiwAssign::NewL");
       
    46     CGlxCommandHandlerAiwAssign* self = new ( ELeave ) 
       
    47         CGlxCommandHandlerAiwAssign(aMediaListProvider, aMenuResource);
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL();
       
    50     CleanupStack::Pop( self );
       
    51     return self;
       
    52     }
       
    53     
       
    54 // -----------------------------------------------------------------------------
       
    55 // Constructor
       
    56 // -----------------------------------------------------------------------------
       
    57 //	
       
    58 CGlxCommandHandlerAiwAssign::CGlxCommandHandlerAiwAssign(
       
    59         MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource)
       
    60 :   CGlxCommandHandlerAiwBase(aMediaListProvider, aMenuResource)
       
    61     {
       
    62     TRACER("CGlxCommandHandlerAiwAssign::CGlxCommandHandlerAiwAssign");
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CGlxCommandHandlerAiwAssign::DoGetRequiredAttributesL
       
    67 // -----------------------------------------------------------------------------
       
    68 //	
       
    69 void CGlxCommandHandlerAiwAssign::DoGetRequiredAttributesL
       
    70 									(RArray<TMPXAttribute>& aAttributes, TBool aFilterUsingSelection) const
       
    71 	{
       
    72 	TRACER("void CGlxCommandHandlerAiwAssign::DoGetRequiredAttributesL");
       
    73   // Add MIME type and filename attributes
       
    74 	if (!aFilterUsingSelection || SelectionLength() <= MaxSelectedItems())
       
    75 		{
       
    76 	  	aAttributes.AppendL(KMPXMediaGeneralMimeType);
       
    77 	  	aAttributes.AppendL(KMPXMediaGeneralUri);
       
    78 	  	aAttributes.AppendL(KMPXMediaGeneralCategory);
       
    79 		} 
       
    80 	}
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CommandId
       
    84 // -----------------------------------------------------------------------------
       
    85 //	
       
    86 TInt CGlxCommandHandlerAiwAssign::CommandId() const
       
    87     {
       
    88     TRACER("TInt CGlxCommandHandlerAiwAssign::CommandId() const");
       
    89     return EGlxCmdAiwAssign;
       
    90     }
       
    91     
       
    92 // -----------------------------------------------------------------------------
       
    93 // AiwCommandId
       
    94 // -----------------------------------------------------------------------------
       
    95 //	
       
    96 TInt CGlxCommandHandlerAiwAssign::AiwCommandId() const
       
    97     {
       
    98     TRACER("TInt CGlxCommandHandlerAiwAssign::AiwCommandId() const");
       
    99     return KAiwCmdAssign;
       
   100     }
       
   101     
       
   102 // -----------------------------------------------------------------------------
       
   103 // AiwInterestResource
       
   104 // -----------------------------------------------------------------------------
       
   105 //	
       
   106 TInt CGlxCommandHandlerAiwAssign::AiwInterestResource() const
       
   107     {
       
   108     return R_GLX_AIW_ASSIGN_TO_CONTACT_INTEREST;
       
   109     }
       
   110         
       
   111 // -----------------------------------------------------------------------------
       
   112 // AppendAiwParameterL
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 TBool CGlxCommandHandlerAiwAssign::AppendAiwParameterL(const TGlxMedia& aItem, 
       
   116                                      CGlxAiwServiceHandler& aAiwServiceHandler)
       
   117     {
       
   118     return AppendDefaultAiwParameterL(  aItem, 
       
   119                                         aAiwServiceHandler, 
       
   120                                         ETrue,                  // Add the Uri
       
   121                                         ETrue);                 // Add the Mime Type
       
   122     }
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // AiwDoDynInitMenuPaneL
       
   126 // -----------------------------------------------------------------------------
       
   127 //	
       
   128 void CGlxCommandHandlerAiwAssign::AiwDoDynInitMenuPaneL(TInt /*aResourceId*/, 
       
   129         CEikMenuPane* aMenuPane)
       
   130     {
       
   131     TRACER("void CGlxCommandHandlerAiwAssign::AiwDoDynInitMenuPaneL");
       
   132     TBool fullscreenViewingMode = EFalse;
       
   133     CGlxNavigationalState* aNavigationalState = CGlxNavigationalState::InstanceL();
       
   134     CMPXCollectionPath* naviState = aNavigationalState->StateLC();
       
   135     
       
   136     if ( naviState->Levels() >= 1)
       
   137         {
       
   138         if (aNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) 
       
   139             {
       
   140             // For image viewer collection, goto view mode
       
   141             if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid))
       
   142                 {
       
   143                 //it means we are in img viewer.
       
   144                 fullscreenViewingMode = ETrue;
       
   145                 }
       
   146             else
       
   147                 {
       
   148                  //it means we are in grid view.
       
   149                 fullscreenViewingMode = EFalse;
       
   150                 }
       
   151             } 
       
   152         else 
       
   153             {
       
   154             //it means we are in Fullscreen.
       
   155             fullscreenViewingMode = ETrue;
       
   156             }                
       
   157         }
       
   158     CleanupStack::PopAndDestroy( naviState );
       
   159     aNavigationalState->Close();
       
   160     
       
   161     HBufC* currentTitle = StringLoader::LoadLC( R_QTN_LGAL_OPTIONS_USE_ITEMS );
       
   162     // get commandId for the current menupane item title
       
   163     TInt cmdId = AiwMenuCmdIdL( *currentTitle,aMenuPane ) ;
       
   164 
       
   165     CleanupStack::PopAndDestroy(currentTitle);
       
   166     
       
   167     if( KErrNotFound != cmdId )
       
   168         {
       
   169         MGlxMediaList& mediaList = MediaList();
       
   170 
       
   171         if (mediaList.SelectionCount() == 1 || fullscreenViewingMode )
       
   172             {
       
   173     		TGlxSelectionIterator iterator;
       
   174             
       
   175             iterator.SetToFirst(&mediaList);
       
   176 
       
   177         	TInt index = iterator++;
       
   178         	if ( index != KErrNotFound )
       
   179         	    {
       
   180         		TMPXGeneralCategory cat = mediaList.Item(index).Category();
       
   181     		    TInt resId(0);
       
   182     		    
       
   183     		    if ( cat == EMPXImage )
       
   184     		        {
       
   185     		        resId = R_QTN_LGAL_OPTIONS_USE_IMAGE_AS;
       
   186     		        }
       
   187     		    else if ( cat == EMPXVideo )
       
   188     		        {
       
   189     		        resId = R_QTN_LGAL_OPTIONS_USE_VIDEO_AS;
       
   190     		        }
       
   191 
       
   192     		    if ( resId )
       
   193     		        {
       
   194                 	HBufC* menuTitle = StringLoader::LoadLC( resId );
       
   195                 	if ( menuTitle )
       
   196                 	    {
       
   197                 	    aMenuPane->SetItemTextL(cmdId, 
       
   198                 	        *menuTitle);
       
   199                 	    }
       
   200                     CleanupStack::PopAndDestroy(menuTitle);
       
   201     		        }
       
   202         	    }
       
   203             }
       
   204 		// In case there are Multiple Media Items Marked
       
   205         else
       
   206            	{
       
   207            	// Setting the " Use Items " Main Menu Option to Invisible
       
   208            	aMenuPane->SetItemDimmed(cmdId,ETrue);
       
   209            	}
       
   210         }
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CommandSpace
       
   215 // -----------------------------------------------------------------------------
       
   216 //	
       
   217 TInt CGlxCommandHandlerAiwAssign::CommandSpace() const
       
   218     {
       
   219     return KGlxAiwAssignCommandSpace;
       
   220     }