diff -r 000000000000 -r 4e91876724a2 photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlersave.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlersave.cpp Thu Dec 17 08:45:44 2009 +0200 @@ -0,0 +1,197 @@ +/* +* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Delete command handler +* +*/ + + + + +#include "glxcommandhandlersave.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // for CGlxResourceUtilities +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "glxcommandfactory.h" + + + + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +EXPORT_C CGlxCommandHandlerSave* CGlxCommandHandlerSave::NewL( + MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem) + { + TRACER("CGlxCommandHandlerSave::NewL"); + CGlxCommandHandlerSave* self = new (ELeave) CGlxCommandHandlerSave(aMediaListProvider, aHasToolbarItem); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// C++ default constructor can NOT contain any code, that +// might leave. +// --------------------------------------------------------------------------- +// +CGlxCommandHandlerSave::CGlxCommandHandlerSave(MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem) + : CGlxMpxCommandCommandHandler( aMediaListProvider, aHasToolbarItem ) + { + // Don't do anything. + } + +// --------------------------------------------------------------------------- +// Symbian 2nd phase constructor can leave. +// --------------------------------------------------------------------------- +// +void CGlxCommandHandlerSave::ConstructL() + { + TRACER("CGlxCommandHandlerSave::ConstructL"); + iUiUtility = CGlxUiUtility::UtilityL(); + iImageViewerInstance = CGlxImageViewerManager::InstanceL(); + // Load resource file + TParse parse; + parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); + TFileName resourceFile; + resourceFile.Append(parse.FullName()); + CGlxResourceUtilities::GetResourceFilenameL(resourceFile); + iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resourceFile); + + // Add supported command + TCommandInfo saveInfo( EGlxCmdSave ); + // Filter out static items + saveInfo.iMinSelectionLength = 1; + AddCommandL(saveInfo); + } + +// --------------------------------------------------------------------------- +// Destructor +// --------------------------------------------------------------------------- +// +EXPORT_C CGlxCommandHandlerSave::~CGlxCommandHandlerSave() + { + TRACER("CGlxCommandHandlerSave::~CGlxCommandHandlerSave"); + if (iResourceOffset) + { + CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); + } + if(iUiUtility) + { + iUiUtility->Close(); + } + if ( NULL != iImageViewerInstance) + { + iImageViewerInstance->DeleteInstance(); + } + } + +// --------------------------------------------------------------------------- +// Create an add to container command +// --------------------------------------------------------------------------- +// +CMPXCommand* CGlxCommandHandlerSave::CreateCommandL(TInt /*aCommandId*/, + MGlxMediaList& /*aMediaList*/, TBool& /*aConsume*/) const + { + TRACER("CGlxCommandHandlerSave::CreateCommandL"); + CMPXCommand* command = NULL; + TDataType nullType; + CDocumentHandler* handler = CDocumentHandler::NewLC( NULL ); + HBufC* imagePath = iImageViewerInstance->ImageUri(); + TInt err = handler->CopyL( *imagePath, *imagePath, nullType, NULL ); + CleanupStack::PopAndDestroy(handler); + return command; + } +// --------------------------------------------------------------------------- +// DynInitMenuPaneL +// --------------------------------------------------------------------------- +// +void CGlxCommandHandlerSave::DynInitMenuPaneL(TInt /*aResourceId*/, CEikMenuPane* aMenuPane) + { + TRACER("CGlxCommandHandlerSave::DynInitMenuPaneL"); + if ( aMenuPane ) + { + TInt pos; + if ( aMenuPane->MenuItemExists(EGlxCmdSave, pos) ) + { + if(!iImageViewerInstance->IsPrivate()) + { + aMenuPane->DeleteMenuItem(EGlxCmdSave); + } + } + } + } + +// ---------------------------------------------------------------------------- +// DoActivateL +// ---------------------------------------------------------------------------- +void CGlxCommandHandlerSave::DoActivateL(TInt /*aViewId*/) + { + + } + +// ---------------------------------------------------------------------------- +// OfferKeyEventL +// ---------------------------------------------------------------------------- +TKeyResponse CGlxCommandHandlerSave::OfferKeyEventL(const TKeyEvent& aKeyEvent, + TEventCode aType) + { + TKeyResponse response = EKeyWasNotConsumed; + // Is the key event from the Cancel (Backspace) key + if (aKeyEvent.iCode == EKeyBackspace && aType == EEventKey) + { + // try to execute the delete command + if(ExecuteL( EGlxCmdSave )) + { + response = EKeyWasConsumed; + } + } + return response; + } + +// ---------------------------------------------------------------------------- +// PopulateToolbar +// ---------------------------------------------------------------------------- +// +void CGlxCommandHandlerSave::PopulateToolbarL() + { + TRACER( "CGlxCommandHandlerRename::PopulateToolbar" ); + + iUiUtility->ScreenFurniture()->SetTooltipL( EGlxCmdSave, CAknButton::EPositionLeft ); + } + +