?? controller.cpp
字號:
// controller.cpp
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.
//
#include "controller.h"
#include "appview.h"
#include <eikenv.h>
#include <eiklabel.h>
// Controller
void CGameController::ConstructL(CEikAppUi* aAppUi)
{
// store cached pointers
iAppUi=aAppUi;
iEnv=CEikonEnv::Static();
// construct GDP session and controller
iGdp= CGdpSession::NewL(KGdpLoopbackUid);
iGdp->OpenL(this);
// construct engine
iGameEngine=new(ELeave) CGameEngine;
// construct app view
iAppView=new(ELeave) CGameAppView;
iAppView->ConstructL(iGameEngine, iAppUi->ClientRect());
iAppUi->AddToStackL(iAppView);
}
CGameController::~CGameController()
{
iAppUi->RemoveFromStack(iAppView);
delete iAppView;
delete iGameEngine;
delete iGdp;
}
// MGdpPacketHandler stuff
void CGameController::GdpHandleL(const TDesC8& /* aFromAddress */, const TDesC8& aData)
{
HBufC* buffer = HBufC::NewLC(aData.Length());
TPtr buffer_ptr(buffer->Des());
buffer_ptr.Copy(aData);
iGameEngine->SetLastReceivedL(buffer_ptr); // not type safe!
iAppView->iLastReceivedLabel->SetTextL(buffer_ptr);
iAppView->DrawNow();
CleanupStack::PopAndDestroy();
}
void CGameController::SendComplete(TInt /* aErr */)
{
// do nothing for loopback testing
}
// app UI commands
// substitute a proper phone number in iGdp->SendL below
void CGameController::CmdSendMessageL(const TDesC& aString)
{
iGameEngine->SetLastSentL(aString);
iAppView->iLastSentLabel->SetTextL(aString);
iAppView->DrawNow();
HBufC8* buffer = HBufC8::NewLC(aString.Length());
TPtr8 buffer_ptr(buffer->Des());
buffer_ptr.Copy(aString);
iGdp->SendL(_L8("+447747447747"), buffer_ptr);
CleanupStack::PopAndDestroy();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -