S60 5th Edition SDK
Example Applications Guide

CCSAsyncRequestHandler Class Reference

#include <csasyncrequesthandler.h>

Inheritance diagram for CCSAsyncRequestHandler:

List of all members.

Detailed Description

CCSAsyncRequestHandler An instance of the request handler object for the ClientServerAsync example application

Definition at line 33 of file csasyncrequesthandler.h.

Public Member Functions

virtual ~CCSAsyncRequestHandler ()
void RequestTime ()
void CancelRequest ()
TTime Time () const

Static Public Member Functions

static CCSAsyncRequestHandlerNewL (MAsyncTimeObserver &aObserver)
static CCSAsyncRequestHandlerNewLC (MAsyncTimeObserver &aObserver)

Protected Member Functions

void RunL ()
void DoCancel ()

Private Member Functions

 CCSAsyncRequestHandler (MAsyncTimeObserver &aObserver)
void ConstructL ()

Private Attributes

RTimeServerSession iSession
TTime iTime
MAsyncTimeObserveriObserver


Constructor & Destructor Documentation

CCSAsyncRequestHandler::~CCSAsyncRequestHandler  )  [virtual]
 

~CCSAsyncRequestHandler. Destructor. Destroys the object and release all memory objects.

Definition at line 77 of file csasyncrequesthandler.cpp.

References iSession.

00078     {
00079     Cancel(); // Causes call to DoCancel()
00080     iSession.Close();
00081     }

CCSAsyncRequestHandler::CCSAsyncRequestHandler MAsyncTimeObserver aObserver  )  [private]
 

CCSAsyncRequestHandler. Performs the first phase of two phase construction.

Parameters:
aObserver The object to be used to handle updates from the server.

Definition at line 66 of file csasyncrequesthandler.cpp.

Referenced by NewLC().

00067 : CActive( EPriorityStandard ), iObserver( aObserver )
00068     {
00069     CActiveScheduler::Add( this );
00070     }


Member Function Documentation

CCSAsyncRequestHandler * CCSAsyncRequestHandler::NewL MAsyncTimeObserver aObserver  )  [static]
 

NewL. Two-phased constructor. Creates a CCSAsyncRequestHandler object using two phase construction, and return a pointer to the created object.

Parameters:
aObserver The object to be used to handle updates from the server.
Returns:
A pointer to the created instance of CCSAsyncRequestHandler.

Definition at line 30 of file csasyncrequesthandler.cpp.

References NewLC().

Referenced by CCSAsyncDocument::CreateAppUiL().

00032     {
00033     CCSAsyncRequestHandler* self = NewLC( aObserver );
00034     CleanupStack::Pop( self );
00035     return( self ) ;
00036     }

CCSAsyncRequestHandler * CCSAsyncRequestHandler::NewLC MAsyncTimeObserver aObserver  )  [static]
 

NewLC. Two-phased constructor. Creates a CCSAsyncRequestHandler object using two phase construction, and return a pointer to the created object.

Parameters:
aObserver The object to be used to handle updates from the server.
Returns:
A pointer to the created instance of CCSAsyncRequestHandler.

Definition at line 42 of file csasyncrequesthandler.cpp.

References CCSAsyncRequestHandler().

Referenced by NewL().

00044     {
00045     CCSAsyncRequestHandler* self =
00046         new ( ELeave ) CCSAsyncRequestHandler( aObserver );
00047     CleanupStack::PushL( self );
00048     self->ConstructL();
00049     return self;
00050     }

void CCSAsyncRequestHandler::RequestTime  ) 
 

RequestTime. Sends a request to the server for an update to the time.

Definition at line 88 of file csasyncrequesthandler.cpp.

References iSession, iTime, and RTimeServerSession::RequestTime().

Referenced by RunL(), and CCSAsyncDocument::UpdateTime().

00089     {
00090     if ( !IsActive() )
00091         {
00092         iSession.RequestTime( iTime, iStatus );
00093         SetActive();
00094         }
00095     }

void CCSAsyncRequestHandler::CancelRequest  ) 
 

CancelRequest. Cancels an outstanding request.

Definition at line 102 of file csasyncrequesthandler.cpp.

Referenced by CCSAsyncDocument::StopClock().

00103     {
00104     Cancel() ; // Causes call to DoCancel()
00105     }

TTime CCSAsyncRequestHandler::Time  )  const
 

Time. Gets a copy of the last time received from the server.

Returns:
The time.

Definition at line 151 of file csasyncrequesthandler.cpp.

References iTime.

Referenced by CCSAsyncDocument::Time().

00152     {
00153     return iTime;
00154     }

void CCSAsyncRequestHandler::RunL  )  [protected]
 

From CActive, RunL. Callback function. Invoked to handle responses from the server.

Definition at line 112 of file csasyncrequesthandler.cpp.

References MAsyncTimeObserver::HandleTimeUpdate(), iObserver, and RequestTime().

00113     {
00114     switch ( iStatus.Int() )
00115         {
00116         case ETimeServRequestTimeComplete:
00117             // The server has completed the request, signalled the client
00118             // thread and the clients active scheduler runs the active object.
00119             // Now do something with it
00120             iObserver.HandleTimeUpdate();
00121             RequestTime();   // Add this line to make the clock keep ticking
00122             break ;
00123 
00124         case KErrCancel:
00125             // The request was canceled
00126             break ;
00127 
00128         case KErrNotReady:
00129             // We requested a new time before completing the previous request
00130         default:
00131             User::Panic( KCSAsyncClient, ECSAsyncBadState ); // Unexpected error
00132             break;
00133         }
00134     }

void CCSAsyncRequestHandler::DoCancel  )  [protected]
 

From CActive, DoCancel. Cancels any outstanding operation.

Definition at line 141 of file csasyncrequesthandler.cpp.

References RTimeServerSession::CancelRequestTime(), and iSession.

00142     {
00143     iSession.CancelRequestTime();
00144     }

void CCSAsyncRequestHandler::ConstructL  )  [private]
 

ConstructL. Performs the second phase construction of a CCSAsyncRequestHandler object.

Definition at line 57 of file csasyncrequesthandler.cpp.

References RTimeServerSession::Connect(), and iSession.

00058     {
00059     User::LeaveIfError( iSession.Connect() );
00060     }


Member Data Documentation

RTimeServerSession CCSAsyncRequestHandler::iSession [private]
 

iSession, the time server session.

Definition at line 123 of file csasyncrequesthandler.h.

Referenced by ConstructL(), DoCancel(), RequestTime(), and ~CCSAsyncRequestHandler().

TTime CCSAsyncRequestHandler::iTime [private]
 

iTime, passed to the session to store the time.

Definition at line 128 of file csasyncrequesthandler.h.

Referenced by RequestTime(), and Time().

MAsyncTimeObserver& CCSAsyncRequestHandler::iObserver [private]
 

iObserver, observer which handles updates from the server.

Definition at line 133 of file csasyncrequesthandler.h.

Referenced by RunL().


The documentation for this class was generated from the following files:

© Nokia 2009

Back to top