examples/ForumNokia/Document_Handler_Example/HandlerApp/src/handlerAppui.cpp

00001 /*
00002  * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003  *    
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *    
00007  *  * Redistributions of source code must retain the above copyright notice, this
00008  *    list of conditions and the following disclaimer.
00009  *  * Redistributions in binary form must reproduce the above copyright notice,
00010  *    this list of conditions and the following disclaimer in the documentation
00011  *    and/or other materials provided with the distribution.
00012  *  * Neither the name of Nokia Corporation nor the names of its contributors
00013  *    may be used to endorse or promote products derived from this software
00014  *    without specific prior written permission.
00015  *    
00016  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  *    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  *    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  *    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  *    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  *    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023  *    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *    
00027  *    Description:  
00028  */
00029 
00030 #include <avkon.hrh>
00031 #include <aknnotewrappers.h> 
00032 
00033 #include <utf.h>
00034 
00035 #include "handler.pan"
00036 #include "handlerAppUi.h"
00037 #include "handlerAppView.h"
00038 #include "handler.hrh"
00039 #include "handlerDocument.h"
00040 
00041 #include <DocumentHandler.h>
00042 #include <eikenv.h> 
00043 #include <eikappui.h>
00044 #include <eikapp.h>
00045 #include <APPARC.H>
00046 #include <eikproc.H>
00047 #include <apmstd.h> //TDAtatype, Link against: apmime.lib 
00048 
00049 #include <handler.rsg>
00050 #include <eikbtgpc.h> //CEikButtonGroupContainer
00051 
00052 #define KEnableSkinFlag 0x1000
00053 #define KLayoutAwareFlag 0x08
00054 
00055 void CHandlerAppUi::ConstructL()
00056     {
00057     #ifdef __SERIES60_3X__
00058             BaseConstructL(EAknEnableSkin);
00059         #else
00060             BaseConstructL(KEnableSkinFlag | KLayoutAwareFlag);
00061         #endif
00062 
00063     iAppView = CHandlerAppView::NewL(ClientRect());    
00064 
00065     if (IsEmbedded())
00066         {
00067         //If the handler application is launched as embedded 
00068         //then set the right softkey to "Back"
00069         CEikButtonGroupContainer * iCba = CEikButtonGroupContainer::Current();
00070         if( iCba) 
00071                 {
00072                 iCba->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK );
00073                 iCba->DrawNow(); 
00074                 }        
00075         }
00076 
00077     AddToStackL(iAppView);
00078     }
00079 
00080 CHandlerAppUi::CHandlerAppUi()                              
00081     {
00082         // no implementation required
00083     }
00084 
00085 CHandlerAppUi::~CHandlerAppUi()
00086     {
00087     if (iAppView)
00088         {
00089         RemoveFromStack(iAppView);
00090         delete iAppView;
00091         iAppView = NULL;
00092         }
00093         
00094     //This only works in 1st and 2nd edition
00095     if( iDoorObserver )
00096         {        
00097         iDoorObserver->NotifyExit( MApaEmbeddedDocObserver::ENoChanges );            
00098         }
00099         
00100     }
00101 
00102 // handle any menu commands
00103 void CHandlerAppUi::HandleCommandL(TInt aCommand)
00104     {
00105     switch(aCommand)
00106         {
00107         case EEikCmdExit:
00108         case EAknSoftkeyBack:
00109             //The application was embedded, now just closes this and
00110             //goes back to the launcher application
00111             
00112         case EAknSoftkeyExit:
00113             //Closes the possible launcher app also if launched embedded
00114             //In the embedded case the Exit was choosen from the options
00115             //menu
00116             if( iDoorObserver )
00117                 {
00118                 SaveL();
00119                 }
00120             Exit();
00121             break;
00122 
00123         default:
00124             Panic(EhandlerBasicUi);
00125             break;
00126         }
00127     }
00128 
00129 void CHandlerAppUi::SetFileData(TFileName& aFileName, TDes8& aData)
00130     {
00131     if (iAppView)
00132         {
00133         iAppView->SetFileData(aFileName,aData);
00134         }
00135     }
00136 
00137 void CHandlerAppUi::HandleResourceChangeL(TInt aType)
00138         {
00139         CAknAppUi::HandleResourceChangeL(aType); //call to upper class
00140 
00141     // ADDED FOR SCALABLE UI SUPPORT
00142     // *****************************
00143         //if ( aType == KEikDynamicLayoutVariantSwitch )
00144         //hard coded constant so it can be compiled with first edition
00145         
00146         if ( aType == 0x101F8121 )
00147             {
00148             iAppView->SetRect( ClientRect() );
00149             }
00150         }
00151 
00152 TBool CHandlerAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/,TFileName& /*aDocumentName*/)
00153     {
00154     return ETrue;
00155     }
00156 
00157 TBool CHandlerAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/,TFileName& /*aDocumentName*/,const TDesC8& /*aTail*/)
00158     {
00159     //return true here so that document's OpenFileL gets called
00160     return ETrue;
00161     }
00162 
00163 
00164 
00165 void CHandlerAppUi::OpenFileL(const TDesC& aFileName)
00166         {
00167         // File changed. Open new file with documents OpenFileL method.
00168         CHandlerDocument* doc = static_cast<CHandlerDocument*> (Document());
00169         doc->OpenFileL( ETrue, aFileName, iEikonEnv->FsSession() );    
00170         }
00171 TBool CHandlerAppUi::IsEmbedded()
00172     {
00173     #ifdef __SERIES60_3X__
00174     return iEikonEnv->StartedAsServerApp();
00175     #else
00176     return (iDoorObserver != NULL);
00177     #endif
00178     }
00179         
00180 //End of file

Generated by  doxygen 1.6.2