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

📄 progressnotetasao.cpp

📁 symbian和旗下的HTTPENGINE的相关代码
💻 CPP
字号:
/**
*
* @brief Definition of CProgressNoteTASAO
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/

// System includes
#include <aknnotewrappers.h> //CAknInformationNote
#include <eikprogi.h> // CEikProgressInfo
#include <ASSISTANT.rsg>
#include <eikenv.h>

//	Class include
#include "ProgressNoteTASAO.h"

// CONSTANTS
const TInt KNumberOfStepsToSaveGame(20);
const TInt KFinalValue(100);
const TInt KTimerInterval(250000);
const TInt KIncrement(5);

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

/**
* Destructor.
* Cancels the active object and closes the timer.
*/
CProgressNoteTASAO::~CProgressNoteTASAO()
{
	Cancel();
	iTimeWaster.Close();
	delete iProgressDialog;
}

/**
* Symbian OS 2nd phase constructor.  Creates a timer and adds the active object to the scheduler.
*/
void CProgressNoteTASAO::ConstructL()
{
	iTimeWaster.CreateLocal();
	CActiveScheduler::Add(this);
}

/**
* Symbian OS 2 phase constructor.
* Constructs the CProgressNoteTASAO using the constructor and ConstructL
* method, leaving the constructed object on the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CProgressNoteTASAO
*/
CProgressNoteTASAO* CProgressNoteTASAO::NewLC()
{
	CProgressNoteTASAO* self = new (ELeave) CProgressNoteTASAO();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}

/**
* Symbian OS 2 phase constructor.
* Constructs the CProgressNoteTASAO using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CProgressNoteTASAO
*/

CProgressNoteTASAO* CProgressNoteTASAO::NewL()
{
	CProgressNoteTASAO* self = CProgressNoteTASAO::NewLC();
	CleanupStack::Pop(self);
	return self;
}

/**
* Called whenever the active object is cancelled. Cancels the timer.
*/

void CProgressNoteTASAO::DoCancel()
{
	iTimeWaster.Cancel();
}

/**
* Saves a game, by starting the active object and executing a progress dialog
*/
void CProgressNoteTASAO::SaveGameL()
{
	iProgressDialog = new (ELeave) CAknProgressDialog (reinterpret_cast<CEikDialog**>(&iProgressDialog));
	iProgressDialog->PrepareLC(R_PROGRESSNOTE_UPDATING_NOTE);	//UPDATING
	iProgressDialog->SetCallback (this);						// calls DialogDismissL on completion
	CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL();	// not taking ownership
	progressBar->SetFinalValue(KFinalValue);					// Set final value of progress bar设置进度条表示的单元数
	iProgressDialog->RunLD();					// this doesn't actually delete the dialog despite the 'D' suffix
	SaveGamePartToFile();						// make a synchronous request
	progressBar->IncrementAndDraw(KIncrement);	// increment the progress bar
	SetActive();								// set the active object to be active
}

void CProgressNoteTASAO::DownLoadL()
{
	iProgressDialog = new (ELeave) CAknProgressDialog (reinterpret_cast<CEikDialog**>(&iProgressDialog));
	iProgressDialog->PrepareLC(R_PROGRESSNOTE_LOADING_NOTE);	//downloading 
	iProgressDialog->SetCallback (this);						// calls DialogDismissL on completion
	CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL();	// not taking ownership
	progressBar->SetFinalValue(KFinalValue);					// Set final value of progress bar设置进度条表示的单元数
	iProgressDialog->RunLD();					// this doesn't actually delete the dialog despite the 'D' suffix
	SaveGamePartToFile();						// make a synchronous request
	progressBar->IncrementAndDraw(KIncrement);	// increment the progress bar
	SetActive();								// set the active object to be active

}

/**
* Performs the work of the active object.
* If there is still processing to complete, saves one part of the game to file and makes the object active again.
*/
void CProgressNoteTASAO::RunL()
{
	if (!IsProcessDone())
	{
		SaveGamePartToFile();
		iProgressDialog->GetProgressInfoL()->IncrementAndDraw(KIncrement);	//工作未完成的时候继续画出来
		SetActive();
	}
	else
	{
		iProgressDialog->ProcessFinishedL();	//It stops the timer and deletes the dialog
	}
}

/**
* Called by the progress note when it is dismissed.
* This is as a result of either the user cancelling the note,
* or the process finishing.
*	进度对话框关闭时调用,用于执行所有的清除工作
*/
void CProgressNoteTASAO::DialogDismissedL(TInt /*aButtonId*/)
{
	if (!IsProcessDone())
	{
		CancelGameSave();	//未完成时手动关闭对话框
	}
	else
	{
		CompleteGameSave();	//完成时关闭对话框
	}
	iStepsCompleted = 0;
}

/**
* Called by RunL to check whether to continue processing.
* @return ETrue if processing is complete, EFalse otherwise
*/
TBool CProgressNoteTASAO::IsProcessDone() const
{
	return (iStepsCompleted == KNumberOfStepsToSaveGame);	//true /false
}

/**
* Dummy method which could be used to cancel a partially saved game, e.g.
* by resetting values and deleting the partially created file.
* In this example it stops the timer used to simulate a game save and cancels any outstanding requests
* for this active object
*/
void CProgressNoteTASAO::CancelGameSave()
{
	Cancel();
}

/**
* Dummy method which could be used to save part of a game to a file
* In this example, it runs a timer for an arbitrary period of time
* to simulate saving part of the game.
* This is an asynchronous method
*/
void CProgressNoteTASAO::SaveGamePartToFile ()
{
	// Use an arbitrary delay to simulate saving part of the game
	TInt delay = KTimerInterval;
	iTimeWaster.After(iStatus, delay);
	// Note that we have completed a step
	iStepsCompleted++;
}

/**
* Dummy method which could be used to complete the game saving process, e.g. by closing
* the saved game file.
* In this example it stops the timer used to simulate a game save and cancels any outstanding requests
* for this active object
*/
void CProgressNoteTASAO::CompleteGameSave()
{
	Cancel();
}

⌨️ 快捷键说明

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