photosgallery/viewframework/commandhandlers/commoncommandhandlers/src/glxcommandhandlersave.cpp
branchRCL_3
changeset 26 5b3385a43d68
equal deleted inserted replaced
25:8e5f6eea9c9f 26:5b3385a43d68
       
     1 /*
       
     2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Save command handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "glxcommandhandlersave.h"
       
    20 
       
    21 #include <glxcommandhandlers.hrh>
       
    22 #include <glxscreenfurniture.h>
       
    23 #include <glxtracer.h>
       
    24 #include <DocumentHandler.h>
       
    25 #include <glxpanic.h>
       
    26 #include <glxuiutilities.rsg>
       
    27 #include <glxgeneraluiutilities.h>
       
    28 #include <StringLoader.h>
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // Two-phased constructor.
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 EXPORT_C CGlxCommandHandlerSave* CGlxCommandHandlerSave::NewL()
       
    35     {
       
    36     TRACER("CGlxCommandHandlerSave::NewL");
       
    37     CGlxCommandHandlerSave* self = new (ELeave) CGlxCommandHandlerSave();
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40     CleanupStack::Pop( self );
       
    41     return self;
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // C++ default constructor can NOT contain any code, that
       
    46 // might leave.
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CGlxCommandHandlerSave::CGlxCommandHandlerSave()
       
    50     {
       
    51     // Don't do anything.
       
    52     }
       
    53  
       
    54 // ---------------------------------------------------------------------------
       
    55 // Symbian 2nd phase constructor can leave.
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void CGlxCommandHandlerSave::ConstructL()
       
    59     {
       
    60     TRACER("CGlxCommandHandlerSave::ConstructL");    
       
    61     iImageViewerInstance = CGlxImageViewerManager::InstanceL();
       
    62 	}
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // Destructor
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CGlxCommandHandlerSave::~CGlxCommandHandlerSave()
       
    69     {
       
    70     TRACER("CGlxCommandHandlerSave::~CGlxCommandHandlerSave");
       
    71     if ( NULL != iImageViewerInstance)
       
    72         {
       
    73         iImageViewerInstance->DeleteInstance();
       
    74         }
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // Create save command
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 TBool CGlxCommandHandlerSave::ExecuteL(TInt aCommandId)
       
    82     {
       
    83     TRACER("CGlxCommandHandlerSave::ExecuteL");
       
    84     if(aCommandId == EGlxCmdSave)
       
    85     	{
       
    86         RFile64& imageHandle = iImageViewerInstance->ImageFileHandle();
       
    87     	if ( &imageHandle )
       
    88     	    {
       
    89             if ( imageHandle.SubSessionHandle() != KNullHandle )
       
    90                 {
       
    91                 TDataType nullType;
       
    92                 CDocumentHandler* handler = CDocumentHandler::NewLC(NULL);
       
    93                 __ASSERT_ALWAYS(handler, Panic(EGlxPanicNullPointer));
       
    94                 TInt err = handler->CopyL(imageHandle, KNullDesC, nullType, NULL);
       
    95                 CleanupStack::PopAndDestroy(handler);
       
    96                 if (err == KErrNone)
       
    97                     {
       
    98                     HBufC* noteText = StringLoader::LoadL(
       
    99                             R_GLX_COMPLETION_FILE_SAVED_TO);
       
   100                     if (noteText)
       
   101                         {
       
   102                         CleanupStack::PushL(noteText);
       
   103                         GlxGeneralUiUtilities::ShowConfirmationNoteL(
       
   104                                 *noteText, ETrue);
       
   105                         CleanupStack::PopAndDestroy(noteText);
       
   106                         }
       
   107                     }
       
   108                 }            
       
   109     		}
       
   110     	return ETrue;
       
   111     	}
       
   112     return EFalse;
       
   113     } 
       
   114 
       
   115 // ---------------------------------------------------------------------------
       
   116 // DynInitMenuPaneL
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CGlxCommandHandlerSave::DynInitMenuPaneL(TInt /*aResourceId*/, CEikMenuPane* aMenuPane,
       
   120                                                 TBool /*aIsBrowseMode*/)
       
   121     {
       
   122     TRACER("CGlxCommandHandlerSave::DynInitMenuPaneL");
       
   123     if ( aMenuPane )
       
   124         {
       
   125         TInt pos;
       
   126         if ( aMenuPane->MenuItemExists(EGlxCmdSave, pos) )
       
   127             {            
       
   128             if(!iImageViewerInstance->IsPrivate())
       
   129                 {
       
   130                 aMenuPane->DeleteMenuItem(EGlxCmdSave);
       
   131                 }
       
   132             }
       
   133         }
       
   134     }
       
   135 
       
   136 // ----------------------------------------------------------------------------
       
   137 // DoActivateL
       
   138 // ----------------------------------------------------------------------------
       
   139 void CGlxCommandHandlerSave::DoActivateL(TInt /*aViewId*/)
       
   140 	{
       
   141 	// Do Nothing
       
   142 	}
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // Deactivate
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 void CGlxCommandHandlerSave::Deactivate()
       
   149 	{
       
   150 	// Do Nothing
       
   151 	}
       
   152 
       
   153 // ----------------------------------------------------------------------------
       
   154 // OfferKeyEventL
       
   155 // ----------------------------------------------------------------------------
       
   156 TKeyResponse CGlxCommandHandlerSave::OfferKeyEventL(const TKeyEvent& aKeyEvent, 
       
   157 															TEventCode aType)
       
   158 	{
       
   159     TKeyResponse response = EKeyWasNotConsumed;
       
   160     // Is the key event from the Cancel (Backspace) key
       
   161 	if (aKeyEvent.iCode == EKeyBackspace && aType == EEventKey)
       
   162 		{
       
   163 		// try to execute the save command
       
   164 		if(ExecuteL( EGlxCmdSave ))
       
   165 		    {
       
   166     		response = EKeyWasConsumed;
       
   167 		    }
       
   168 		}
       
   169 	return response;	
       
   170 	}
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // PreDynInitMenuPaneL
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 void CGlxCommandHandlerSave::PreDynInitMenuPaneL( TInt /*aResourceId*/ )
       
   177 	{
       
   178 	// Do Nothing		
       
   179 	}
       
   180 		
       
   181 //End of file