S60 3rd Edition SDK for Symbian OS
Example Applications Guide

MessagingAppui.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : MessagingAppui.cpp
00004 *  Part of     : Messaging
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2005-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include <sendui.h>
00018 #include <SendUiConsts.h>
00019 #include <CMessageData.h> 
00020 #include <Messaging.rsg>
00021 #include "Messaging.hrh"
00022 #include "MessagingAppui.h"
00023 #include "MessagingContainer.h" 
00024 
00025 // ================= MEMBER FUNCTIONS ==========================================
00026 
00027 // -----------------------------------------------------------------------------
00028 // CMessagingAppUi::ConstructL()
00029 // Symbian two-phased constructor
00030 // -----------------------------------------------------------------------------
00031 //
00032 void CMessagingAppUi::ConstructL()
00033     {
00034     BaseConstructL( CAknAppUi::EAknEnableSkin );
00035     iAppContainer = CMessagingContainer::NewL( ClientRect() );
00036     iAppContainer->SetMopParent( this );
00037     AddToStackL( iAppContainer );    
00038     iSendUi = CSendUi::NewL();    
00039     }
00040 
00041 // -----------------------------------------------------------------------------
00042 // CMessagingAppUi::~CMessagingAppUi()
00043 // Destructor
00044 // Frees reserved resources
00045 // -----------------------------------------------------------------------------
00046 //
00047 CMessagingAppUi::~CMessagingAppUi()
00048     {
00049     if ( iAppContainer )
00050         {
00051         RemoveFromStack( iAppContainer );
00052         delete iAppContainer;
00053                 iAppContainer = NULL;
00054         }
00055     if ( iSendUi )
00056             {
00057             delete iSendUi;
00058             iSendUi = NULL;
00059             }
00060     }
00061 
00062 // -----------------------------------------------------------------------------
00063 // CMessagingAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
00064 //  This function is called by the EIKON framework just before it displays
00065 //  a menu pane. Its default implementation is empty, and by overriding it,
00066 //  the application can set the state of menu items dynamically according
00067 //  to the state of application data.
00068 // -----------------------------------------------------------------------------
00069 //
00070 void CMessagingAppUi::DynInitMenuPaneL( TInt, CEikMenuPane* )
00071     {
00072     // no implementation needed here
00073     }
00074 
00075 // -----------------------------------------------------------------------------
00076 // CMessagingAppUi::HandleKeyEventL(
00077 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
00078 // takes care of key event handling
00079 // -----------------------------------------------------------------------------
00080 //
00081 TKeyResponse CMessagingAppUi::HandleKeyEventL( const TKeyEvent&, TEventCode )
00082     {
00083     return EKeyWasNotConsumed;
00084     }
00085 
00086 // -----------------------------------------------------------------------------
00087 // CMessagingAppUi::HandleCommandL(TInt aCommand)
00088 // takes care of command handling
00089 // -----------------------------------------------------------------------------
00090 //
00091 void CMessagingAppUi::HandleCommandL( TInt aCommand )
00092     {
00093     switch ( aCommand )
00094         {
00095         case EAknSoftkeyExit:
00096         case EEikCmdExit:
00097             {
00098             Exit();
00099             break;
00100             }        
00101         case EMessagingCmdCreateSMS:
00102                 {
00103                 // create and send SMS
00104                 CreateAndSendMessageL( KSenduiMtmSmsUid );
00105                 break;  
00106                 }
00107         case EMessagingCmdCreateMMS:
00108                 {
00109                 // create and send MMS
00110                 CreateAndSendMessageL( KSenduiMtmMmsUid );
00111                 break;  
00112                 }
00113         case EMessagingCmdCreateEmail:
00114                 {
00115                 // create and send email
00116                 CreateAndSendMessageL( KSenduiMtmSmtpUid );     
00117                 break;  
00118                 }       
00119         default:
00120             break;      
00121         }
00122     }
00123 
00124 
00125 // -----------------------------------------------------------------------------
00126 // CMessagingAppUi::CreateAndSendMessageL(const TUid aServiceUid)
00127 // Starts message editor via CSendUi class. 
00128 // Message type is defined in parameter aServiceUid.
00129 // -----------------------------------------------------------------------------
00130 //
00131 void CMessagingAppUi::CreateAndSendMessageL( const TUid aServiceUid )
00132         {
00133         // create empty message
00134         CMessageData*  message = CMessageData::NewLC(); 
00135         // start message editor through SendUI
00136         iSendUi->CreateAndSendMessageL( aServiceUid, message, KNullUid );
00137         CleanupStack::PopAndDestroy( message );
00138         }
00139 
00140 // -----------------------------------------------------------------------------
00141 // CMessagingAppUi::HandleResourceChangeL( TInt aType )
00142 // takes care of command handling
00143 // -----------------------------------------------------------------------------
00144 //
00145 void CMessagingAppUi::HandleResourceChangeL( TInt aType )
00146     {
00147     CAknAppUi::HandleResourceChangeL( aType );
00148     if ( aType==KEikDynamicLayoutVariantSwitch )
00149         {
00150         iAppContainer->SetRect( ClientRect() );
00151         }
00152     }
00153 // End of File  

© Nokia 2006

Back to top