photosgallery/viewframework/commandhandlers/commandhandlerbase/src/glxmpxcommandcommandhandler.cpp
branchRCL_3
changeset 75 01504893d9cb
parent 64 34937ec34dac
equal deleted inserted replaced
68:5b238bc8ffb6 75:01504893d9cb
    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 <glxtracer.h>
    45 #include <glxresourceutilities.h>                // for CGlxResourceUtilities
    45 #include <glxresourceutilities.h>                // for CGlxResourceUtilities
    46 #include <glxnavigationalstate.h>
    46 
    47 #include <mpxcollectionpath.h>
    47 /// @todo Move elsewhere
    48 #include <glxcollectionpluginimageviewer.hrh>
    48 const TInt KGlxMaxNoteLength = 256;
    49 #include <glximageviewermanager.h>
       
    50 #include <caf/manager.h>
       
    51 
       
    52 
    49 
    53 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    54 // ConstructL
    51 // ConstructL
    55 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    56 //	
    53 //	
   121 		consume = EFalse;
   118 		consume = EFalse;
   122 		}
   119 		}
   123 
   120 
   124     if ( consume )
   121     if ( consume )
   125         {
   122         {
   126         CGlxNavigationalState* navState = CGlxNavigationalState::InstanceL();
   123         // get a command object from the deriving class.
   127 		CleanupClosePushL(*navState);
   124         // Allow deriving class modify the consume value, even without 
   128         CMPXCollectionPath* path = navState->StateLC();
   125         // creating a commmand (in case it wants to filter out a command)
   129         CreateImageViewerInstanceL();
   126         CMPXCommand* command = CreateCommandL(aCommandId, aList, consume);
   130         TBool privatePath = iImageViewerInstance->IsPrivate();
   127         
   131         TBool viewerPathId = (path->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) ? ETrue : EFalse;
   128         if (command)
   132         iImageViewerInstance->CloseImageDecoder();
       
   133         DeleteImageViewerInstance();
       
   134         CleanupStack::PopAndDestroy(path);
       
   135         CleanupStack::PopAndDestroy(navState);
       
   136 	 		
       
   137         if (viewerPathId && !privatePath)
       
   138             {
   129             {
   139             RFs fs;
   130             CleanupStack::PushL(command);
   140 			CleanupClosePushL(fs);
   131             
   141             User::LeaveIfError(fs.Connect());
   132             if ( CommandInfo(aCommandId).iStopAnimationForExecution )
   142 			ContentAccess::CManager *manager = ContentAccess::CManager::NewL();
       
   143 			CleanupStack::PushL(manager);
       
   144 			fs.SetAtt(focusedMedia.Uri(), 0, KEntryAttReadOnly);		
       
   145             TInt ret = manager->DeleteFile(focusedMedia.Uri());
       
   146             if(ret != KErrNone)
       
   147                 {
   133                 {
   148 				CreateImageViewerInstanceL();
   134                 // Stop GIF animation
   149 				iImageViewerInstance->CreateImageDecoderL();
   135                 iAppUi->ProcessCommandL(EGlxCmdDisableAnimations);
   150 				DeleteImageViewerInstance();
   136                 iAnimationStopped = ETrue;
   151                 HBufC* noteText = StringLoader::LoadL(R_GLX_DELETION_FAILURE_NOTE);
       
   152                 CleanupStack::PushL(noteText);
       
   153                 const TDesC& itemName = focusedMedia.Uri();
       
   154                 TParsePtrC parse(focusedMedia.Uri());
       
   155                 TBuf<KMaxFileName> text;
       
   156                 StringLoader::Format(text, *noteText, -1, parse.Name());
       
   157                 GlxGeneralUiUtilities::ShowErrorNoteL(text, ETrue);
       
   158                 CleanupStack::PopAndDestroy(noteText);
       
   159                 }
   137                 }
   160             CleanupStack::PopAndDestroy(manager);
   138             
   161             CleanupStack::PopAndDestroy(&fs);
   139             // Add the pointer of this command handler as session id into the message
   162             if(ret == KErrNone)
   140             // This can be used to ensure that this object is the intended recipient
       
   141             // of a message
       
   142             command->SetTObjectValueL<TAny*>(KMPXCommandGeneralSessionId,
       
   143             		static_cast<TAny*>(this));
       
   144 
       
   145        		aList.AddMediaListObserverL(this);
       
   146 			
       
   147             aList.CommandL(*command);
       
   148             
       
   149             // raise progress note. Note will be closed when complete message received
       
   150 			// For EGlxCmdAddMedia we dont need to show dialog as EGlxCmdAddToAlbum or
       
   151 			// EGlxCmdAddTag will show processing dialog.
       
   152             if (aCommandId != EGlxCmdAddMedia)
   163                 {
   153                 {
   164                 iAppUi->ProcessCommandL(EAknSoftkeyExit);
   154                 ProgressNoteL(aCommandId);
   165                 }
   155                 }
   166             }
   156             CleanupStack::PopAndDestroy(command);
   167         else
       
   168             {
       
   169             // get a command object from the deriving class.
       
   170             // Allow deriving class modify the consume value, even without 
       
   171             // creating a commmand (in case it wants to filter out a command)
       
   172             CMPXCommand* command = CreateCommandL(aCommandId, aList, consume);
       
   173 
       
   174             if (command)
       
   175                 {
       
   176                 CleanupStack::PushL(command);
       
   177 
       
   178                 if (CommandInfo(aCommandId).iStopAnimationForExecution)
       
   179                     {
       
   180                     // Stop GIF animation
       
   181                     iAppUi->ProcessCommandL(EGlxCmdDisableAnimations);
       
   182                     iAnimationStopped = ETrue;
       
   183                     }
       
   184 
       
   185                 // Add the pointer of this command handler as session id into the message
       
   186                 // This can be used to ensure that this object is the intended recipient
       
   187                 // of a message
       
   188                 command->SetTObjectValueL<TAny*> (
       
   189                         KMPXCommandGeneralSessionId,
       
   190                         static_cast<TAny*> (this));
       
   191 
       
   192                 aList.AddMediaListObserverL(this);
       
   193 
       
   194                 aList.CommandL(*command);
       
   195 
       
   196                 // raise progress note. Note will be closed when complete message received
       
   197                 // For EGlxCmdAddMedia we dont need to show dialog as EGlxCmdAddToAlbum or
       
   198                 // EGlxCmdAddTag will show processing dialog.
       
   199                 if (aCommandId != EGlxCmdAddMedia)
       
   200                     {
       
   201                     ProgressNoteL(aCommandId);
       
   202                     }
       
   203                 CleanupStack::PopAndDestroy(command);
       
   204                 }
       
   205             }
   157             }
   206         }
   158         }
   207     
   159     
   208     return consume;
   160     return consume;
   209     }
   161     }
   427             const CGlxMedia* media = aMediaList.Item(iterator++).Properties();
   379             const CGlxMedia* media = aMediaList.Item(iterator++).Properties();
   428         
   380         
   429             // noteText has a place for a title string in it
   381             // noteText has a place for a title string in it
   430             const TDesC& itemName = media->ValueText(KMPXMediaGeneralTitle);
   382             const TDesC& itemName = media->ValueText(KMPXMediaGeneralTitle);
   431     
   383     
   432             TBuf<KMaxFileName> text;
   384             TBuf<KGlxMaxNoteLength> text;
   433             StringLoader::Format(text, *noteText, -1, itemName);
   385             StringLoader::Format(text, *noteText, -1, itemName);
   434     
   386     
   435             // show popup
   387             // show popup
   436             confirmed = GlxGeneralUiUtilities::ConfirmQueryL(R_GLX_QUERY_YES_NO, text);
   388             confirmed = GlxGeneralUiUtilities::ConfirmQueryL(R_GLX_QUERY_YES_NO, text);
   437             }
   389             }
   462 
   414 
   463         // string has a place for number in it, and that number should be populated with selected
   415         // string has a place for number in it, and that number should be populated with selected
   464         // item count
   416         // item count
   465 		TInt count = aMediaList.SelectionCount();
   417 		TInt count = aMediaList.SelectionCount();
   466 
   418 
   467         TBuf<KMaxFileName> text;
   419         TBuf<KGlxMaxNoteLength> text;
   468 		GlxGeneralUiUtilities::FormatString(text, *noteText, -1, count, ETrue);
   420 		GlxGeneralUiUtilities::FormatString(text, *noteText, -1, count, ETrue);
   469 		
   421 		
   470         // show popup
   422         // show popup
   471 		confirmed = GlxGeneralUiUtilities::ConfirmQueryL(R_GLX_QUERY_YES_NO, text);
   423 		confirmed = GlxGeneralUiUtilities::ConfirmQueryL(R_GLX_QUERY_YES_NO, text);
   472 
   424 
   529     TRACER("CGlxMpxCommandCommandHandler::ProgressNoteL(TInt aCommandId)");
   481     TRACER("CGlxMpxCommandCommandHandler::ProgressNoteL(TInt aCommandId)");
   530 
   482 
   531     // get progress note 
   483     // get progress note 
   532     HBufC* progressText = ProgressTextL(aCommandId);
   484     HBufC* progressText = ProgressTextL(aCommandId);
   533     __ASSERT_DEBUG(progressText, Panic(EGlxPanicNullDescriptor));
   485     __ASSERT_DEBUG(progressText, Panic(EGlxPanicNullDescriptor));
   534     CleanupStack::PushL(progressText);
   486 	CleanupStack::PushL(progressText);
   535     // construct progress dialog
   487     // construct progress dialog
   536     iProgressDialog = new (ELeave) CAknProgressDialog(
   488 	iProgressDialog = new(ELeave)CAknProgressDialog(
   537             (REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
   489 			(REINTERPRET_CAST(CEikDialog**,&iProgressDialog)));
   538     iProgressDialog->PrepareLC(R_GLX_PROGRESS_NOTE);
   490 	iProgressDialog->PrepareLC(R_GLX_PROGRESS_NOTE); 
   539     if (aCommandId == EGlxCmdRename)
   491 	iProgressDialog->SetTextL(*progressText);
   540         {
   492 	iProgressDialog->SetCallback(this);
   541         iProgressDialog->ButtonGroupContainer().SetCommandSetL(
   493 	
   542                 R_AVKON_SOFTKEYS_EMPTY);
       
   543         }
       
   544     iProgressDialog->SetTextL(*progressText);
       
   545     iProgressDialog->SetCallback(this);
       
   546 
       
   547     // pick up progress info so that progress notification can be later updated
   494     // pick up progress info so that progress notification can be later updated
   548     iProgressInfo = iProgressDialog->GetProgressInfoL();
   495 	iProgressInfo = iProgressDialog->GetProgressInfoL();
   549 
   496 	
   550     // launch the note
   497     // launch the note
   551     iProgressDialog->RunLD();
   498 	iProgressDialog->RunLD();
   552     CleanupStack::PopAndDestroy(progressText);
   499 	CleanupStack::PopAndDestroy(progressText); 
   553     }
   500 	}
   554 
   501 
   555 // -----------------------------------------------------------------------------
   502 // -----------------------------------------------------------------------------
   556 // DismissProgressNoteL
   503 // DismissProgressNoteL
   557 // -----------------------------------------------------------------------------
   504 // -----------------------------------------------------------------------------
   558 //	
   505 //	
   750 	if (iProgressDialog)
   697 	if (iProgressDialog)
   751         {
   698         {
   752         TRAP_IGNORE(DismissProgressNoteL());
   699         TRAP_IGNORE(DismissProgressNoteL());
   753         }
   700         }
   754     }
   701     }
   755 
       
   756 // -----------------------------------------------------------------------------
       
   757 // CreateImageViewerInstanceL
       
   758 // -----------------------------------------------------------------------------
       
   759 //
       
   760 void CGlxMpxCommandCommandHandler::CreateImageViewerInstanceL()
       
   761     {
       
   762     TRACER("CGlxMpxCommandCommandHandler::CreateImageViewerInstanceL");
       
   763     iImageViewerInstance = CGlxImageViewerManager::InstanceL();    
       
   764     __ASSERT_ALWAYS(iImageViewerInstance, Panic(EGlxPanicNullPointer));
       
   765     }
       
   766 
       
   767 // -----------------------------------------------------------------------------
       
   768 // DeleteImageViewerInstance
       
   769 // -----------------------------------------------------------------------------
       
   770 //
       
   771 void CGlxMpxCommandCommandHandler::DeleteImageViewerInstance()
       
   772     {
       
   773     TRACER("CGlxMpxCommandCommandHandler::DeleteImageViewerInstance");
       
   774     if ( iImageViewerInstance )
       
   775         {
       
   776         iImageViewerInstance->DeleteInstance();
       
   777         }
       
   778     }