photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlerdetails.cpp
changeset 0 4e91876724a2
child 12 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:    Details commmand handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "glxcommandhandlerdetails.h"
       
    22 
       
    23 #include <AknUtils.h>
       
    24 #include <bautils.h>
       
    25 
       
    26 #include <mpxviewutility.h>
       
    27 
       
    28 #include <data_caging_path_literals.hrh> 	//for gallery related constatns
       
    29 #include <glxcommandhandlers.hrh> 			//for command id
       
    30 
       
    31 #include <glxuiutility.h>
       
    32 
       
    33 #include <glxuistd.h>
       
    34 #include <glxuiutility.h>
       
    35 #include <glxuiutilities.rsg>
       
    36 #include <glxpanic.h>
       
    37 #include <StringLoader.h>
       
    38 #include <glxtracer.h>
       
    39 #include <glxlog.h>
       
    40 #include <glxicons.mbg>
       
    41 
       
    42 #include <glxmedia.h> 
       
    43 #include <glxmedialist.h> 
       
    44 #include <mpxmediageneraldefs.h>            // for TMPXAttribute
       
    45 #include <glxattributeretriever.h>          // for CGlxAttributeRetriever 
       
    46 #include <glxattributecontext.h>            // for CGlxDefaultAttributeContext
       
    47 #include <glxresourceutilities.h>           // for CGlxResourceUtilities
       
    48 #include <glxfetchcontextremover.h>         // for TGlxFetchContextRemover
       
    49 
       
    50 #include <glxviewpluginuids.hrh> //for view plugin implmentation id
       
    51 #include <glxcollectionpluginimageviewer.hrh>
       
    52 #include <mpxcollectionutility.h>
       
    53 #include <glxmetadatadialog.h>              //for metadata dialog
       
    54 #include <glximgvwrmetadatadialog.h>
       
    55 #include <glxnavigationalstate.h>
       
    56 #include <mpxcollectionpath.h>
       
    57 // ---------------------------------------------------------------------------
       
    58 // Two-phased constructor.
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 EXPORT_C CGlxCommandHandlerDetails* 
       
    62 			CGlxCommandHandlerDetails::NewL( 
       
    63 			MGlxMediaListProvider* aMediaListProvider )
       
    64 	{
       
    65 	CGlxCommandHandlerDetails* self = new (ELeave) CGlxCommandHandlerDetails(aMediaListProvider);
       
    66 	CleanupStack::PushL(self);
       
    67 	self->ConstructL();
       
    68 	CleanupStack::Pop(self);
       
    69 	return self;
       
    70 	}
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // C++ default constructor can NOT contain any code, that
       
    74 // might leave.
       
    75 // ---------------------------------------------------------------------------
       
    76 //	
       
    77 CGlxCommandHandlerDetails::CGlxCommandHandlerDetails(MGlxMediaListProvider* aMediaListProvider )
       
    78 														:CGlxMediaListCommandHandler(aMediaListProvider)
       
    79 	{
       
    80 	//Do nothing
       
    81 	}			
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // Symbian 2nd phase constructor can leave.
       
    85 // ---------------------------------------------------------------------------
       
    86 //	
       
    87 void CGlxCommandHandlerDetails::ConstructL()
       
    88 	{
       
    89     // Load resource file
       
    90     GLX_FUNC("GLX_Property::ConstructL");
       
    91 	
       
    92 	// register property command in command handler
       
    93 	TParse parse;
       
    94     parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL);
       
    95     TFileName resourceFile;
       
    96     resourceFile.Append(parse.FullName());
       
    97 
       
    98     CGlxResourceUtilities::GetResourceFilenameL(resourceFile); 
       
    99    	iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resourceFile);
       
   100 				
       
   101 	// register property command in command handler
       
   102    	TCommandInfo infoProp(EGlxCmdDetails);
       
   103    	// Filter out static items and only allows one item to select
       
   104     infoProp.iMinSelectionLength = 1;
       
   105     infoProp.iMaxSelectionLength = 1;
       
   106     //Allow DRM
       
   107     infoProp.iDisallowDRM = EFalse;
       
   108     //Allow system items
       
   109     infoProp.iDisallowSystemItems= EFalse;
       
   110     //Allow animation
       
   111     infoProp.iStopAnimationForExecution = EFalse;  
       
   112     //no category filter
       
   113     infoProp.iCategoryFilter = EMPXNoCategory;
       
   114    	AddCommandL(infoProp);
       
   115 		   			   	
       
   116    	TCommandInfo infoSubMenu(EGlxCmdDetailsOption);
       
   117     infoSubMenu.iViewingState = TCommandInfo::EViewingStateBrowse;
       
   118    	//AddCommandL(infoSubMenu);
       
   119    	
       
   120    	// register for the reset view command so that we can 
       
   121    	// dismiss the dialog if it is being shown when we are activated
       
   122    	// from SpaceUI 
       
   123     TCommandInfo resetViewCmd( EGlxCmdResetView );
       
   124     AddCommandL( resetViewCmd );
       
   125     
       
   126    	// get pointer to HUI utility
       
   127     iUiUtility = CGlxUiUtility::UtilityL();
       
   128 	}	
       
   129 	
       
   130 // ---------------------------------------------------------------------------
       
   131 // Destructor
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 EXPORT_C CGlxCommandHandlerDetails::~CGlxCommandHandlerDetails()
       
   135 	{
       
   136 	TRACER("GLX_Property::~CGlxCommandHandlerDetails");
       
   137 	if ( iResourceOffset )
       
   138         {
       
   139         CCoeEnv::Static()->DeleteResourceFile(iResourceOffset);
       
   140         }
       
   141         
       
   142     if ( iUiUtility )
       
   143         {
       
   144         iUiUtility->Close();
       
   145         }
       
   146 	}
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // DoExecuteL
       
   150 // -----------------------------------------------------------------------------
       
   151 //	
       
   152 TBool CGlxCommandHandlerDetails::DoExecuteL( TInt aCommandId, MGlxMediaList& aList )
       
   153 	{
       
   154 	TBool consume(EFalse);
       
   155 	TRACER("GLX_Property::DoExecuteL");
       
   156 	GLX_LOG_INFO1("GLX_Property::DoExecuteL::DoExecuteL %d",aCommandId);
       
   157 	switch(aCommandId)
       
   158 		{
       
   159 		case EGlxCmdDetails:
       
   160 			{
       
   161 			GLX_LOG_INFO("GLX_Property::DoExecuteL::Launch UMP");
       
   162 
       
   163 			CGlxDefaultAttributeContext* attrContext = CGlxDefaultAttributeContext::NewL();
       
   164 			CleanupStack::PushL(attrContext);
       
   165 
       
   166 			attrContext->AddAttributeL(KMPXMediaGeneralUri);
       
   167 
       
   168 			aList.AddContextL(attrContext, KGlxFetchContextPriorityBlocking);	
       
   169 
       
   170 			// TGlxContextRemover will remove the context when it goes out of scope
       
   171 			// Used here to avoid a trap and still have safe cleanup
       
   172 			TGlxFetchContextRemover contextRemover (attrContext, aList);
       
   173 
       
   174 			CleanupClosePushL( contextRemover);
       
   175 
       
   176 			TInt err = GlxAttributeRetriever::RetrieveL(*attrContext,aList,ETrue);
       
   177 
       
   178 			// context off the list
       
   179 			CleanupStack::PopAndDestroy( &contextRemover );
       
   180 
       
   181 			if ( err == KErrNone )
       
   182 				{
       
   183 				TInt focusIndex = aList.FocusIndex();
       
   184 				TGlxMedia item = aList.Item(focusIndex);
       
   185 				const CGlxMedia* media = item.Properties();
       
   186 
       
   187 				TBool isDrm = aList.Item(focusIndex).IsDrmProtected();
       
   188 				TBool isVideo = EFalse;
       
   189 
       
   190 				TMPXGeneralCategory type = MediaList().Item( focusIndex ).Category();
       
   191 				if(type == EMPXVideo)   
       
   192 					{
       
   193 					isVideo = ETrue;
       
   194 					}
       
   195 
       
   196 
       
   197 				//check media support uri attribute
       
   198 				if(media && media->IsSupported(KMPXMediaGeneralUri))
       
   199 					{
       
   200 					const TDesC& uri = media->ValueText(KMPXMediaGeneralUri);
       
   201 
       
   202 					HBufC* uriBuf = HBufC::NewLC(uri.Length()+2);
       
   203 
       
   204 					TPtr uriPtr (uriBuf->Des());
       
   205 					uriPtr = uri;
       
   206 					uriPtr.Append( isDrm );
       
   207 					uriPtr.Append( isVideo );
       
   208 
       
   209 					GLX_DEBUG2("GLX_Property::DoExecuteL::URI:%S:",&uri);
       
   210 
       
   211                     iUiUtility->SetViewNavigationDirection(EGlxNavigationForwards); 
       
   212                     if (aList.Collection().UidL().iUid == KGlxCollectionPluginImageViewerImplementationUid)
       
   213                         {
       
   214                         CGlxImgVwrMetadataDialog* dialog  = CGlxImgVwrMetadataDialog::NewL( uri);
       
   215                         dialog->ExecuteLD();
       
   216                         }
       
   217                     else
       
   218                         {
       
   219                         CGlxMetadataDialog* dialog  = CGlxMetadataDialog::NewL( uri );    
       
   220                         dialog->ExecuteLD();
       
   221                         }
       
   222 
       
   223                     
       
   224                     CleanupStack::PopAndDestroy(uriBuf);
       
   225                     }
       
   226                 }
       
   227             CleanupStack::PopAndDestroy( attrContext );
       
   228             consume = ETrue;
       
   229             break;
       
   230             }// contextRemover goes out of scope and removes the context from media list
       
   231         default:
       
   232             {
       
   233             break;		
       
   234             }
       
   235         }
       
   236 
       
   237 	return consume;
       
   238 	}
       
   239 // -----------------------------------------------------------------------------
       
   240 // LaunchViewL
       
   241 // -----------------------------------------------------------------------------
       
   242 //		
       
   243 void CGlxCommandHandlerDetails::LaunchViewL(TUid aViewPluginId,const TDesC& aURI)
       
   244 	{
       
   245 	TRACER("GLX_UMP::CGlxCommandHandlerDetails:LaunchViewL");
       
   246 	
       
   247 	MMPXViewUtility* viewUtility = MMPXViewUtility::UtilityL();
       
   248 	CleanupClosePushL(*viewUtility);
       
   249 	
       
   250 	if( aURI.Length() > 0 )
       
   251 		{
       
   252 		//following is to preserve unicode format of filename
       
   253 		//Convert aURI 16 bit descriptor to 8 bit descriptor
       
   254 		TPtrC8 ptr8((TUint8*)aURI.Ptr(),aURI.Length());
       
   255 		GLX_LOG_INFO1("GLX_UMP::CGlxCommandHandlerDetails:ActivateViewL::ptr8:%S:",&ptr8);
       
   256 		
       
   257 		//convert back to 16 bit descriptor
       
   258 		TPtrC16 ptr16((TUint16*)ptr8.Ptr(),ptr8.Length());
       
   259 		GLX_LOG_INFO1("GLX_UMP::CGlxCommandHandlerDetails:ActivateViewL::ptr16:%S:",&ptr16);	
       
   260 		
       
   261 		viewUtility->ActivateViewL(aViewPluginId,&ptr16);
       
   262 		}
       
   263 	else
       
   264 		{
       
   265 		viewUtility->ActivateViewL(aViewPluginId,&KNullDesC);
       
   266 		}
       
   267 
       
   268 	CleanupStack::PopAndDestroy(viewUtility); 
       
   269 	}
       
   270 // -----------------------------------------------------------------------------
       
   271 // DoActivateL
       
   272 // -----------------------------------------------------------------------------
       
   273 //		
       
   274 void CGlxCommandHandlerDetails::DoActivateL( TInt /*aViewId*/ )
       
   275 	{
       
   276 	
       
   277 	}
       
   278 
       
   279 // -----------------------------------------------------------------------------
       
   280 // DoIsDisabled
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 TBool CGlxCommandHandlerDetails::DoIsDisabled(TInt aCommandId, 
       
   284                                         MGlxMediaList& aList) const 
       
   285     {
       
   286     TBool fullscreenViewingMode = EFalse;
       
   287     CGlxNavigationalState* aNavigationalState = CGlxNavigationalState::InstanceL();
       
   288     CMPXCollectionPath* naviState = aNavigationalState->StateLC();
       
   289     
       
   290     if ( naviState->Levels() >= 1)
       
   291         {
       
   292         if (aNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) 
       
   293             {
       
   294             // For image viewer collection, goto view mode
       
   295             if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid))
       
   296                 {
       
   297                 //it means we are in img viewer.so details will be available
       
   298                 fullscreenViewingMode = ETrue;
       
   299                 }
       
   300             else
       
   301                 {
       
   302                 //it means we are in grid view.so details will be not beavailable
       
   303                 fullscreenViewingMode = EFalse;
       
   304                 }
       
   305             } 
       
   306         else 
       
   307             {
       
   308             //it means we are in Fullscreen.so details will be available
       
   309             fullscreenViewingMode = ETrue;
       
   310             }                
       
   311         }
       
   312     CleanupStack::PopAndDestroy( naviState );
       
   313     aNavigationalState->Close();
       
   314     
       
   315     if(EGlxCmdDetails==aCommandId && (0 == aList.Count() || 1 != aList.SelectionCount())&& !fullscreenViewingMode )
       
   316         {   
       
   317         return ETrue;
       
   318         }
       
   319     return EFalse;
       
   320     }
       
   321 
       
   322 	
       
   323 //End of file