www.pudn.com > SystemSounds_Example_v1_0.zip > SystemSoundsView2.cpp


/* 
* ============================================================================ 
*  Name     : CSystemSoundsView2 from SystemSoundsView2.h 
*  Part of  : SystemSounds 
*  Created  : 06/12/2003 by Forum Nokia 
*  Implementation notes: 
*     Initial content was generated by Nokia Series 60 AppWizard. 
*  Version  : 1.0 
*  Copyright: Nokia 
* ============================================================================ 
*/ 
 
// INCLUDE FILES 
#include   
#include   
#include   
#include  "SystemSoundsView2.h" 
#include  "SystemSoundsContainer2.h"  
#include  "SystemSounds.hrh" 
 
// MACROS 
_LIT(KRingToneFileName, "z:\\System\\Sounds\\Simple\\alarm.rng"); 
 
 
// ================= MEMBER FUNCTIONS ======================= 
 
// --------------------------------------------------------- 
// CSystemSoundsView2::ConstructL(const TRect& aRect) 
// EPOC two-phased constructor 
// --------------------------------------------------------- 
// 
void CSystemSoundsView2::ConstructL() 
    { 
    BaseConstructL( R_SYSTEMSOUNDS_VIEW2 ); 
    } 
 
// --------------------------------------------------------- 
// CSystemSoundsView2::~CSystemSoundsView2() 
// ?implementation_description 
// --------------------------------------------------------- 
// 
CSystemSoundsView2::~CSystemSoundsView2() 
    { 
    if ( iContainer ) 
        { 
        AppUi()->RemoveFromViewStack( *this, iContainer ); 
        } 
 
    delete iContainer; 
    } 
 
// --------------------------------------------------------- 
// TUid CSystemSoundsView2::Id() 
// ?implementation_description 
// --------------------------------------------------------- 
// 
TUid CSystemSoundsView2::Id() const 
    { 
    return KView2Id; 
    } 
 
// --------------------------------------------------------- 
// CSystemSoundsView2::HandleCommandL(TInt aCommand) 
// ?implementation_description 
// --------------------------------------------------------- 
// 
void CSystemSoundsView2::HandleCommandL(TInt aCommand) 
    {    
    switch ( aCommand ) 
        { 
        case EAknSoftkeyBack: 
            { 
            AppUi()->HandleCommandL(EEikCmdExit); 
            break; 
            } 
        case ESystemSoundsView2Cmd1: 
            { 
             
            // Major sound types : 
            // TBaSystemSoundUid KSystemSoundRingUID	= {0x100048AB}; 
 
            // Minor type is optional.  
 
            // Set Sound Info, which is type and location for the sound 
 
            TBaSystemSoundType soundType(KSystemSoundRingUID); 
            TBaSystemSoundName soundName(KRingToneFileName); 
            TBaSystemSoundInfo soundInfo(soundType, soundName); 
 
            BaSystemSound::SetSoundL(CCoeEnv::Static()->FsSession(), soundInfo); 
            // Play sound if profile is not "Silent" or on "Meeting" 
            CoeSoundPlayer::PlaySoundNow (soundType); 
            } 
 
             
 
        default: 
            { 
            AppUi()->HandleCommandL( aCommand ); 
            break; 
            } 
        } 
    } 
 
// --------------------------------------------------------- 
// CSystemSoundsView2::HandleClientRectChange() 
// --------------------------------------------------------- 
// 
void CSystemSoundsView2::HandleClientRectChange() 
    { 
    if ( iContainer ) 
        { 
        iContainer->SetRect( ClientRect() ); 
        } 
    } 
 
// --------------------------------------------------------- 
// CSystemSoundsView2::DoActivateL(...) 
// --------------------------------------------------------- 
// 
void CSystemSoundsView2::DoActivateL( 
   const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, 
   const TDesC8& /*aCustomMessage*/) 
    { 
    if (!iContainer) 
        { 
        iContainer = new (ELeave) CSystemSoundsContainer2; 
        iContainer->SetMopParent(this); 
        iContainer->ConstructL( ClientRect() ); 
        AppUi()->AddToStackL( *this, iContainer ); 
        } 
   } 
 
// --------------------------------------------------------- 
// CSystemSoundsView2::HandleCommandL(TInt aCommand) 
// --------------------------------------------------------- 
// 
void CSystemSoundsView2::DoDeactivate() 
    { 
    if ( iContainer ) 
        { 
        AppUi()->RemoveFromViewStack( *this, iContainer ); 
        } 
     
    delete iContainer; 
    iContainer = NULL; 
    } 
 
// End of File