Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 07:07, 25 September 2007.

Display wait note between HTTP response delay

From Forum Nokia Wiki


This example will allow you to display a wait note till you get a http response.


In the MMP file

LIBRARY       avkon.lib
LIBRARY       eikcdlg.lib
LIBRARY       eikctl.lib


In the RSS file

//----------------------------------------------------
//   
//    r_wait_note_http_request
//    Display wait note
//
//----------------------------------------------------
//
RESOURCE DIALOG r_wait_note_http_request
	{
	flags=EAknWaitNoteFlags;
	items =
		{
		DLG_LINE
			{
			type = EAknCtNote;
			id = EWaitNoteId;
			control = AVKON_NOTE
				{
				layout = EWaitLayout;
				singular_label = "Please wait..."
				imagefile = "z:\\system\data\avkon.mbm";
				imageid = EMbmAvkonQgn_note_progress;
				imagemask = EMbmAvkonQgn_note_progress_mask;
				animation = R_QGN_GRAF_WAIT_BAR_ANIM;
				};
			}
		};
	}

In the HEADER File


#ifndef __TestClass_H__
#define __TestClass_H__
 
#include "HTTPClientEngine.h"
#include <AknWaitNoteWrapper.h>
 
 
class TestClass: public MHTTPObserver,public MAknBackgroundProcess
{
public:
 
	static TestClass* NewLC();
 
	static TestClass* NewL();
 
	void ConstructL();
 
	TestClass();
 
	virtual ~TestClass();
 
 
        void IssueHTTPRequest(); 
 
	/*
	* HTTP Callback Methods
	*
	*/
 
 
	virtual	void ClientEvent(const TDesC& aEventDescription);
 
	virtual	void ClientBodyReceived(const TDesC8& aBodyData);
 
	
       /*
	*	From MAKnBackgroundObserver
	*
	*/
 
	TBuf<32> Status;
 
 
	RTimer iTimeWaster;
 
   private:
 
	TBool iDialogDismissed;
 
	void DialogDismissedL(TInt aButtonId);
 
	TBool IsProcessDone() const;
 
	void ProcessFinished();
 
	void StepL();
 
 
	
private:
 
	HBufC8*				iHTTPResponse;
 
	CHTTPClientEngine*	        iHTTPClient;
 
	CAknWaitNoteWrapper*		waitNoteWrapper;
 
	};
 
#endif __TestClass_H__

In the CPP File

// TestClass.cpp: implementation of the CTestClassclass.
//
//////////////////////////////////////////////////////////////////////
 
#include "TestClass.h" 
#include <e32std.h>
#include <eikmenup.h>
#include <e32base.h>
#include <aknnotewrappers.h>
#include <StringLoader.h> 
/*
============================================================================
Name        : CTestClass from TestClass.h
Author      : shivam
Version     : 
 
============================================================================
*/
 
 
 
CTestClass ::CTestClass()
{
 
}
 
 
 
CTestClass::~CTestClass()
{
 
	if(iHTTPClient)
	{
		delete iHTTPClient;
		iHTTPClient=NULL;
	}
 
	if(iHTTPResponse)
	{
		delete iHTTPResponse;
		iHTTPResponse=NULL;
	}
 
	iTimeWaster.Close();
 
	delete this->waitNoteWrapper;
	this->waitNoteWrapper=NULL;
 
}
 
void CTestClass::CTestClass()
{
	iHTTPClient=CHTTPClientEngine::NewL(*this);
 
	iHTTPResponse=NULL;
 
	waitNoteWrapper = CAknWaitNoteWrapper::NewL();
	iTimeWaster.CreateLocal();
 
 
}
 
CTestClass* CTestClass::NewL()
{
	CTestClass* self = CTestClass::NewLC();
	CleanupStack::Pop(self);
	return self;
 
}
 
CTestClass* CTestClass::NewLC()
{
	CTestClass* self = new (ELeave) CTestClass();
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
 
}
 
 
//=========================================================================
//ClientBodyReceived() -- HTTP Callback Function.This will get the response 
// body data.
//returns -- None
//
//==========================================================================
 
void CTestClass::ClientBodyReceived(const TDesC8& aBodyData)
{
	if(!iHTTPResponse)
		{
			iHTTPResponse = HBufC8::NewL(aBodyData.Length());
		}
		else
		{
iHTTPResponse = 
     iHTTPResponse->ReAllocL(iHTTPResponse->Length()+aBodyData.Length());		
		}
 
		TPtr8 ptr_bufNoteData8=iHTTPResponse->Des();
		ptr_bufNoteData8.Append(aBodyData);
	
}
 
 
//=========================================================================
//ClientEvent() -- HTTP Callback function
//aEventDescription -- The transaction events
//returns -- None
//
//==========================================================================
 
void CTestClass::ClientEvent(const TDesC& aEventDescription)
{
	this->Status.Copy(aEventDescription);
 
	_LIT(KTransactionSuccessful, "Transaction Successful");
	if(aEventDescription==KTransactionSuccessful)
	{
		//Handle HTTP Response
	}
 
}
 
//=========================================================================
//
//IssueHTTPRequest()  -- Issue HTTP request
//
//
//==========================================================================
 
void CConnector::IssueHTTPRequest()
{
 
	 iRSSFeed = aCurrentFeed;
	
	 Status.Copy(_L("Init"));
	
	 TBuf8<256> uri8;
	 uri8.Append(_L("http://www.forum.nokia.com"));
 
 
	// Start transaction
	iHTTPClient->IssueHTTPGetL(uri8);
 
if (!waitNoteWrapper->ExecuteL(R_WAIT_NOTE_HTTP_REQUEST, *this,ETrue)) 
{
		iHTTPClient->CancelTransaction();
}
 
}
//=========================================================================
//StepL() -- Used by the Wait bar to increment the timer
//Inherited from MAknBackgroundObserver
//
//==========================================================================
 
void CTestClass::StepL()
{
	TRequestStatus status;
	TInt delay = 100000; // 1 second
	iTimeWaster.After(status, delay);
	User::WaitForRequest(status); 
 
}
 
 
//=========================================================================
//ProcessFinished() -- Diminishes the wait bar when the http process is finished
//
//Inherited from MAknBackgroundObserver
//==========================================================================
 
void CTestClass::ProcessFinished()
{
	iTimeWaster.Cancel();
	this->Status.Delete(0,this->Status.Length());
}
 
 
//=========================================================================
//IsProcessDone() -- Checks whethet the HTTP request is complete or not
//returns : True/False
//Inherited from MAknBackgroundObserver
//==========================================================================
 
TBool CTestClass::IsProcessDone() const
{
	_LIT(KTransactionSuccessful, "Transaction Successful");
	TPtrC istatus(this->Status);
	return(istatus==KTransactionSuccessful);
 
}
 
//=========================================================================
//DialogDismissedL() -- Called if the wait bar is stopeed in between
//Inherited from MAknBackgroundObserver
//
//==========================================================================
 
void CTestClass::DialogDismissedL(TInt /*aButtonId*/)
{
	
}
Related Discussions
Thread Thread Starter Forum Replies Last Post
change language of note dialog cds.ds General Symbian C++ 0 2008-02-15 09:53
read the conent of file and display using information note sangeethavijaysekar General Symbian C++ 3 2007-04-09 11:25
Delay in Sound wilnal General Symbian C++ 1 2003-02-07 15:58
CAknGlobalNote(permanent note) sapramit General Symbian C++ 1 2005-05-30 09:03
Response complete -- HTTP connection mobileworm Symbian Networking & Messaging 0 2005-11-04 00:19
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX