photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandleraiwprintpreview.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 27 Apr 2010 16:37:53 +0300
branchRCL_3
changeset 25 191387a8b767
parent 18 bcb43dc84c44
permissions -rw-r--r--
Revision: 201015 Kit: 201017

/*
* 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:    AIW print preview command handler
*
*/




#include "glxcommandhandleraiwprintpreview.h"
#include "glxaiwservicehandler.h"

#include <glxattributecontext.h>
#include <glxcommandhandlers.hrh>
#include <glxmedia.h>
#include <glxuiutilities.rsg>
#include <mglxmedialist.h>
#include <StringLoader.h>
#include <glxnavigationalstate.h>
#include <mpxcollectionpath.h>
#include <glxcollectionpluginimageviewer.hrh>

const TInt KGlxAiwPrintPreviewCommandSpace = 0x00000300;

// -----------------------------------------------------------------------------
// NewL
// -----------------------------------------------------------------------------
//	
EXPORT_C CGlxCommandHandlerAiwPrintPreview*
CGlxCommandHandlerAiwPrintPreview::NewL(
		MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource,
		const TDesC& aFileName)
	{
	CGlxCommandHandlerAiwPrintPreview* self =
			new (ELeave) CGlxCommandHandlerAiwPrintPreview(aMediaListProvider,
					aMenuResource);
	CleanupStack::PushL(self);
	self->ConstructL(aFileName);
	CleanupStack::Pop(self);
	return self;
	}
    
// -----------------------------------------------------------------------------
// CGlxCommandHandlerAiwPrintPreview::DoGetRequiredAttributesL
// -----------------------------------------------------------------------------
//	
void CGlxCommandHandlerAiwPrintPreview::DoGetRequiredAttributesL
									(RArray<TMPXAttribute>& aAttributes, TBool aFilterUsingSelection) const
	{
	if (!aFilterUsingSelection || SelectionLength() <= MaxSelectedItems())
		{
	    // Add MIME type and fileaname attributes
		aAttributes.AppendL(KMPXMediaGeneralMimeType);
		aAttributes.AppendL(KMPXMediaGeneralUri);
		}
	}

// -----------------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------------
//	
CGlxCommandHandlerAiwPrintPreview::CGlxCommandHandlerAiwPrintPreview(
        MGlxMediaListProvider* aMediaListProvider, TInt aMenuResource)
:   CGlxCommandHandlerAiwBase(aMediaListProvider, aMenuResource)
    {
    }
    
// -----------------------------------------------------------------------------
// CommandId
// -----------------------------------------------------------------------------
//	
TInt CGlxCommandHandlerAiwPrintPreview::CommandId() const
    {
    return EGlxCmdAiwPrint;
    }
    
// -----------------------------------------------------------------------------
// AiwCommandId
// -----------------------------------------------------------------------------
//	
TInt CGlxCommandHandlerAiwPrintPreview::AiwCommandId() const
    {
    return KAiwCmdPrint;
    }
    
// -----------------------------------------------------------------------------
// AiwInterestResource
// -----------------------------------------------------------------------------
//	
TInt CGlxCommandHandlerAiwPrintPreview::AiwInterestResource() const
    {
    return R_GLX_AIW_PRINT_INTEREST;
    }
        
// -----------------------------------------------------------------------------
// AppendAiwParameterL
// -----------------------------------------------------------------------------
//	
TBool CGlxCommandHandlerAiwPrintPreview::AppendAiwParameterL(const TGlxMedia& aItem, 
                                     CGlxAiwServiceHandler& aAiwServiceHandler)
    {
    return AppendDefaultAiwParameterL(  aItem, 
                                        aAiwServiceHandler, 
                                        ETrue,                  // Add the Uri
                                        ETrue);                 // Add the MineType
    }
    

// -----------------------------------------------------------------------------
// CommandSpace
// -----------------------------------------------------------------------------
//	
TInt CGlxCommandHandlerAiwPrintPreview::CommandSpace() const
    {
    return KGlxAiwPrintPreviewCommandSpace;
    }
    
// -----------------------------------------------------------------------------
// AiwDoDynInitMenuPaneL for PrintPreview
// -----------------------------------------------------------------------------
//
void CGlxCommandHandlerAiwPrintPreview::PreDynInitMenuPaneL(TInt aResourceId)
    {
    CGlxCommandHandlerAiwBase::PreDynInitMenuPaneL(aResourceId);
    }
// -----------------------------------------------------------------------------
// AiwDoDynInitMenuPaneL
// -----------------------------------------------------------------------------
//  
void CGlxCommandHandlerAiwPrintPreview::AiwDoDynInitMenuPaneL(TInt /*aResourceId*/, 
        CEikMenuPane* aMenuPane)
    {
    TBool fullscreenViewingMode = EFalse;
    CGlxNavigationalState* aNavigationalState = CGlxNavigationalState::InstanceL();
    CMPXCollectionPath* naviState = aNavigationalState->StateLC();
       
    if ( naviState->Levels() >= 1)
        {
        if (aNavigationalState->ViewingMode() == NGlxNavigationalState::EBrowse) 
            {
            if (naviState->Id() == TMPXItemId(KGlxCollectionPluginImageViewerImplementationUid))
                {
                fullscreenViewingMode = ETrue;
                }
            else
                {
                fullscreenViewingMode = EFalse;
                }
            } 
        else 
            {
            fullscreenViewingMode = ETrue;
            }                
        }
    CleanupStack::PopAndDestroy( naviState );
    aNavigationalState->Close();
      
    HBufC* currentTitle = StringLoader::LoadLC( R_QTN_LGAL_OPTIONS_PRINT_MENU );
    TInt cmdId = AiwMenuCmdIdL( *currentTitle,aMenuPane ) ;
    CleanupStack::PopAndDestroy(currentTitle);
    if( KErrNotFound != cmdId )
        {
        if ((MediaList().SelectionCount() == 0) && !fullscreenViewingMode)
            {
            aMenuPane->SetItemDimmed(cmdId,ETrue);    
            }
        }
    }