⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 console.cpp

📁 symbian智能手机音乐播放器完整代码
💻 CPP
字号:
// ResourceManagement.cpp
//
// Copyright (c) 2000 Symbian Ltd.  All rights reserved.

#include <e32cons.h>
#include "activeconsole.h"
#include "oggtremortest.h"
#include "ogglog.h"

// All messages written to this
LOCAL_D CConsoleBase* console;

class CExampleScheduler : public CActiveScheduler
	{
public:
	void Error (TInt aError) const;
	};

void CExampleScheduler::Error(TInt aError) const
	{
	_LIT(KMsgSchedErr,"CExampleScheduler-error");
	User::Panic(KMsgSchedErr,aError);
	}

_LIT(KTxtEEMemMan,"Berthier Player");
_LIT(KTxtPressAnyKey," [press any key to quit]");

LOCAL_C void mainL()
    {
    console=Console::NewL(KTxtEEMemMan,TSize(KConsFullScreen,KConsFullScreen));
	CleanupStack::PushL(console);                // Push onto the cleanup stack
    // Active Object Scheduler
    CExampleScheduler*  exampleScheduler = new (ELeave) CExampleScheduler;
	CleanupStack::PushL(exampleScheduler);	     // Push onto the cleanup stack
	CActiveScheduler::Install(exampleScheduler); // Install as the active scheduler
  

    CIvorbisTest * vorbisDecoder;
    
    vorbisDecoder =  CIvorbisTest::NewL(console);
    CleanupStack::PushL( vorbisDecoder );

   
    // KeyPress handler
    CEventHandler * keypressHandler = new(ELeave) CEventHandler( console, vorbisDecoder );
    CleanupStack::PushL( keypressHandler );
    keypressHandler->ConstructL();
    keypressHandler->RequestCharacter();

    CActiveScheduler::Start();

    CleanupStack::PopAndDestroy(2); // CIvorbisTest, keypressHandler

	console->Printf(KTxtPressAnyKey);
	console->Getch(); // get and ignore character

    CleanupStack::PopAndDestroy(2); // Console, Active Scheduler
     
    COggLog::Exit();  // MUST BE AFTER LAST TRACE, otherwise will leak memory
    }

//////////////////////////////////////////////////////////////////////////////
//
// Main function called by E32
//
//////////////////////////////////////////////////////////////////////////////
GLDEF_C TInt E32Main() // main function called by E32
    {
	__UHEAP_MARK;

    // Cleanup Stack
	CTrapCleanup* cleanup=CTrapCleanup::New();
   
    // To use the CleanUp Stack, we have to start with a TRAPD before pushing anything.
    // Start the main function
    TRAPD(error,mainL());

    _LIT(KTxtMemMan,"MemMan");
	__ASSERT_ALWAYS(!error,User::Panic(KTxtMemMan,error));

	delete cleanup; // destroy clean-up stack
	__UHEAP_MARKEND;

	return 0; // and return
    }




///////////////////
// CActiveConsole
///////////////////

CActiveConsole::CActiveConsole( CConsoleBase* aConsole) 
: CActive(CActive::EPriorityUserInput)
// Construct high-priority active object
    {
    iConsole = aConsole;
    }

void CActiveConsole::ConstructL()
    {
    // Add to active scheduler
    CActiveScheduler::Add(this);
    }

CActiveConsole::~CActiveConsole()
    {
    // Make sure we're cancelled
    Cancel();
    }

void  CActiveConsole::DoCancel()
    {
    iConsole->ReadCancel();
    }

void  CActiveConsole::RunL()
    {
    // Handle completed request
    if (iAction == EWaitForKey)
        {
        ProcessKeyPress(TChar(iConsole->KeyCode()));
        }
    else
        {
        CActiveScheduler::Stop();
        }
    }

void CActiveConsole::RequestCharacter()
    {
    // A request is issued to the CConsoleBase to accept a
    // character from the keyboard. 
    iConsole->Read(iStatus); 
    SetActive();
    iAction = EWaitForKey;
    }

///////////////
// CEventHandler
///////////////

CEventHandler::CEventHandler(CConsoleBase* aConsole,MKeyPressObserver* anObserver)
:CActiveConsole(aConsole)
    {
    iObserver = anObserver;
    };



void CEventHandler::ProcessKeyPress(TChar aChar)
    {
    if ( iObserver->ProcessKeyPress(aChar) )
        RequestCharacter(); // Wait for an other keypress
    else
        CActiveScheduler::Stop();  // Leave the test.
    }

TAny * iPtr; // For TLS stuff

TInt Dll::SetTls(TAny* aPtr)
{
    iPtr = aPtr;
    return(KErrNone);
}

void * Dll::Tls(void)
{
    return(iPtr);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -