📄 orcloginview.cpp
字号:
/* Copyright (c) 2007, Nokia. All rights reserved */
#include <eikbtgpc.h>//repair cba
#include <akntitle.h>
#include <aknnotewrappers.h>
#include "orcerAppUi.h"
#include "ORCLoginView.h"
#include "ORCLoginContainer.h"
#include "orcer.hrh"
#include "orcer.rsg"
#include "ORCOperBook.h"
CORCLoginView* CORCLoginView::NewL()
{
CORCLoginView* self = NewLC();
CleanupStack::Pop(self);
return self;
}
CORCLoginView* CORCLoginView::NewLC()
{
CORCLoginView* self = new (ELeave) CORCLoginView();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
void CORCLoginView::ConstructL()
{
BaseConstructL(R_ENTER_VIEW);
}
CORCLoginView::CORCLoginView()
{
iState = 0;
m_pAppContainer = NULL;
}
CORCLoginView::~CORCLoginView()
{
}
TUid CORCLoginView::Id() const
{
return TUid::Uid(EORCLoginViewID);
}
void CORCLoginView::HandleCommandL(TInt aCommand)
{
switch(aCommand) {
case EORCERCommandFun: //登录
JudgeregiMessage();
break;
case EORCERCommandLogin: //注册
m_pAppContainer->SetVisible();
m_pAppContainer->SetState(1);
iState = 1;
SetLoginCBA();
m_pAppContainer->DrawNow();
//AppUi()->ActivateLocalViewL(TUid::Uid(EORCLoginViewID));
break;
case EORCERCommandHelp: //帮助
AppUi()->ActivateLocalViewL(TUid::Uid(EORCHelpViewID));
break;
case EORCERLogin:
JudgeLonginMessage();
iState = 0;
break;
case EORCERLoginReturn:
m_pAppContainer->SetUnVisible();
m_pAppContainer->SetState(0);
iState = 0;
SetLoginCBA();
m_pAppContainer->DrawNow();
break;
default:
AppUi()->HandleCommandL(aCommand);
break;
}
}
void CORCLoginView::HandleClientRectChange()
{
}
void CORCLoginView::DoActivateL(const TVwsViewId&, TUid, const TDesC8&)
{
m_pAppContainer = new( ELeave ) CORCLoginContainer();
m_pAppContainer->SetMopParent(this);
m_pAppContainer->ConstructL( ClientRect());
AppUi()->AddToStackL( *this, m_pAppContainer );
// set titil
TBuf<32> buf;
CEikonEnv::Static()->ReadResource(buf, R_RECORD_LOGIN);
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
tp->SetTextL(buf);
// set
// m_pAppContainer->ConstructL( ClientRect() );
// AppUi()->AddToStackL( *this, m_pAppContainer );
}
void CORCLoginView::DoDeactivate()
{
if(m_pAppContainer)
{
AppUi()->RemoveFromStack( m_pAppContainer );
delete m_pAppContainer;
m_pAppContainer = NULL;
}
}
void CORCLoginView::SetLoginCBA()
{
if(iState == 0)
{
this->Cba()->MakeVisible(EFalse);
this->Cba()->SetCommandSetL(R_PLAN_ENTER_VIEW_CBA);
this->Cba()->MakeVisible(ETrue);
this->Cba()->DrawNow();
}
else
{
this->Cba()->MakeVisible(EFalse);
this->Cba()->SetCommandSetL(R_PLAN_LOGIN_VIEW_CBA);
this->Cba()->MakeVisible(ETrue);
this->Cba()->DrawNow();
}
}
void CORCLoginView::JudgeLonginMessage()
{
_LIT(KEnterType,"register");
TBuf<20> userPsw;
TBuf<20> affirmPsw;
TBuf<30> showPhonMes;
TBuf<30> showPswMes;
TBuf<10> EnterType(KEnterType);
m_pAppContainer->GetUserPhon(userPhon);
m_pAppContainer->GetUserPsw(userPsw);
m_pAppContainer->GetAfirmPws(affirmPsw);
m_pOperBook->SetPoneNum(userPhon);
if (userPhon.Length() == 0 || userPsw.Length() == 0)
{
CEikonEnv::Static()->ReadResource(showPhonMes,R_RECORD_SHOWMESSAGE);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(showPhonMes);
}
else if (userPsw.Compare(affirmPsw))
{
CEikonEnv::Static()->ReadResource(showPswMes,R_RECORD_SHOWCOMPARE);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(showPswMes);
}
else if (userPsw.Length() < 6 || userPhon.Length() < 11 )
{
CEikonEnv::Static()->ReadResource(showPhonMes,R_RECORD_SHOWMESSAGE);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(showPhonMes);
}
else
m_pHttp->SendUrl(EnterType, userPhon, userPsw); //cancer
// AppUi()->ActivateLocalViewL(TUid::Uid(EORCFunViewID));
}
void CORCLoginView::JudgeregiMessage()//登录
{
_LIT(KLoginType,"login");
TBuf<20> userPsw;
TBuf<30> showPhonMes;
TBuf<30> showPswMes;
TBuf<10> loginType(KLoginType);
m_pAppContainer->GetUserPhon(userPhon1);
m_pAppContainer->GetUserPsw(userPsw);
m_pOperBook->SetPoneNum(userPhon1);
if (userPhon1.Length() == 0 || userPsw.Length() == 0)
{
CEikonEnv::Static()->ReadResource(showPhonMes,R_RECORD_SHOWMESSAGE);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(showPhonMes);
}
else if (userPsw.Length() < 6 || userPhon1.Length() < 11 )
{
CEikonEnv::Static()->ReadResource(showPhonMes,R_RECORD_SHOWMESSAGE);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(showPhonMes);
}
else
m_pHttp->SendUrl(loginType, userPhon1, userPsw);
// AppUi()->ActivateLocalViewL(TUid::Uid(EORCFunViewID));
}
void CORCLoginView::SetResponseType(const TDesC& aType,const TDesC& aResult)
{
TBuf<10> sType(aType);
TBuf<10> sResult(aResult);
TBuf<20> sShowMessage;
AppUi()->ActivateLocalViewL(TUid::Uid(EORCFunViewID));
if (sType.Compare(_L("regi")) == 0)
{
AppUi()->ActivateLocalViewL(TUid::Uid(EORCFunViewID));
if (sResult.Compare(_L("0")) == 0)
{
AppUi()->ActivateLocalViewL(TUid::Uid(EORCFunViewID));
}
else
{
CEikonEnv::Static()->ReadResource(sShowMessage,R_ORCER_LOGIN_FAIL);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sShowMessage);
}
}
if (sType.Compare(_L("login")) == 0)
{
AppUi()->ActivateLocalViewL(TUid::Uid(EORCFunViewID));
if (sResult.Compare(_L("0")) == 0)
{
AppUi()->ActivateLocalViewL(TUid::Uid(EORCFunViewID));
}
if (sResult.Compare(_L("1")) == 0)
{
CEikonEnv::Static()->ReadResource(sShowMessage,R_ORCER_ENTER_FAIL);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sShowMessage);
}
if (sResult.Compare(_L("2")) == 0)
{
CEikonEnv::Static()->ReadResource(sShowMessage,R_ORCER_ENTER_FAIL);
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sShowMessage);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -