⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginview.cpp

📁 symbian手机加密记事本
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CLoginView from CAknView
*  Part of  : Login
*  Copyright (c) 2003 Nokia. All rights reserved.
* ============================================================================
*/

// INCLUDE FILES
#include <aknviewappui.h>
#include <avkon.hrh>
#include <Memento.rsg>
#include <eikmenub.h>
#include <aknnotewrappers.h> 
#include "Memento.hrh"
#include "LoginView.h"
#include "LoginContainer.h" 
#include "MementoAppUi.h"
#include "DirView.h"
#include "DataManage.h"

// ================= MEMBER FUNCTIONS =======================

// C++ default constructor can NOT contain any code, that
// might leave.
//
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;
}

CLoginView::CLoginView()
    {
    }

// EPOC default constructor can leave.
void CLoginView::ConstructL()
    {
    //BaseConstructL(R_Login_VIEW);
	BaseConstructL(R_LONGIN_VIEW);
    }

// Destructor
CLoginView::~CLoginView()
    {

    }

// ---------------------------------------------------------
// TUid CLoginView::Id()
// Returns Id of the view.
// ---------------------------------------------------------
TUid CLoginView::Id() const
    {
    return KViewId1;
    }

// ---------------------------------------------------------
// CLoginView::HandleCommandL(TInt aCommand)
// Handles commands
// ---------------------------------------------------------
void CLoginView::HandleCommandL(TInt aCommand)
    {   
		TBuf<32>   sUser,sPw1,sPw2,Errorinf;//Errorinf接收中文
		iContainer->GetUserInfo(sUser,sPw1,sPw2);
		switch(aCommand)
		{
// 		case EMyLoginCmdLogon:
// 			{
// 			//	AppUi()->ActivateLocalViewL(KViewId2);
// 				break;
// 			}

		case ELogMenuLogin:
			{
			TBuf<32>   sUser,Pw,Pw1;
			iContainer->GetUserInfo(sUser,Pw,Pw1);

			if(sUser.Length()>0)
			{
				if(Pw.Length()==6)
				{
					CMementoAppUi* pUI = (CMementoAppUi*)CEikonEnv::Static()->AppUi();
					CDataManage* pDataMangae = pUI->GetDataManage();
					if(pDataMangae->LoadUser(sUser,Pw))
					{
						AppUi()->ActivateLocalViewL(KViewId3);
					}
					else
					{													
						CEikonEnv::Static()->ReadResource(Errorinf, R_QTN_MH_LONGIN_ERROR6);
// 						_LIT(Error6,"Error 6");
						CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
						informationNote->ExecuteLD(Errorinf);
					}
				}
				else if(Pw.Length()==0)
				{
					CEikonEnv::Static()->ReadResource(Errorinf, R_QTN_MH_LONGIN_ERROR4);
//					_LIT(Error1,"Error 4");
					CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
					informationNote->ExecuteLD(Errorinf);
					
				}
				else
				{
					CEikonEnv::Static()->ReadResource(Errorinf, R_QTN_MH_LONGIN_ERROR1);
//					_LIT(Error1,"Error 1");
					CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
					informationNote->ExecuteLD(Errorinf);

				}
			}
			else 
			{
				CEikonEnv::Static()->ReadResource(Errorinf, R_QTN_MH_LONGIN_ERROR3);
//				_LIT(Error3,"Error 3");
				CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
				informationNote->ExecuteLD(Errorinf);
				
			}	
			break;
			}

		case ELogMenuHelp:
			{
//				AppUi()->ActivateLocalViewL(KViewId2);
			_LIT(message,"Command 1");
            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
            informationNote->ExecuteLD(message);
			break;
			}

		case ELogMenuRegister:
			{
			if(sUser.Length()>0)
			{
				if((sPw2.Compare(sPw1)==0)&&(sPw1.Length()==6))
				{
					CMementoAppUi* pUI = (CMementoAppUi*)CEikonEnv::Static()->AppUi();
					CDataManage* pDataMangae = pUI->GetDataManage();
					if(pDataMangae->CreateUserL(sUser,sPw1))
					{
						AppUi()->ActivateLocalViewL(KViewId3);
					}
					else
					{
						_LIT(Error4,"Error 5:  can't save information");
						CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
						informationNote->ExecuteLD(Error4);
					
					}
				}
				else
				{
					if((sPw1.Length()==0)&&(sPw2.Length()==0))
					{
						CEikonEnv::Static()->ReadResource(Errorinf, R_QTN_MH_LONGIN_ERROR4);
						//						_LIT(Error4,"Error 4");
						CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
						informationNote->ExecuteLD(Errorinf);
						
					}
					else if(sPw2.Compare(sPw1)!=0)
					{
						CEikonEnv::Static()->ReadResource(Errorinf, R_QTN_MH_LONGIN_ERROR2);
						//						_LIT(Error2,"Error 2");
						CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
						informationNote->ExecuteLD(Errorinf);
					}
					else
					{
						CEikonEnv::Static()->ReadResource(Errorinf, R_QTN_MH_LONGIN_ERROR1);
//						_LIT(Error1,"Error 1");
						CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
						informationNote->ExecuteLD(Errorinf);
					}
					
				}
			//		AppUi()->ActivateLocalViewL(TUid::Uid(EXWNoteEdit))
			}			
			else 
			{
				CEikonEnv::Static()->ReadResource(Errorinf, R_QTN_MH_LONGIN_ERROR3);
//				_LIT(Error3,"Error 3");
				CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
				informationNote->ExecuteLD(Errorinf);
			}
			break;

			}

		default:
			{
				AppUi()->HandleCommandL(aCommand);
				break;
			}
		}
	}
// ---------------------------------------------------------
// CLoginView::HandleClientRectChange()
// Handles client rect change.
// ---------------------------------------------------------
void CLoginView::HandleClientRectChange()
    {
    if (iContainer)
        {
        iContainer->SetRect(ClientRect());
        }
    }

// ---------------------------------------------------------
// CLoginView::DoActivateL(...)
// Creates the Container class object.
// ---------------------------------------------------------
void CLoginView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
                                    TUid /*aCustomMessageId*/,
                                    const TDesC8& /*aCustomMessage*/)
    {
    iContainer = new (ELeave) CLoginContainer;
    iContainer->SetMopParent(this);

	CDataManage* pDataMangae = ((CMementoAppUi*)CEikonEnv::Static()->AppUi())->GetDataManage();
	TBool flag = pDataMangae->IsEmpty();
	if (flag)
	{
		iContainer->setState(ERegister);
//		MenuBar()->SetMenuTitleResourceId(R_REGISTER_MENUBAR);
		Cba()->SetCommandSetL(R_CBA_REGISTER);
		Cba()->DrawNow();
	}
	else
	{
		iContainer->setState(ELogin);
//		MenuBar()->SetMenuTitleResourceId(R_LOG_MENUBAR);
		Cba()->SetCommandSetL(R_CBA_LOGIN);
		Cba()->DrawNow();
	}

	TRect rc;
	rc.SetRect(ClientRect().iTl, TSize(176, 144));
    iContainer->ConstructL(rc);
    AppUi()->AddToStackL(*this, iContainer);
    }

// ---------------------------------------------------------
// CLoginView::DoDeactivate()
// Deletes the Container class object.
// ---------------------------------------------------------
void CLoginView::DoDeactivate()
    {
    if (iContainer)
        {
        AppUi()->RemoveFromStack(iContainer);
    
		delete iContainer;
		iContainer = NULL;
		}
    }

// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -