CMcn Class Reference

class CMcn : public CBase

Client must first connect to the server and then register a MCbsMcnObserver-derived class to receive notifications when MCN messages are received from the network.

Registration to CbsServer is not required to retrieve the current cell info message.

In the example below, the client has implemented the class MCbsMcnObserver in class CCbsMcnObserver. First, the client establishes a session with CbsServer. The subscribed topics are specified with a CMcnTopicArray instance.

Example:

// Establish the session. CMcn* session = CMcn::NewL() ; CleanupStack::PushL( session );

// Specify topics with CMcnTopicArray . CMcnTopicArray* topics = CMcnTopicArray::NewL() ; topics->AddCbTopicL( 50 ); // District info (cell info) topics->AddCbTopicL( 0 ); // CB index messages

// Register. Parameter observer is an instance of CCbsMcnObserver. session->RegisterL( observer, topics ); delete topics;

// Get current MCN state. TMcnMessage mcnInfo; TInt result( session->GetCellInfo( mcnInfo ) ); if ( result != KErrNone ) { // mcnInfo contains the current MCN message. }

// Observer's CellInfoChanged() gets called if MCN state changes. // Note that the active scheduler must be running here.

// Terminate session. session->Unregister( observer ); CleanupStack::PopAndDestroy() ; // session, gets closed when deleted

Inherits from

Constructor & Destructor Documentation

CMcn()

CMcn ( ) [private]

Default constructor.

CMcn(const CMcn &)

CMcn ( const CMcn & ) [private]

Parameters

const CMcn &

~CMcn()

IMPORT_C ~CMcn ( )

Destructor. Also closes CbsServer session.

Member Functions Documentation

ConstructL()

void ConstructL ( ) [private]

2nd-phase constructor

GetCellInfo(TDes &)

IMPORT_C TInt GetCellInfo ( TDes & aMcnMessage ) const

Retrieves the current MCN message (Cell Info, topic 050) from CBS server. A new MCN message always overwrites the previous one in CBS server, no buffering is done. Note that this function may be only used to retrieve cell info messages.

Return codes: KErrNone aMcnMessage contains the current, valid MCN message. KErrNotFound CbsServer has not yet received a MCN message. Content of aMcnMessage must be ignored.

Parameters

TDes & aMcnMessage Returns the current MCN message.

GetInfoMessage(TDes &, TInt)

IMPORT_C TInt GetInfoMessage ( TDes & aInfoMessage,
TInt aTopicNumber
) const

Retrieves the current info message (e.g. HomeZone, topic 221) from CBS server. A new info message always overwrites the previous one in CBS server, no buffering is done. Note that this function may be only used to retrieve cell info messages.

Return codes: KErrNone aInfoMessage contains the current, valid info message. KErrNotFound CbsServer has not yet received a info message. Content of aInfoMessage must be ignored.

Parameters

TDes & aInfoMessage Returns the current info message.
TInt aTopicNumber Number of the topic

NewL()

IMPORT_C CMcn * NewL ( ) [static]

Instantiates new CMcn object and establishes a session with CBS server.

If connecting to CBS server fails, the function leaves with the leave code of RSessionBase::CreateSession() .

Active scheduler has to be installed prior to calling this function.

RegisterL(MCbsMcnObserver *, const CMcnTopicArray &)

IMPORT_C void RegisterL ( MCbsMcnObserver * aObserver,
const CMcnTopicArray & aArray
)

Registers an observer to CBS server. The observer is notified when a MCN message is received from the network. The caller is also required to provide an array containing numbers of subscribed topics.

Parameter aArray may contain topic number entry duplicates. Topics may be in any order.

Leave codes indicate an error accessing EPOC Telephony Sever. In this case, the leave code is the same returned by EPOC Telephony Sever.

Parameters

MCbsMcnObserver * aObserver Observer implemented by the client
const CMcnTopicArray & aArray List of relayed topics

RelayMessage(TCbsMcnMessage &)

void RelayMessage ( TCbsMcnMessage & aMcnMessage ) [private]

Relays aMcnMessage to the registered observers. Used by a friend class CCbsMcnListener instance

Parameters

TCbsMcnMessage & aMcnMessage Received CB message from CbsServer

Unregister(MCbsMcnObserver *)

IMPORT_C void Unregister ( MCbsMcnObserver * aObserver )

Unregisters a previously registered MCN observer clearing any topic subscriptions of this client in CBS server.

Panics if the observer specified was not registered.

Parameters

MCbsMcnObserver * aObserver Observer implemented by the client

operator=(const CMcn &)

CMcn & operator= ( const CMcn & ) [private]

Parameters

const CMcn &

Member Data Documentation

CCbsMcnListener * iMcnListener

CCbsMcnListener * iMcnListener [private]

Own: Active object responsible for responding to server-initiated notification indicating that a message has arrived from the CbsServer.

CArrayPtrFlat< MCbsMcnObserver > * iObservers

CArrayPtrFlat < MCbsMcnObserver > * iObservers [private]

RCbsMcnSession iSession

RCbsMcnSession iSession [private]