📄 chttpappui.cpp
字号:
/**
* CHttpAppUi implementation
*
* This file is part of HttpServer.
*
* HttpServer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* HttpServer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HttpServer; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "HttpServer.h"
CHttpAppUi *CHttpAppUi::NewL()
{
CHttpAppUi *self = new (ELeave) CHttpAppUi();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop();
return self;
}
CHttpAppUi::CHttpAppUi()
{
// Nothing here, all work done in ConstructL().
view = NULL;
socketengine = NULL;
periodic = NULL;
}
void CHttpAppUi::ConstructL()
{
CHttpView *nview;
CHttpSocketEngine *nsocketengine;
// Must call BaseConstructL() to complete the UI framework's
// construction of the App UI.
BaseConstructL();
// Create the view.
nview = new (ELeave) CHttpView();
CleanupStack::PushL(nview);
nview->ConstructL();
view = nview;
CleanupStack::Pop();
AddViewL(view);
ActivateLocalViewL(view->Id());
// Create the socket engine
nsocketengine = new (ELeave) CHttpSocketEngine(CActive::EPriorityStandard);
CleanupStack::PushL(nsocketengine);
nsocketengine->ConstructL(this);
socketengine = nsocketengine;
CleanupStack::Pop(nsocketengine);
// Set up an initialization timer
periodic = CPeriodic::NewL(0);
periodic->Start(250000, 10000000, TCallBack(StaticDelayedInitialize, this));
}
CHttpAppUi::~CHttpAppUi()
{
delete socketengine;
// delete view;
delete periodic;
}
/**
* This static function is called by the CPeriodic timer.
*/
TInt CHttpAppUi::StaticDelayedInitialize(TAny *ptr)
{
TInt err;
TRAP(err, ((CHttpAppUi *) ptr)->DelayedInitializeL());
return 0;
}
/**
* Do the delayed initialization of CHttpAppUi.
* We only want one initialization, so we'll disable the Periodic timer
* in the first call.
*/
void CHttpAppUi::DelayedInitializeL()
{
_LIT(KInitText, "Initializing...");
view->PrintL(KInitText);
socketengine->StartListeningL();
delete periodic;
periodic = NULL;
}
/**
* This function is called by the UI framework whenever
* a command has been issued. The ID's are defined in the
* resource header (.hrh) file and associated to resources
* in the resource file (.rss).
*/
void CHttpAppUi::HandleCommandL(TInt cmd)
{
switch (cmd)
{
case EHttpMenuStartStop:
socketengine->ToggleListeningL();
break;
case EHttpMenuExit:
socketengine->StopListeningL();
Exit();
break;
case EEikCmdExit: // defined in eikon.hrh
socketengine->StopListeningL();
Exit();
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -