// TCONE0.CPP
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

#include <coeauis.h>
#include <coemain.h>
#include <coedef.h>
#include <basched.h>
#include <basndut.h>

class CTestAppUi : public CCoeAppUiSimple
    {
private: // from CCoeAppUiSimple
    void HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
    void HandleForegroundEventL(TBool aForeground);
private: // utility
	void Beep(TInt aFrequency);
    };

void CTestAppUi::Beep(TInt aFrequency)
	{
	SoundUtilities::PlayTone(aFrequency,100000,100,SoundUtilities::EToneQuiet);
	}
	
void CTestAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    Beep(1760+(aType-EEventKey)*220);
    if (aType==EEventKey && aKeyEvent.iCode==CTRL('e'))
		CBaActiveScheduler::Exit();
    }

void CTestAppUi::HandleForegroundEventL(TBool aForeground)
    {
    Beep(aForeground? 1500: 1200);
    }

void ConstructAppL(CCoeEnv* aCoe)
    { // runs inside a TRAP harness
    aCoe->ConstructL();
    CTestAppUi* appUi=new(ELeave) CTestAppUi;
    aCoe->SetAppUi(appUi);
    }

#if defined(__WINS__)
EXPORT_C TInt EntryPoint(TAny*)
#else
GLDEF_C TInt E32Main()
#endif
    {
    CCoeEnv* coe=new CCoeEnv;
    TRAPD(err,ConstructAppL(coe));
    if (!err)
        coe->ExecuteD();
    return(err);
    }

#if defined(__WINS__)
GLDEF_C TInt E32Dll(TDllReason)
	{
	return(KErrNone);
	}
#endif
