/*
 * ============================================================================
 *  Name     : CGreg2AppUi from Greg2AppUi.cpp
 *  Part of  : greg2
 *  Created  : 12/11/2002 by 
 *  Implementation notes:
 *     Initial content was generated by Series 60 AppWizard.
 *  Version  :
 *  Copyright: 
 * ============================================================================
 */

// INCLUDE FILES
#include "Greg2AppUi.h"
#include "Greg2Container.h" 
#include <greg2.rsg>
#include "greg2.hrh"

#include <avkon.hrh>

#include <e32std.h>
#include <stdio.h> //For fprintf()
#include <f32file.h>

#include "testauddevice.h"

// ================= MEMBER FUNCTIONS =======================
//
// ----------------------------------------------------------
// CGreg2AppUi::ConstructL()
// ?implementation_description
// ----------------------------------------------------------
//
void CGreg2AppUi::ConstructL()
{
    BaseConstructL();
    iAppContainer = new (ELeave) CGreg2Container;
    iAppContainer->SetMopParent(this);
    iAppContainer->ConstructL( ClientRect() );
    AddToStackL( iAppContainer );
}

// ----------------------------------------------------
// CGreg2AppUi::~CGreg2AppUi()
// Destructor
// Frees reserved resources
// ----------------------------------------------------
//
CGreg2AppUi::~CGreg2AppUi()
{
    if (iAppContainer)
    {
        RemoveFromStack( iAppContainer );
        delete iAppContainer;
    }
}

// ------------------------------------------------------------------------------
// CGreg2AppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
//  This function is called by the EIKON framework just before it displays
//  a menu pane. Its default implementation is empty, and by overriding it,
//  the application can set the state of menu items dynamically according
//  to the state of application data.
// ------------------------------------------------------------------------------
//
void CGreg2AppUi::DynInitMenuPaneL(
    TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
{
}

// ----------------------------------------------------
// CGreg2AppUi::HandleKeyEventL(
//     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
// ?implementation_description
// ----------------------------------------------------
//
TKeyResponse CGreg2AppUi::HandleKeyEventL(
    const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
{
    return EKeyWasNotConsumed;
}

// ----------------------------------------------------
// CGreg2AppUi::HandleCommandL(TInt aCommand)
// ?implementation_description
// ----------------------------------------------------
//
void CGreg2AppUi::HandleCommandL(TInt aCommand)
{
    bool launchTest = FALSE;
    
    switch ( aCommand )
    {
       case EAknSoftkeyBack:
       case EEikCmdExit:
       {
           Exit();
           break;
       }
       case Egreg2CmdAppTest:
       {
           iEikonEnv->InfoMsg(_L("Launching the audio test...."));
           launchTest = TRUE;
           break;
       }
       // TODO: Add Your command handling code here

       default:
           break;      
    }

    if( TRUE == launchTest )
    {
        //Call the test procedure...
        int ret = audioTestEntry();
        if( 0 == ret )
        {
            fprintf( stderr, "PASSED.....\n" ); 
        }
        else
        {
            fprintf( stderr, "FAILED.....\n" ); 
        }
    }
}

// End of File  
