photosgallery/viewframework/commandhandlers/commandhandlerbase/src/glxmpxcommandcommandhandler.cpp
changeset 2 7d9067c6fcb1
parent 0 4e91876724a2
child 9 6b87b143d312
equal deleted inserted replaced
1:9ba538e329bd 2:7d9067c6fcb1
    39 #include <glxattributecontext.h>
    39 #include <glxattributecontext.h>
    40 #include <glxattributeretriever.h>
    40 #include <glxattributeretriever.h>
    41 #include <glxuistd.h>
    41 #include <glxuistd.h>
    42 #include <glxuiutilities.rsg>
    42 #include <glxuiutilities.rsg>
    43 #include <glxcommandhandlers.hrh>
    43 #include <glxcommandhandlers.hrh>
       
    44 #include <glxtracer.h>
    44 #include <glxresourceutilities.h>                // for CGlxResourceUtilities
    45 #include <glxresourceutilities.h>                // for CGlxResourceUtilities
    45 
    46 
    46 /// @todo Move elsewhere
    47 /// @todo Move elsewhere
    47 const TInt KGlxMaxNoteLength = 256;
    48 const TInt KGlxMaxNoteLength = 256;
    48 
    49 
    52 //	
    53 //	
    53 EXPORT_C CGlxMpxCommandCommandHandler::
    54 EXPORT_C CGlxMpxCommandCommandHandler::
    54     CGlxMpxCommandCommandHandler(MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem)
    55     CGlxMpxCommandCommandHandler(MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem)
    55         : CGlxMediaListCommandHandler(aMediaListProvider, aHasToolbarItem)
    56         : CGlxMediaListCommandHandler(aMediaListProvider, aHasToolbarItem)
    56 	{
    57 	{
       
    58     TRACER("CGlxMpxCommandCommandHandler::CGlxMpxCommandCommandHandler");
    57     iAppUi = static_cast< CAknAppUi* >( CCoeEnv::Static()->AppUi() );
    59     iAppUi = static_cast< CAknAppUi* >( CCoeEnv::Static()->AppUi() );
    58 	}
    60 	}
    59 	
    61 	
    60 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    61 // Destructor
    63 // Destructor
    62 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    63 //	
    65 //	
    64 EXPORT_C CGlxMpxCommandCommandHandler::~CGlxMpxCommandCommandHandler()
    66 EXPORT_C CGlxMpxCommandCommandHandler::~CGlxMpxCommandCommandHandler()
    65 	{
    67 	{
       
    68     TRACER("CGlxMpxCommandCommandHandler::~CGlxMpxCommandCommandHandler");
    66 	// cancel command if running
    69 	// cancel command if running
    67 	if (iProgressComplete)
    70 	if (iProgressComplete)
    68 	    {
    71 	    {
    69 //    	MediaList().Cancel();
    72 //    	MediaList().Cancel();
    70 	    }
    73 	    }
    82 // -----------------------------------------------------------------------------
    85 // -----------------------------------------------------------------------------
    83 //	
    86 //	
    84 EXPORT_C TBool CGlxMpxCommandCommandHandler::DoExecuteL(TInt aCommandId, 
    87 EXPORT_C TBool CGlxMpxCommandCommandHandler::DoExecuteL(TInt aCommandId, 
    85         MGlxMediaList& aList)
    88         MGlxMediaList& aList)
    86     {
    89     {
       
    90     TRACER("CGlxMpxCommandCommandHandler::DoExecuteL");
    87     // reset progress complete flag
    91     // reset progress complete flag
    88     iProgressComplete = EFalse;
    92     iProgressComplete = EFalse;
    89     
    93     
    90     // deriving class consumes command by default
    94     // deriving class consumes command by default
    91     TBool consume = ETrue;
    95     TBool consume = ETrue;
   128             // of a message
   132             // of a message
   129             command->SetTObjectValueL<TAny*>(KMPXCommandGeneralSessionId,
   133             command->SetTObjectValueL<TAny*>(KMPXCommandGeneralSessionId,
   130             		static_cast<TAny*>(this));
   134             		static_cast<TAny*>(this));
   131 
   135 
   132        		aList.AddMediaListObserverL(this);
   136        		aList.AddMediaListObserverL(this);
   133 
   137 			
   134             // @todo TRAP this?
       
   135             aList.CommandL(*command);
   138             aList.CommandL(*command);
   136             
   139             
   137             // raise progress note. Note will be closed when complete message received
   140             // raise progress note. Note will be closed when complete message received
   138             ProgressNoteL(aCommandId);
   141             ProgressNoteL(aCommandId);
   139             
   142             
   148 // TryExitL
   151 // TryExitL
   149 // -----------------------------------------------------------------------------
   152 // -----------------------------------------------------------------------------
   150 //	
   153 //	
   151 EXPORT_C void CGlxMpxCommandCommandHandler::TryExitL(TInt aErrorCode)
   154 EXPORT_C void CGlxMpxCommandCommandHandler::TryExitL(TInt aErrorCode)
   152 	{
   155 	{
       
   156     TRACER("CGlxMpxCommandCommandHandler::TryExitL");
   153 	// any error will abort the command execution
   157 	// any error will abort the command execution
   154     if ( KErrNone != aErrorCode ) 
   158     if ( KErrNone != aErrorCode ) 
   155 	    {
   159 	    {
   156 	    // error received. Close progress note
   160 	    // error received. Close progress note
   157 		DismissProgressNoteL();
   161 		DismissProgressNoteL();
   185 // Default implementation shows an error note
   189 // Default implementation shows an error note
   186 // -----------------------------------------------------------------------------
   190 // -----------------------------------------------------------------------------
   187 //	
   191 //	
   188 EXPORT_C void CGlxMpxCommandCommandHandler::HandleErrorL(TInt aErrorCode) 
   192 EXPORT_C void CGlxMpxCommandCommandHandler::HandleErrorL(TInt aErrorCode) 
   189     {
   193     {
       
   194     TRACER("CGlxMpxCommandCommandHandler::HandleErrorL");
   190 	// show error note
   195 	// show error note
   191 	GlxGeneralUiUtilities::ShowErrorNoteL(aErrorCode);
   196 	GlxGeneralUiUtilities::ShowErrorNoteL(aErrorCode);
   192     }
   197     }
   193 
   198 
   194 // -----------------------------------------------------------------------------
   199 // -----------------------------------------------------------------------------
   196 // -----------------------------------------------------------------------------
   201 // -----------------------------------------------------------------------------
   197 //	
   202 //	
   198 TBool CGlxMpxCommandCommandHandler::UpdateProgressL(const CMPXMessage& aMessage,
   203 TBool CGlxMpxCommandCommandHandler::UpdateProgressL(const CMPXMessage& aMessage,
   199         TInt& aError)
   204         TInt& aError)
   200     {
   205     {
       
   206     TRACER("CGlxMpxCommandCommandHandler::UpdateProgressL");
   201     TBool isComplete = EFalse;
   207     TBool isComplete = EFalse;
   202     
   208     
   203     // should not receive any progress messages after progress is completed
   209     // should not receive any progress messages after progress is completed
   204     __ASSERT_DEBUG(!iProgressComplete, Panic(EGlxPanicIllegalState));
   210     __ASSERT_DEBUG(!iProgressComplete, Panic(EGlxPanicIllegalState));
   205     
   211     
   244 // -----------------------------------------------------------------------------
   250 // -----------------------------------------------------------------------------
   245 //	
   251 //	
   246 EXPORT_C void CGlxMpxCommandCommandHandler::DoHandleCommandCompleteL(TAny* /*aSessionId*/, 
   252 EXPORT_C void CGlxMpxCommandCommandHandler::DoHandleCommandCompleteL(TAny* /*aSessionId*/, 
   247         CMPXCommand* /*aCommandResult*/, TInt /*aError*/, MGlxMediaList* /*aList*/)
   253         CMPXCommand* /*aCommandResult*/, TInt /*aError*/, MGlxMediaList* /*aList*/)
   248     {
   254     {
       
   255     TRACER("CGlxMpxCommandCommandHandler::DoHandleCommandCompleteL");
   249     }
   256     }
   250 
   257 
   251 
   258 
   252 // -----------------------------------------------------------------------------
   259 // -----------------------------------------------------------------------------
   253 // Default implementation of advanced message handling does nothing
   260 // Default implementation of advanced message handling does nothing
   254 // -----------------------------------------------------------------------------
   261 // -----------------------------------------------------------------------------
   255 //	
   262 //	
   256 EXPORT_C TInt CGlxMpxCommandCommandHandler::DoHandleMessageL(const CMPXMessage& /*aMessage*/,
   263 EXPORT_C TInt CGlxMpxCommandCommandHandler::DoHandleMessageL(const CMPXMessage& /*aMessage*/,
   257 	    MGlxMediaList& /*aList*/)
   264 	    MGlxMediaList& /*aList*/)
   258     {
   265     {
       
   266     TRACER("CGlxMpxCommandCommandHandler::DoHandleMessageL");
   259     return KErrNone;
   267     return KErrNone;
   260     }
   268     }
   261 
   269 
   262 // -----------------------------------------------------------------------------
   270 // -----------------------------------------------------------------------------
   263 // Default implementation DoHandleItemAddedL does not do anything
   271 // Default implementation DoHandleItemAddedL does not do anything
   264 // -----------------------------------------------------------------------------
   272 // -----------------------------------------------------------------------------
   265 //	
   273 //	
   266 EXPORT_C void CGlxMpxCommandCommandHandler::DoHandleItemAddedL(TInt /*aStartIndex*/, 
   274 EXPORT_C void CGlxMpxCommandCommandHandler::DoHandleItemAddedL(TInt /*aStartIndex*/, 
   267 		TInt /*aEndIndex*/, MGlxMediaList* /*aList*/)
   275 		TInt /*aEndIndex*/, MGlxMediaList* /*aList*/)
   268 	{
   276 	{
       
   277     TRACER("CGlxMpxCommandCommandHandler::DoHandleItemAddedL");
   269 	}
   278 	}
   270 
   279 
   271 // -----------------------------------------------------------------------------
   280 // -----------------------------------------------------------------------------
   272 // Default implementation is always ready to exit
   281 // Default implementation is always ready to exit
   273 // -----------------------------------------------------------------------------
   282 // -----------------------------------------------------------------------------
   274 //	
   283 //	
   275 EXPORT_C TBool CGlxMpxCommandCommandHandler::OkToExit() const
   284 EXPORT_C TBool CGlxMpxCommandCommandHandler::OkToExit() const
   276     {
   285     {
       
   286     TRACER("CGlxMpxCommandCommandHandler:::OkToExit()");
   277     return ETrue;
   287     return ETrue;
   278     }
   288     }
   279 
   289 
   280 // -----------------------------------------------------------------------------
   290 // -----------------------------------------------------------------------------
   281 // Show confirmation note
   291 // Show confirmation note
   282 // -----------------------------------------------------------------------------
   292 // -----------------------------------------------------------------------------
   283 //	
   293 //	
   284 EXPORT_C TBool CGlxMpxCommandCommandHandler::ConfirmationNoteL(TInt aCommandId,
   294 EXPORT_C TBool CGlxMpxCommandCommandHandler::ConfirmationNoteL(TInt aCommandId,
   285         MGlxMediaList& aMediaList) const
   295         MGlxMediaList& aMediaList) const
   286 	{
   296 	{
       
   297     TRACER("CGlxMpxCommandCommandHandler::ConfirmationNoteL");
   287 	TInt selectionCount = aMediaList.SelectionCount();
   298 	TInt selectionCount = aMediaList.SelectionCount();
   288 
   299 
   289     // If media list is not empty, treat focused item as selected
   300     // If media list is not empty, treat focused item as selected
   290     // At this point can assume that the command was disabled 
   301     // At this point can assume that the command was disabled 
   291     // if static items were not supported	
   302     // if static items were not supported	
   313 // -----------------------------------------------------------------------------
   324 // -----------------------------------------------------------------------------
   314 //	
   325 //	
   315 EXPORT_C TBool CGlxMpxCommandCommandHandler::ConfirmationNoteSingleL(TInt aCommandId, 
   326 EXPORT_C TBool CGlxMpxCommandCommandHandler::ConfirmationNoteSingleL(TInt aCommandId, 
   316         MGlxMediaList& aMediaList) const
   327         MGlxMediaList& aMediaList) const
   317     {
   328     {
       
   329     TRACER("CGlxMpxCommandCommandHandler::ConfirmationNoteSingleL");
   318     // if no confirmation note shown, assume command is confirmed
   330     // if no confirmation note shown, assume command is confirmed
   319     TBool confirmed = ETrue;
   331     TBool confirmed = ETrue;
   320 
   332 
   321     // get confirmation note text for single selection
   333     // get confirmation note text for single selection
   322     HBufC* noteText = ConfirmationTextL(aCommandId, EFalse); // EFalse for single selection
   334     HBufC* noteText = ConfirmationTextL(aCommandId, EFalse); // EFalse for single selection
   375 // -----------------------------------------------------------------------------
   387 // -----------------------------------------------------------------------------
   376 //	
   388 //	
   377 EXPORT_C TBool CGlxMpxCommandCommandHandler::ConfirmationNoteMultipleL(TInt aCommandId, 
   389 EXPORT_C TBool CGlxMpxCommandCommandHandler::ConfirmationNoteMultipleL(TInt aCommandId, 
   378         MGlxMediaList& aMediaList) const
   390         MGlxMediaList& aMediaList) const
   379 	{
   391 	{
       
   392     TRACER("CGlxMpxCommandCommandHandler::ConfirmationNoteMultipleL");
   380 	// if no confirmation note shown, assume command is confirmed
   393 	// if no confirmation note shown, assume command is confirmed
   381 	TBool confirmed = ETrue;
   394 	TBool confirmed = ETrue;
   382 
   395 
   383 	// get confirmation note text for multiselection
   396 	// get confirmation note text for multiselection
   384 	HBufC* noteText = ConfirmationTextL(aCommandId, ETrue); // ETrue for Multiselection
   397 	HBufC* noteText = ConfirmationTextL(aCommandId, ETrue); // ETrue for Multiselection
   415 // Return default progress string
   428 // Return default progress string
   416 // -----------------------------------------------------------------------------
   429 // -----------------------------------------------------------------------------
   417 //	
   430 //	
   418 EXPORT_C HBufC* CGlxMpxCommandCommandHandler::ProgressTextL(TInt /*aCommandId*/) const
   431 EXPORT_C HBufC* CGlxMpxCommandCommandHandler::ProgressTextL(TInt /*aCommandId*/) const
   419     {
   432     {
       
   433     TRACER("CGlxMpxCommandCommandHandler::ProgressTextL");
   420     // Lazy construction for resource file
   434     // Lazy construction for resource file
   421     if (iResourceOffset == 0)
   435     if (iResourceOffset == 0)
   422         {
   436         {
   423         // Load resource file
   437         // Load resource file
   424     	TParse parse;
   438     	TParse parse;
   449 // ProgressNoteL
   463 // ProgressNoteL
   450 // -----------------------------------------------------------------------------
   464 // -----------------------------------------------------------------------------
   451 //	
   465 //	
   452 void CGlxMpxCommandCommandHandler::ProgressNoteL(TInt aCommandId)
   466 void CGlxMpxCommandCommandHandler::ProgressNoteL(TInt aCommandId)
   453 	{
   467 	{
       
   468     TRACER("CGlxMpxCommandCommandHandler::ProgressNoteL(TInt aCommandId)");
   454 	//MGlxMediaList& mediaList = MediaList();
   469 	//MGlxMediaList& mediaList = MediaList();
   455 
   470 
   456     // get progress note 
   471     // get progress note 
   457     HBufC* progressText = ProgressTextL(aCommandId);
   472     HBufC* progressText = ProgressTextL(aCommandId);
   458     __ASSERT_DEBUG(progressText, Panic(EGlxPanicNullDescriptor));
   473     __ASSERT_DEBUG(progressText, Panic(EGlxPanicNullDescriptor));
   476 // DismissProgressNoteL
   491 // DismissProgressNoteL
   477 // -----------------------------------------------------------------------------
   492 // -----------------------------------------------------------------------------
   478 //	
   493 //	
   479 void CGlxMpxCommandCommandHandler::DismissProgressNoteL()
   494 void CGlxMpxCommandCommandHandler::DismissProgressNoteL()
   480 	{
   495 	{
       
   496     TRACER("CGlxMpxCommandCommandHandler::DismissProgressNoteL");
   481     // Close the progress note, if displayed
   497     // Close the progress note, if displayed
   482     if (iProgressDialog) 
   498     if (iProgressDialog) 
   483         {
   499         {
   484     	iProgressDialog->ProcessFinishedL();
   500     	iProgressDialog->ProcessFinishedL();
   485     	iProgressDialog = NULL;
   501     	iProgressDialog = NULL;
   491 // Remove MediaList Observer
   507 // Remove MediaList Observer
   492 // -----------------------------------------------------------------------------
   508 // -----------------------------------------------------------------------------
   493 //
   509 //
   494 void CGlxMpxCommandCommandHandler::RemoveMediaListObserver()
   510 void CGlxMpxCommandCommandHandler::RemoveMediaListObserver()
   495 	{
   511 	{
       
   512     TRACER("CGlxMpxCommandCommandHandler::RemoveMediaListObserver");
   496 	MGlxMediaList& mediaList = MediaList();
   513 	MGlxMediaList& mediaList = MediaList();
   497 	mediaList.RemoveMediaListObserver(this);
   514 	mediaList.RemoveMediaListObserver(this);
   498 	}
   515 	}
   499 
   516 
   500 // -----------------------------------------------------------------------------
   517 // -----------------------------------------------------------------------------
   501 // Show a completion note
   518 // Show a completion note
   502 // -----------------------------------------------------------------------------
   519 // -----------------------------------------------------------------------------
   503 //	
   520 //	
   504 void CGlxMpxCommandCommandHandler::CompletionNoteL() const
   521 void CGlxMpxCommandCommandHandler::CompletionNoteL() const
   505 	{
   522 	{
       
   523     TRACER("CGlxMpxCommandCommandHandler::CompletionNoteL");
   506 	// Get completion note text 
   524 	// Get completion note text 
   507 	HBufC* noteText = CompletionTextL(); 
   525 	HBufC* noteText = CompletionTextL(); 
   508 	if ( noteText )
   526 	if ( noteText )
   509 	    {
   527 	    {
   510 		CleanupStack::PushL(noteText);
   528 		CleanupStack::PushL(noteText);
   585 // -----------------------------------------------------------------------------
   603 // -----------------------------------------------------------------------------
   586 //	
   604 //	
   587 EXPORT_C void CGlxMpxCommandCommandHandler::HandleMessageL(const CMPXMessage& aMessage, 
   605 EXPORT_C void CGlxMpxCommandCommandHandler::HandleMessageL(const CMPXMessage& aMessage, 
   588         MGlxMediaList* aList)
   606         MGlxMediaList* aList)
   589 	{
   607 	{
       
   608     TRACER("CGlxMpxCommandCommandHandler::HandleMessageL");
   590     if ((aMessage.IsSupported(KMPXMessageGeneralId) &&
   609     if ((aMessage.IsSupported(KMPXMessageGeneralId) &&
   591     	(aMessage.IsSupported(KMPXCommandGeneralSessionId))))
   610     	(aMessage.IsSupported(KMPXCommandGeneralSessionId))))
   592         {
   611         {
   593         TInt msgId = aMessage.ValueTObjectL<TInt>(KMPXMessageGeneralId);
   612         TInt msgId = aMessage.ValueTObjectL<TInt>(KMPXMessageGeneralId);
   594         TAny* sessionId = aMessage.ValueTObjectL<TAny*>(KMPXCommandGeneralSessionId);
   613         TAny* sessionId = aMessage.ValueTObjectL<TAny*>(KMPXCommandGeneralSessionId);
   617 // -----------------------------------------------------------------------------
   636 // -----------------------------------------------------------------------------
   618 //	
   637 //	
   619 EXPORT_C void CGlxMpxCommandCommandHandler::HandleCommandCompleteL(TAny* aSessionId,
   638 EXPORT_C void CGlxMpxCommandCommandHandler::HandleCommandCompleteL(TAny* aSessionId,
   620 	CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList)
   639 	CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList)
   621     {
   640     {
       
   641     TRACER("CGlxMpxCommandCommandHandler::HandleCommandCompleteL");
   622     // Unmark all medialist items. Exit Multiple marking mode upon command completion
   642     // Unmark all medialist items. Exit Multiple marking mode upon command completion
   623     iAppUi->ProcessCommandL(EGlxCmdEndMultipleMarking);
   643     iAppUi->ProcessCommandL(EGlxCmdEndMultipleMarking);
   624 
   644 
   625     ///@todo Enforce a single command request at a time on the media list.
   645     ///@todo Enforce a single command request at a time on the media list.
   626     DoHandleCommandCompleteL(aSessionId, aCommandResult, aError, aList);
   646     DoHandleCommandCompleteL(aSessionId, aCommandResult, aError, aList);
   632 // DialogDismissedL
   652 // DialogDismissedL
   633 // -----------------------------------------------------------------------------
   653 // -----------------------------------------------------------------------------
   634 //  
   654 //  
   635 EXPORT_C void CGlxMpxCommandCommandHandler::DialogDismissedL(TInt /*aButtonId*/)
   655 EXPORT_C void CGlxMpxCommandCommandHandler::DialogDismissedL(TInt /*aButtonId*/)
   636 	{
   656 	{
       
   657     TRACER("CGlxMpxCommandCommandHandler::DialogDismissedL");
   637 	if (!iProgressComplete)
   658 	if (!iProgressComplete)
   638 		{
   659 		{
   639 		// Remove as media list observer
   660 		// Remove as media list observer
   640 		MGlxMediaList& mediaList = MediaList();
   661 		MGlxMediaList& mediaList = MediaList();
   641 		mediaList.CancelCommand();
   662 		mediaList.CancelCommand();
   656 // Deactivate - Deactivate this command handler
   677 // Deactivate - Deactivate this command handler
   657 // -----------------------------------------------------------------------------
   678 // -----------------------------------------------------------------------------
   658 //
   679 //
   659 EXPORT_C void CGlxMpxCommandCommandHandler::Deactivate()
   680 EXPORT_C void CGlxMpxCommandCommandHandler::Deactivate()
   660     {
   681     {
       
   682     TRACER("CGlxMpxCommandCommandHandler::Deactivate");
   661     // Close the progress note, if displayed
   683     // Close the progress note, if displayed
   662 	if (iProgressDialog)
   684 	if (iProgressDialog)
   663         {
   685         {
   664         TRAP_IGNORE(DismissProgressNoteL());
   686         TRAP_IGNORE(DismissProgressNoteL());
   665         }
   687         }