diff -r 9a9c174934f5 -r 57d388cc48c1 photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandleraiwedit.cpp --- a/photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandleraiwedit.cpp Tue Jan 26 11:58:28 2010 +0200 +++ b/photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandleraiwedit.cpp Tue Feb 02 00:10:37 2010 +0200 @@ -26,145 +26,169 @@ #include #include +#include +#include +#include + #include "glxaiwservicehandler.h" #include #include #include #include +#include // for passing data between applications +#include "AiwServiceHandler.h" // AIW service handler +#include "glxmedia.h" + const TInt KGlxAiwEditCommandSpace = 0x00000200; // ----------------------------------------------------------------------------- // NewL // ----------------------------------------------------------------------------- // -EXPORT_C CGlxCommandHandlerAiwEdit* CGlxCommandHandlerAiwEdit::NewL( - MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource, - TBool aCommandSingleClick) +EXPORT_C CGlxCommandHandlerAiwEdit* CGlxCommandHandlerAiwEdit::NewL(MGlxMediaListProvider* aMediaListProvider, TBool aCommandSingleClick) { - CGlxCommandHandlerAiwEdit* self = new ( ELeave ) - CGlxCommandHandlerAiwEdit(aMediaListProvider, aMenuResource); - CleanupStack::PushL( self ); - self->ConstructL(aCommandSingleClick); - CleanupStack::Pop( self ); + CGlxCommandHandlerAiwEdit* self = new (ELeave) CGlxCommandHandlerAiwEdit(aMediaListProvider, aCommandSingleClick); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); return self; } -// --------------------------------------------------------------------------- -// Symbian 2nd phase constructor can leave. -// --------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- +// ~CGlxCommandHandlerAiwEdit +// ----------------------------------------------------------------------------- +// +EXPORT_C CGlxCommandHandlerAiwEdit::~CGlxCommandHandlerAiwEdit() + { + delete iServiceHandler; + } + +// ----------------------------------------------------------------------------- +// ConstructL +// ----------------------------------------------------------------------------- // -void CGlxCommandHandlerAiwEdit::ConstructL(TBool aCommandSingleClick) +void CGlxCommandHandlerAiwEdit::ConstructL() { - TRACER("CGlxCommandHandlerAiwEdit::ConstructL"); - CGlxCommandHandlerAiwBase::ConstructL(); - iCommandSingleClick = aCommandSingleClick; + TRAP_IGNORE( + { + iServiceHandler = CAiwServiceHandler::NewL(); + iServiceHandler->AttachL( R_GLX_AIW_EDIT_INTEREST ); + iEditSupported = ETrue; + } ); + + if(iCommandSingleClick) + { + TCommandInfo info(EGlxCmdAiwSingleClickEdit); + AddCommandL(info); + } + else + { + TCommandInfo info(EGlxCmdAiwEdit); + AddCommandL(info); + } + } + +// ----------------------------------------------------------------------------- +// CGlxCommandHandlerAiwEdit +// ----------------------------------------------------------------------------- +// +CGlxCommandHandlerAiwEdit::CGlxCommandHandlerAiwEdit( MGlxMediaListProvider* aMediaListProvider, TBool aCommandSingleClick ) + :CGlxMediaListCommandHandler(aMediaListProvider), + iCommandSingleClick(aCommandSingleClick) + { + // Do Nothing + } + +// ----------------------------------------------------------------------------- +// DoActivateL +// ----------------------------------------------------------------------------- +// +void CGlxCommandHandlerAiwEdit::DoActivateL(TInt /*aViewId*/) + { + // DO Nothing } // ----------------------------------------------------------------------------- -// CGlxCommandHandlerAiwEdit::DoGetRequiredAttributesL -// ----------------------------------------------------------------------------- -// -void CGlxCommandHandlerAiwEdit::DoGetRequiredAttributesL - (RArray& aAttributes, TBool aFilterUsingSelection) const - { - if (!aFilterUsingSelection || SelectionLength() <= MaxSelectedItems()) - { - // Add MIME type and fileaname attributes - aAttributes.AppendL(KMPXMediaGeneralMimeType); - aAttributes.AppendL(KMPXMediaGeneralUri); - } - } - -// ----------------------------------------------------------------------------- -// Constructor +// DynInitMenuPaneL // ----------------------------------------------------------------------------- -// -CGlxCommandHandlerAiwEdit::CGlxCommandHandlerAiwEdit( - MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource) -: CGlxCommandHandlerAiwBase(aMediaListProvider, aMenuResource) +// +void CGlxCommandHandlerAiwEdit::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) { - } + MGlxMediaList& mediaList = MediaList(); + TInt pos; -// ----------------------------------------------------------------------------- -// CommandId -// ----------------------------------------------------------------------------- -// -TInt CGlxCommandHandlerAiwEdit::CommandId() const - { - if (iCommandSingleClick) + if (aMenuPane && iCommandSingleClick && aMenuPane->MenuItemExists(EGlxCmdAiwSingleClickEdit, pos) + && (mediaList.SelectionCount() > 1)) { - return EGlxCmdAiwSingleClickEdit; + aMenuPane->SetItemDimmed(EGlxCmdAiwSingleClickEdit, ETrue); } - return EGlxCmdAiwEdit; - } - -// ----------------------------------------------------------------------------- -// AiwCommandId -// ----------------------------------------------------------------------------- -// -TInt CGlxCommandHandlerAiwEdit::AiwCommandId() const - { - return KAiwCmdEdit; - } - -// ----------------------------------------------------------------------------- -// AiwInterestResource -// ----------------------------------------------------------------------------- -// -TInt CGlxCommandHandlerAiwEdit::AiwInterestResource() const - { - if (iCommandSingleClick) + else if (aMenuPane && aMenuPane->MenuItemExists(EGlxCmdAiwEdit, pos) + && (mediaList.SelectionCount() != 1) && !IsInFullScreenViewingModeL()) { - return R_GLX_AIW_SINGLE_CLICK_EDIT_INTEREST; - } - return R_GLX_AIW_EDIT_INTEREST; - } - -// ----------------------------------------------------------------------------- -// AppendAiwParameterL -// ----------------------------------------------------------------------------- -// -TBool CGlxCommandHandlerAiwEdit::AppendAiwParameterL(const TGlxMedia& aItem, - CGlxAiwServiceHandler& aAiwServiceHandler) - { - return AppendDefaultAiwParameterL( aItem, - aAiwServiceHandler, - ETrue, // Add the Uri - ETrue); // Add the Mime Type - + aMenuPane->SetItemDimmed(EGlxCmdAiwEdit, ETrue); + } + } // ----------------------------------------------------------------------------- -// CommandSpace +// DoExecuteL // ----------------------------------------------------------------------------- -// -TInt CGlxCommandHandlerAiwEdit::CommandSpace() const - { - return KGlxAiwEditCommandSpace; - } - -// ----------------------------------------------------------------------------- -// AiwDoDynInitMenuPaneL -// ----------------------------------------------------------------------------- -// -void CGlxCommandHandlerAiwEdit::AiwDoDynInitMenuPaneL(TInt /*aResourceId*/, - CEikMenuPane* aMenuPane) +// +TBool CGlxCommandHandlerAiwEdit::DoExecuteL( TInt aCommandId , MGlxMediaList& aList) { - TRACER("CGlxCommandHandlerAiwEdit::AiwDoDynInitMenuPaneL()"); - HBufC* currentTitle = StringLoader::LoadLC( R_QTN_LGAL_OPTIONS_EDIT ); - TInt cmdId = AiwMenuCmdIdL( *currentTitle,aMenuPane ) ; - CleanupStack::PopAndDestroy(currentTitle); + TBool handled = EFalse; + if (iEditSupported && (EGlxCmdAiwEdit == aCommandId || EGlxCmdAiwSingleClickEdit == aCommandId)) + { + CAiwGenericParamList& inputParams = iServiceHandler->InParamListL(); + + TGlxSelectionIterator iterator; + iterator.SetToFirst(&aList); + TInt index = iterator++; + const TGlxMedia& mediaItem = aList.Item(index); + + TAiwGenericParam param( EGenericParamFile, TAiwVariant(mediaItem.Uri())); + inputParams.AppendL( param ); + + TAiwGenericParam param2( EGenericParamMIMEType, TAiwVariant(mediaItem.MimeType())); + inputParams.AppendL( param2 ); + + // Execute the KAiwCmdUpload command EGlxCmdAiwEdit + iServiceHandler->ExecuteServiceCmdL(KAiwCmdEdit, inputParams, iServiceHandler->OutParamListL()); - if (KErrNotFound != cmdId) + handled = ETrue; + } + return handled; + } + +// ----------------------------------------------------------------------------- +// IsInFullScreenViewingModeL +// ----------------------------------------------------------------------------- +// +TBool CGlxCommandHandlerAiwEdit::IsInFullScreenViewingModeL() + { + TRACER("CGlxCommandHandlerAiwEdit::IsInFullScreenViewingModeL()"); + TBool fullscreenViewingMode = EFalse; + CGlxNavigationalState* aNavigationalState = CGlxNavigationalState::InstanceL(); + CMPXCollectionPath* naviState = aNavigationalState->StateLC(); + + if ( naviState->Levels() >= 1) { - if (iCommandSingleClick && (MediaList().SelectionCount() > 1)) + if (aNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) { - aMenuPane->SetItemDimmed(cmdId,ETrue); - } - else if ( MediaList().SelectionCount() != 1) + // For image viewer collection, goto view mode + if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid)) + { + //it means we are in img viewer + fullscreenViewingMode = ETrue; + } + } + else { - // Enable ONLY when a single item marked - aMenuPane->SetItemDimmed(cmdId,ETrue); - } + //it means we are in Fullscreen + fullscreenViewingMode = ETrue; + } } + CleanupStack::PopAndDestroy( naviState ); + aNavigationalState->Close(); + return fullscreenViewingMode; }