MMdESessionObserver Class Reference

class MMdESessionObserver

Observer interface for a metadata engine session.

Examples of MdE session usage:

The class that needs a MdE session needs to implement MMdESessionObserver interface to get a notification of completed session opening or an error that has occurred.

class CMdESessionExample : public MMdESessionObserver { void HandleSessionOpened(CMdESession& aSession, TInt aError); void HandleSessionError(CMdESession& aSession, TInt aError); ...

CMdESession* iMdeSession; };

The session is opened simply by creating an instance of CMdESession.

void CMdESessionExample::OpenSession() { iMdeSession = CMdESession::NewL( *this ); }

void CMdESessionExample::HandleSessionOpened(CMdESession& aSession, TInt aError) { if ( KErrNone != aError ) { // Error occurred when opening session. iMdeSession must be deleted and new // session opened if we wish to use MdE.

delete iMdeSession; iMdeSession = NULL; return; }

// The session was opened successfully. ... }

void CMdESessionError::HandleSessionError(CMdESession& aSession, TInt aError) { // This function is called when an error has occurred in the session by some // external source (e.g. other clients). It s important to notice, that // this method is called when the session has already been opened, not when // error happens during opening. Session can't be used anymore and it must be deleted.

delete iMdeSession; iMdeSession = NULL; }

Public Member Functions
voidHandleSessionError(CMdESession &, TInt)
voidHandleSessionOpened(CMdESession &, TInt)

Member Functions Documentation

HandleSessionError(CMdESession &, TInt)

voidHandleSessionError(CMdESession &aSession,
TIntaError
)[pure virtual]

Called to notify the observer about errors, which are not a direct consequence of the operations initiated by the client but caused by some external source (e.g., other clients). The error cannot be recovered and all on-going operations initiated by the client have been aborted. Any attempts to continue using the session will cause a panic. The client should close the session immediately and try to open a new session, if it needs to continue using the metadata engine.

Parameters

CMdESession & aSessionsession
TInt aErrorone of the system-wide error codes

HandleSessionOpened(CMdESession &, TInt)

voidHandleSessionOpened(CMdESession &aSession,
TIntaError
)[pure virtual]

Called to notify the observer that opening the session has been completed and, if the opening succeeded, the session is ready for use.

Parameters

CMdESession & aSessionsession
TInt aErrorKErrNone, if opening the session succeeded; or one of the system-wide error codes, if opening the session failed