📄 newapp11view2.cpp
字号:
/*
============================================================================
Name : CNewApp11View2 from NewApp11View2.h
Author :
Version :
Copyright : Your copyright notice
Description : CNewApp11View2 implementation
============================================================================
*/
// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <NewApp11.rsg>
#include "NewApp11View2.h"
#include "NewApp11Container2.h"
#include "ToUnicode.h"
#include <aknquerydialog.h>
#include "Sockets.hrh"
#include "SocketsEngine.h"
#include "CAppSvrPacket.h"
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CNewApp11View2::ConstructL(const TRect& aRect)
// EPOC two-phased constructor
// ---------------------------------------------------------
//
void CNewApp11View2::ConstructL()
{
BaseConstructL( R_NEWAPP11_VIEW2 );
iSocketsEngine = NULL;
}
// ---------------------------------------------------------
// CNewApp11View2::~CNewApp11View2()
// destructor
// ---------------------------------------------------------
//
CNewApp11View2::~CNewApp11View2()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
}
// ---------------------------------------------------------
// TUid CNewApp11View2::Id()
//
// ---------------------------------------------------------
//
TUid CNewApp11View2::Id() const
{
return KView2Id;
}
// ---------------------------------------------------------
// CNewApp11View2::HandleCommandL(TInt aCommand)
// takes care of view command handling
// ---------------------------------------------------------
//
void CNewApp11View2::HandleCommandL(TInt aCommand)
{
switch ( aCommand )
{
case EAknSoftkeyOk:
{
iEikonEnv->InfoMsg( _L("view2 ok") );
break;
}
case EAknSoftkeyBack:
{
AppUi()->HandleCommandL(EEikCmdExit);
break;
}
default:
{
AppUi()->HandleCommandL( aCommand );
break;
}
}
}
// ---------------------------------------------------------
// CNewApp11View2::HandleClientRectChange()
// ---------------------------------------------------------
//
void CNewApp11View2::HandleClientRectChange()
{
if ( iContainer )
{
iContainer->SetRect( ClientRect() );
}
}
// ---------------------------------------------------------
// CNewApp11View2::DoActivateL(...)
//
// ---------------------------------------------------------
//
void CNewApp11View2::DoActivateL(
const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
if (!iContainer)
{
iContainer = new (ELeave) CNewApp11Container2;
iContainer->SetMopParent(this);
iContainer->ConstructL( ClientRect() );
AppUi()->AddToStackL( *this, iContainer );
}
}
// ---------------------------------------------------------
// CNewApp11View2::DoDeactivate()
//
// ---------------------------------------------------------
//
void CNewApp11View2::DoDeactivate()
{
if ( iContainer )
{
AppUi()->RemoveFromViewStack( *this, iContainer );
}
delete iContainer;
iContainer = NULL;
}
void CNewApp11View2::ConnectServ()
{
if(iSocketsEngine == NULL)
{
iSocketsEngine = CSocketsEngine::NewL( *iContainer );
}
if (iSocketsEngine )
{
TBuf<KMaxServerNameLength> serverName(
iSocketsEngine->ServerName() );
TInt port( iSocketsEngine->Port() );
CAknMultiLineDataQueryDialog* dialog =
CAknMultiLineDataQueryDialog::NewL( serverName, port );
// Display and execute dialog, and act according to return value
if ( dialog->ExecuteLD( R_SOCKETS_DIALOG_CONNECT ) )
{
iSocketsEngine->SetServerName( serverName );
iSocketsEngine->SetPort( port );
iSocketsEngine->ConnectL(); // Initiate connection
}
}
}
void CNewApp11View2::SendToServer()
{
if(iSocketsEngine == NULL)
{
return;
}
/*
TBuf<40> aBuf;
TBuf8<120> aBuf8;
iContainer->iEdwin->GetText(aBuf);
ToUnicode unicode;
TText *iText =(TText *) aBuf.Ptr();
iText[aBuf.Length()] = '\0';
TBufC<40> aBufC(iText);
unicode.ConvUni2Gbk(aBufC, aBuf8);
*/
TText8 *pr = (TText8 *)"<message><user><serialid>410</serialid><mobilecode>13858012984</mobilecode><type>ucsp</type><command>QhqlMTIVRAddMemberReq</command><role>0</role><isresult>0</isresult><time>2006-12-21 16:04:50</time><level>0</level><version>1.0.0</version><param1></param1><param2>136</param2><business>qhql</business></user><body><phone>13735810001,</phone><serialNo>0</serialNo><meetingserial></meetingserial></body></message>";
TBuf8<800> iBuf(pr);
CAppSvrPacket::GetPacket(iBuf);
iSocketsEngine->WriteL(iBuf);
// iContainer->iEdwin->ClearSelectionL(iBuf);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -