📄 loginview.cpp
字号:
/* Copyright (c) 2007, Nokia. All rights reserved */
#include <akntitle.h>
#include <eikspace.h>
#include <eikbtgpc.h> //CEikButtonGroupContainer
#include <aknnotewrappers.h> //CAknInformationNote
#include "ASSISTANTAppUi.h"
#include "LoginView.h"
#include "LoginContainer.h"
#include "ASSISTANT.hrh"
#include "ASSISTANT.rsg"
CLoginView* CLoginView::NewL()
{
CLoginView* self = NewLC();
CleanupStack::Pop(self);
return self;
}
CLoginView* CLoginView::NewLC()
{
CLoginView* self = new (ELeave) CLoginView();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
void CLoginView::ConstructL()
{
BaseConstructL(R_PLAN_LOGIN_VIEW);
}
CLoginView::CLoginView()
{
m_pAppContainer = NULL;
m_pServerManager = NULL;
m_nflag = 0;
m_nStatus = -1;
}
CLoginView::~CLoginView()
{
}
TUid CLoginView::Id() const
{
return TUid::Uid(ELoginViewID);
}
void CLoginView::HandleCommandL(TInt aCommand)
{
switch(aCommand)
{
case EPLANCmdAppHelp_OK: //登录
{
m_nflag = 0;
AppUi()->ActivateLocalViewL(TUid::Uid(EMainViewID));
// LoginJudgeInfo();
}
break;
case EPLANCmdAppHelp_Register:
{
m_nflag = 1;
m_pAppContainer->SetPreVisible();
SetLoginCBA();
SetLoginTitle();
m_pAppContainer->DrawNow();
}
break;
case EPLANCmdAppRegister_return:
{
m_nflag = 0;
m_pAppContainer->SetPreUnVisible();
SetLoginCBA();
SetLoginTitle();
m_pAppContainer->DrawNow();
}
break;
case EPLANCmdAppRegister_confirm: //注册
{
m_nflag = 0;
RegistJudgeInfo();
}
break;
default:
AppUi()->HandleCommandL(aCommand);
break;
}
}
void CLoginView::HandleClientRectChange()
{
}
void CLoginView::DoActivateL(const TVwsViewId&, TUid, const TDesC8&)
{
m_pAppContainer = new( ELeave ) CLoginContainer();
m_pAppContainer->SetMopParent(this);
m_pAppContainer->ConstructL( TRect(TPoint(0, 44), TSize(176, 144)));
AppUi()->AddToStackL( *this, m_pAppContainer );
//change title
TBuf<32> buf;
CEikonEnv::Static()->ReadResource(buf, R_ASS_TAS_LOGIN);
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
tp->SetTextL(buf);
SetLoginCBA();
}
void CLoginView::DoDeactivate()
{
if(m_pAppContainer)
{
AppUi()->RemoveFromStack( m_pAppContainer );
delete m_pAppContainer;
m_pAppContainer = NULL;
}
}
void CLoginView::SetLoginCBA()
{
if (m_nflag == 1) {
this->Cba()->MakeVisible(EFalse);
this->Cba()->SetCommandSetL(R_LOGIN_VIEW_REGISTER_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 CLoginView::SetLoginTitle()
{
TBuf<32> sbuf;
if(m_nflag==1)
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_REGISTER);//regist
}
else
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_LOGIN);//login
}
CEikStatusPane* sp=iEikonEnv->AppUiFactory()->StatusPane();
CAknTitlePane* tp=(CAknTitlePane*)sp->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
tp->SetTextL(sbuf);
}
void CLoginView::LoginJudgeInfo()
{
TBuf<16> sname;
TBuf<16> spassword;
TBuf<32> sbuf;
m_pAppContainer->GetUserName(sname);
m_pAppContainer->GetPassword(spassword);
// // cancer
// m_pLoginInfoNotify->LoginInfoNotify(sname,spassword,ELogin);
// AppUi()->ActivateLocalViewL(TUid::Uid(EMainViewID));
// return;
// //cancer
// m_pLoginInfoNotify->LoginInfoNotify(sname, spassword, ELogin);
//
// return;
if (sname.Length()==0 || sname.Length()< 11)
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_JUDGE_USERNAME); //手机号只能为11位数字
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sbuf);
}
else if (spassword.Length() == 0 || spassword.Length() < 6 )
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_JUDGE_PASSWORD); // 6位密码
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sbuf);
}
else
{
m_pLoginInfoNotify->LoginInfoNotify(sname,spassword,ELogin); //login = 2
}
}
void CLoginView::RegistJudgeInfo()
{
TBuf<16> sname;
TBuf<16> spassword;
TBuf<16> sprepassword;
TBuf<32> sbuf;
m_pAppContainer->GetUserName(sname);
m_pAppContainer->GetPassword(spassword);
m_pAppContainer->GetPrePassword(sprepassword);
if (sname.Length() == 0 || sname.Length() < 11)
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_JUDGE_USERNAME); //手机号只能为11位数字
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sbuf);
}
else if (spassword.Length() == 0 || spassword.Length() < 6 )
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_JUDGE_PASSWORD); // 6位密码
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sbuf);
}
else if (sprepassword.Compare(spassword) != 0)
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_PREPASSWORD_DIFFER); // 对不起!确认密码不一致!
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sbuf);
}
else
{
m_pLoginInfoNotify->LoginInfoNotify(sname,spassword,ERegister);//regist
}
}
void CLoginView::ServerReNotify(TInt aStatusCode,TInt aModel)
{
TBuf<16> sbuf;
m_nStatus = aStatusCode;
// sBuf.Num(aStatusCode);
// CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
// informationNote->ExecuteLD(sBuf);
// AppUi()->ActivateLocalViewL(TUid::Uid(EMainViewID));
// return;
//___________________________________________________________________________________
//login
if (aModel == ELogin)
{
if (m_nStatus == 0)
{
AppUi()->ActivateLocalViewL(TUid::Uid(EMainViewID));//登录成功
}
else if (m_nStatus == 1)
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_PASSWORD_WRONG); // 对不起!密码不正确!
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sbuf); //cancer
}
else if (m_nStatus == 2)
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_USERNAME_NONE); // 对不起!用户名不存在!
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sbuf);
}
}
else if (aModel == ERegister)
{
if (m_nStatus == 0)
{
// CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
// informationNote->ExecuteLD(_L("regist succeed!!!"));
AppUi()->ActivateLocalViewL(TUid::Uid(EMainViewID)); //注册成功
}
else if (m_nStatus == 1)
{
CEikonEnv::Static()->ReadResource(sbuf, R_ASS_TAS_USERNAME_EXIST); // 对不起!用户名已存在!
CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
informationNote->ExecuteLD(sbuf);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -