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

00001 /* ====================================================================
00002  * File: handlerAppUi.cpp
00003  * Created: 09/27/05
00004  * Author: 
00005  * Copyright (c):  All rights reserved
00006  * ==================================================================== */
00007 
00008 #include <avkon.hrh>
00009 #include <aknnotewrappers.h> 
00010 
00011 #include <utf.h>
00012 
00013 #include "handler.pan"
00014 #include "handlerAppUi.h"
00015 #include "handlerAppView.h"
00016 #include "handler.hrh"
00017 #include "handlerDocument.h"
00018 
00019 #include <DocumentHandler.h>
00020 #include <eikenv.h> 
00021 #include <eikappui.h>
00022 #include <eikapp.h>
00023 #include <APPARC.H>
00024 #include <eikproc.H>
00025 #include <apmstd.h> //TDAtatype, Link against: apmime.lib 
00026 
00027 #include <handler.rsg>
00028 #include <eikbtgpc.h> //CEikButtonGroupContainer
00029 
00030 #define KEnableSkinFlag 0x1000
00031 #define KLayoutAwareFlag 0x08
00032 
00033 void CHandlerAppUi::ConstructL()
00034     {
00035     #ifdef __SERIES60_3X__
00036             BaseConstructL(EAknEnableSkin);
00037         #else
00038             BaseConstructL(KEnableSkinFlag | KLayoutAwareFlag);
00039         #endif
00040 
00041     iAppView = CHandlerAppView::NewL(ClientRect());    
00042 
00043     if (IsEmbedded())
00044         {
00045         //If the handler application is launched as embedded 
00046         //then set the right softkey to "Back"
00047         CEikButtonGroupContainer * iCba = CEikButtonGroupContainer::Current();
00048         if( iCba) 
00049                 {
00050                 iCba->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK );
00051                 iCba->DrawNow(); 
00052                 }        
00053         }
00054 
00055     AddToStackL(iAppView);
00056     }
00057 
00058 CHandlerAppUi::CHandlerAppUi()                              
00059     {
00060         // no implementation required
00061     }
00062 
00063 CHandlerAppUi::~CHandlerAppUi()
00064     {
00065     if (iAppView)
00066         {
00067         RemoveFromStack(iAppView);
00068         delete iAppView;
00069         iAppView = NULL;
00070         }
00071         
00072     //This only works in 1st and 2nd edition
00073     if( iDoorObserver )
00074         {        
00075         iDoorObserver->NotifyExit( MApaEmbeddedDocObserver::ENoChanges );            
00076         }
00077         
00078     }
00079 
00080 // handle any menu commands
00081 void CHandlerAppUi::HandleCommandL(TInt aCommand)
00082     {
00083     switch(aCommand)
00084         {
00085         case EEikCmdExit:
00086         case EAknSoftkeyBack:
00087             //The application was embedded, now just closes this and
00088             //goes back to the launcher application
00089             
00090         case EAknSoftkeyExit:
00091             //Closes the possible launcher app also if launched embedded
00092             //In the embedded case the Exit was choosen from the options
00093             //menu
00094             if( iDoorObserver )
00095                 {
00096                 SaveL();
00097                 }
00098             Exit();
00099             break;
00100 
00101         default:
00102             Panic(EhandlerBasicUi);
00103             break;
00104         }
00105     }
00106 
00107 void CHandlerAppUi::SetFileData(TFileName& aFileName, TDes8& aData)
00108     {
00109     if (iAppView)
00110         {
00111         iAppView->SetFileData(aFileName,aData);
00112         }
00113     }
00114 
00115 void CHandlerAppUi::HandleResourceChangeL(TInt aType)
00116         {
00117         CAknAppUi::HandleResourceChangeL(aType); //call to upper class
00118 
00119     // ADDED FOR SCALABLE UI SUPPORT
00120     // *****************************
00121         //if ( aType == KEikDynamicLayoutVariantSwitch )
00122         //hard coded constant so it can be compiled with first edition
00123         
00124         if ( aType == 0x101F8121 )
00125             {
00126             iAppView->SetRect( ClientRect() );
00127             }
00128         }
00129 
00130 TBool CHandlerAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/,TFileName& /*aDocumentName*/)
00131     {
00132     return ETrue;
00133     }
00134 
00135 TBool CHandlerAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/,TFileName& /*aDocumentName*/,const TDesC8& /*aTail*/)
00136     {
00137     //return true here so that document's OpenFileL gets called
00138     return ETrue;
00139     }
00140 
00141 
00142 
00143 void CHandlerAppUi::OpenFileL(const TDesC& aFileName)
00144         {
00145         // File changed. Open new file with documents OpenFileL method.
00146         CHandlerDocument* doc = static_cast<CHandlerDocument*> (Document());
00147         doc->OpenFileL( ETrue, aFileName, iEikonEnv->FsSession() );    
00148         }
00149 TBool CHandlerAppUi::IsEmbedded()
00150     {
00151     #ifdef __SERIES60_3X__
00152     return iEikonEnv->StartedAsServerApp();
00153     #else
00154     return (iDoorObserver != NULL);
00155     #endif
00156     }
00157         
00158 //End of file

Generated by  doxygen 1.6.2