RCbs Class Reference

class RCbs : public RSessionBase

This represents the client-side session to the cbs server.

Every client must have an instance of the class to be able to communicate with the server.

Note that both client and server must use the same versions of the API. Otherwise the server will terminate the client process.

  • The server does not buffer events. This must be taken into account when using notifications.

  • There can only be one pending notification request per subsession object. The behaviour is undefined, if you try to make several for only one subsession.

Inherits from

Public Member Functions
RCbs ()
~RCbs ()
IMPORT_C TInt AddTopic ( TCbsTopic &)
IMPORT_C TInt ChangeTopicHotmarkStatus ( TCbsTopicNumber , TBool )
IMPORT_C TInt ChangeTopicNameAndNumber ( TCbsTopicNumber , TCbsTopicNumber , const TCbsTopicName &)
IMPORT_C TInt ChangeTopicSubscriptionStatus ( TCbsTopicNumber , TBool )
IMPORT_C void Close ()
IMPORT_C TInt Connect ()
IMPORT_C TBool Connected ()
IMPORT_C TInt DeleteAllTopics ()
IMPORT_C TInt DeleteMessage (const TCbsMessageHandle &)
IMPORT_C TInt DeleteTopic ( TCbsTopicNumber )
IMPORT_C TInt FindMessageByHandle (const TCbsMessageHandle &, TCbsMessage &)
IMPORT_C TInt FindTopicByNumber ( TCbsTopicNumber , TCbsTopic &)
IMPORT_C void GetHotmarkedMessageHandle ( TCbsMessageHandle &)
IMPORT_C void GetLanguages ( TCbsSettingsLanguages &)
IMPORT_C TInt GetLatestTopicNumber ( TCbsTopicNumber &)
IMPORT_C TInt GetMessage ( TCbsTopicNumber , TInt , TCbsMessage &)
IMPORT_C TInt GetMessageContents (const TCbsMessageHandle &, TDes &)
IMPORT_C TInt GetMessageCount ( TCbsTopicNumber , TInt &)
IMPORT_C TInt GetMessageIndexByHandle (const TCbsMessageHandle &, TInt &)
IMPORT_C TInt GetNewTopicsCount ( TInt &)
IMPORT_C TInt GetNextAndPrevMessageHandle (const TCbsMessageHandle &, TCbsMessageHandle &, TCbsMessageHandle &, TInt &)
IMPORT_C TInt GetNextAndPrevTopicNumber (const TCbsTopicNumber &, TCbsTopicNumber &, TCbsTopicNumber &, TInt &)
IMPORT_C void GetReceptionStatus ( TBool &)
IMPORT_C TInt GetTopic (const TInt , TCbsTopic &)
IMPORT_C void GetTopicCount ( TInt &)
IMPORT_C void GetTopicDetectionStatus ( TBool &)
IMPORT_C void GetUnreadMessageCount ( TInt &)
IMPORT_C TBool HasNextCollectionTopic ()
IMPORT_C TInt LockMessage (const TCbsMessageHandle &)
IMPORT_C TInt NextCollectionTopic ( TCbsTopicInfo &)
IMPORT_C void NotifyOnTopicListEvent ( TRequestStatus &, const TInt , TCbsTopicListEvent &, TCbsTopicNumber &)
IMPORT_C void NotifyOnTopicListEventCancel ()
IMPORT_C void NotifySettingsChanged ( TRequestStatus &, TCbsSettingsEvent &)
IMPORT_C void NotifySettingsChangedCancel ()
IMPORT_C TInt NumberOfUnreadHotmarkedMessages ()
IMPORT_C TInt ReadMessage (const TCbsMessageHandle &)
IMPORT_C TInt SaveMessage (const TCbsMessageHandle &)
IMPORT_C TInt SetLanguages (const TCbsSettingsLanguages &)
IMPORT_C TInt SetReceptionStatus ( TBool )
IMPORT_C TInt SetTopicDetectionStatus ( TBool )
IMPORT_C void Shutdown ()
IMPORT_C void StartCollectionBrowsing ()
IMPORT_C TVersion Version ()
Private Member Functions
RCbs (const RCbs &)
TBool IsServerStarted ()
TInt StartServer ()
RCbs & operator= (const RCbs &)
Inherited Functions
RHandleBase::Attributes()const
RHandleBase::BTraceId()const
RHandleBase::DoExtendedClose()
RHandleBase::Duplicate(const RThread &,TOwnerType)
RHandleBase::FullName()const
RHandleBase::FullName(TDes &)const
RHandleBase::Handle()const
RHandleBase::HandleInfo(THandleInfo *)
RHandleBase::Name()const
RHandleBase::NotifyDestruction(TRequestStatus &)
RHandleBase::Open(const TFindHandleBase &,TOwnerType)
RHandleBase::OpenByName(const TDesC &,TOwnerType,TInt)
RHandleBase::RHandleBase()
RHandleBase::RHandleBase(TInt)
RHandleBase::SetHandle(TInt)
RHandleBase::SetHandleNC(TInt)
RSessionBase::CreateSession(RServer2,const TVersion &)
RSessionBase::CreateSession(RServer2,const TVersion &,TInt)
RSessionBase::CreateSession(RServer2,const TVersion &,TInt,TIpcSessionType,const TSecurityPolicy *,TRequestStatus *)
RSessionBase::CreateSession(const TDesC &,const TVersion &)
RSessionBase::CreateSession(const TDesC &,const TVersion &,TInt)
RSessionBase::CreateSession(const TDesC &,const TVersion &,TInt,TIpcSessionType,const TSecurityPolicy *,TRequestStatus *)
RSessionBase::CreateSession(const TDesC &,const TVersion &,TInt,TRequestStatus *)
RSessionBase::Open(RMessagePtr2,TInt,TOwnerType)
RSessionBase::Open(RMessagePtr2,TInt,const TSecurityPolicy &,TOwnerType)
RSessionBase::Open(TInt,TOwnerType)
RSessionBase::Open(TInt,const TSecurityPolicy &,TOwnerType)
RSessionBase::Send(TInt)const
RSessionBase::Send(TInt,const TIpcArgs &)const
RSessionBase::SendReceive(TInt)const
RSessionBase::SendReceive(TInt,TRequestStatus &)const
RSessionBase::SendReceive(TInt,const TIpcArgs &)const
RSessionBase::SendReceive(TInt,const TIpcArgs &,TRequestStatus &)const
RSessionBase::SetReturnedHandle(TInt)
RSessionBase::SetReturnedHandle(TInt,RHandleBase &)
RSessionBase::SetReturnedHandle(TInt,const TSecurityPolicy &)
RSessionBase::ShareAuto()
RSessionBase::ShareProtected()
Inherited Enumerations
RHandleBase:TAttributes
RSessionBase:TAttachMode
Private Attributes
TBool iConnected
RCbsSettings iSettings
RCbsTopicCollection iTopicCollection
RCbsTopicList iTopicList
RCbsTopicMessages iTopicMessages
Inherited Attributes
RHandleBase::iHandle

Constructor & Destructor Documentation

RCbs()

IMPORT_C RCbs ( )

Constructor.

RCbs(const RCbs &)

RCbs ( const RCbs & ) [private]

Parameters

const RCbs &

~RCbs()

IMPORT_C ~RCbs ( )

Destructor.

Member Functions Documentation

AddTopic(TCbsTopic &)

IMPORT_C TInt AddTopic ( TCbsTopic & aTopic )

Adds a new topic. The handle assigned to the topic will be returned in aTopic.

Return values: KErrNone Topic was successfully added. KErrAlreadyExists A topic of the same number already exists in DB KErrArgument Topic number given was not in a proper range. KErrDiskFull Topic not added - FFS out of space

Note that the number of the new topic must be unused.

Parameters

TCbsTopic & aTopic Contains the information of the new topic. On return, aTopic also contains the topic handle.

ChangeTopicHotmarkStatus(TCbsTopicNumber, TBool)

IMPORT_C TInt ChangeTopicHotmarkStatus ( TCbsTopicNumber aNumber,
TBool aNewStatus
)

Changes topic hotmark status.

Parameters

TCbsTopicNumber aNumber Number of the topic
TBool aNewStatus New hotmark status

ChangeTopicNameAndNumber(TCbsTopicNumber, TCbsTopicNumber, const TCbsTopicName &)

IMPORT_C TInt ChangeTopicNameAndNumber ( TCbsTopicNumber aOldNumber,
TCbsTopicNumber aNewNumber,
const TCbsTopicName & aName
)

Changes the name and number of the existing topic.

Note that the changing fails in case there is another topic with the new topic number. It also fails if the topic is protected.

Return values: KErrNone Topic name and number successfully changed. KErrDiskFull Topic information not changed - FFS out of space

Parameters

TCbsTopicNumber aOldNumber Number of the topic to be changed
TCbsTopicNumber aNewNumber Number to be given for the topic
const TCbsTopicName & aName Name to be given for the topic

ChangeTopicSubscriptionStatus(TCbsTopicNumber, TBool)

IMPORT_C TInt ChangeTopicSubscriptionStatus ( TCbsTopicNumber aNumber,
TBool aNewStatus
)

Changes topic subscription status.

Parameters

TCbsTopicNumber aNumber Number of the topic
TBool aNewStatus New subscription status

Close()

IMPORT_C void Close ( )

Closes the session to the server.

Connect()

IMPORT_C TInt Connect ( )

Creates connection to the server.

Note that the method must be called before calling any other methods. The method returns an error code and, therefore, the caller is responsible of checking that everything went just fine.

Connected()

IMPORT_C TBool Connected ( ) const

Returns ETrue if CbsServer session has been established.

DeleteAllTopics()

IMPORT_C TInt DeleteAllTopics ( )

Delete all topics.

DeleteMessage(const TCbsMessageHandle &)

IMPORT_C TInt DeleteMessage ( const TCbsMessageHandle & aHandle )

Deletes an existing message.

Note that it does not care a lot about the status of the message.

Please check also the description of LockMessage() .

Parameters

const TCbsMessageHandle & aHandle It is handle to the message.

DeleteTopic(TCbsTopicNumber)

IMPORT_C TInt DeleteTopic ( TCbsTopicNumber aNumber )

Deletes an existing topic.

Parameters

TCbsTopicNumber aNumber Number of the topic to be deleted

FindMessageByHandle(const TCbsMessageHandle &, TCbsMessage &)

IMPORT_C TInt FindMessageByHandle ( const TCbsMessageHandle & aHandle,
TCbsMessage & aMessage
)

Finds a message by given handle.

Parameters

const TCbsMessageHandle & aHandle Handle to the message.
TCbsMessage & aMessage Return: contains the message information.

FindTopicByNumber(TCbsTopicNumber, TCbsTopic &)

IMPORT_C TInt FindTopicByNumber ( TCbsTopicNumber aNumber,
TCbsTopic & aTopic
)

Finds the topic by the given number.

Return values: KErrNone Topic returned in parameter aTopic. KErrNotFound Topic was not found.

Parameters

TCbsTopicNumber aNumber Number of the topic
TCbsTopic & aTopic Return: contains the topic information

GetHotmarkedMessageHandle(TCbsMessageHandle &)

IMPORT_C void GetHotmarkedMessageHandle ( TCbsMessageHandle & aMessage )

Returns the handle to the latest hotmarked message that has been received after the system has started up.

Parameters

TCbsMessageHandle & aMessage Handle to the message

GetLanguages(TCbsSettingsLanguages &)

IMPORT_C void GetLanguages ( TCbsSettingsLanguages & aLanguages )

Returns the preferred languages in aLanguages.

Parameters

TCbsSettingsLanguages & aLanguages The method returns the languages in this parameter.

GetLatestTopicNumber(TCbsTopicNumber &)

IMPORT_C TInt GetLatestTopicNumber ( TCbsTopicNumber & aNumber )

Returns the number of the topic which was last added to topic list.

Note: if a topic list cache is maintained by the client (as CBS UI application does), this function has to be called BEFORE calling GetTopicCount() and GetTopic() to make sure that no topic is added in between GetTopic() and GetLatestTopicHandle() calls. If this happens, GetLatestTopicHandle() will return a handle to a topic that is not cached client-side.

Return codes: KErrNone aNumber is a valid topic number. KErrNotFound No topic added since server start, aNumber is not valid.

Parameters

TCbsTopicNumber & aNumber Returns: number of the topic last added

GetMessage(TCbsTopicNumber, TInt, TCbsMessage &)

IMPORT_C TInt GetMessage ( TCbsTopicNumber aNumber,
TInt aIndex,
TCbsMessage & aMessage
)

Returns message information.

Return codes: KErrNotFound Topic or message not found. KErrNone aMessage contains the message information.

Parameters

TCbsTopicNumber aNumber Number of the topic
TInt aIndex Index to the message in topic.
TCbsMessage & aMessage Returns: the message information

GetMessageContents(const TCbsMessageHandle &, TDes &)

IMPORT_C TInt GetMessageContents ( const TCbsMessageHandle & aHandle,
TDes & aBuffer
)

Returns the message contents.

Parameters

const TCbsMessageHandle & aHandle It is handle to the message.
TDes & aBuffer It will contain the contents (as much as it fits).

GetMessageCount(TCbsTopicNumber, TInt &)

IMPORT_C TInt GetMessageCount ( TCbsTopicNumber aNumber,
TInt & aCount
)

Returns the total amount of messages the topic contains.

Return codes: KErrNotFound Invalid handle. KErrNone aCount contains the number of messages in topic

Parameters

TCbsTopicNumber aNumber Number of the topic.
TInt & aCount Number of messages in given topic.

GetMessageIndexByHandle(const TCbsMessageHandle &, TInt &)

IMPORT_C TInt GetMessageIndexByHandle ( const TCbsMessageHandle & aHandle,
TInt & aIndex
)

Returns the index of a message with given handle in topic.

Result code KErrNotFound indicates that no message was found with the given handle.

Parameters

const TCbsMessageHandle & aHandle Handle of the message
TInt & aIndex Return: index of the message in message topic

GetNewTopicsCount(TInt &)

IMPORT_C TInt GetNewTopicsCount ( TInt & aCount )

Returns the number of topics added since last GetNewTopicsCount() by the topic detection feature.

Parameters

TInt & aCount It will contain the amount of new topics.

GetNextAndPrevMessageHandle(const TCbsMessageHandle &, TCbsMessageHandle &, TCbsMessageHandle &, TInt &)

IMPORT_C TInt GetNextAndPrevMessageHandle ( const TCbsMessageHandle & aCurrentMsgHandle,
TCbsMessageHandle & aPrevMsgHandle,
TCbsMessageHandle & aNextMsgHandle,
TInt & aPosition
)

Returns the handles of messages that precede and succeed the given message in server-side list of topic messages.

Topic is resolved from the given message handle

If the given handle specifies the first message in topic, aPosition has ECbsHead bit up. If the given handle specifies the last message in topic, aPosition has ECbsTail bit up.

Return code values: KErrNone aPrevMsgHandle, aNextMsgHandle and aPosition contain valid values. KErrNotFound aCurrentMsgHandle specified a message that was not found.

Parameters

const TCbsMessageHandle & aCurrentMsgHandle Handle that specifies the message whose surroundings are returned
TCbsMessageHandle & aPrevMsgHandle Returns: handle of message preceding the given message
TCbsMessageHandle & aNextMsgHandle Returns: handle of message succeeding the given topic
TInt & aPosition Returns: position of current topic in list

GetNextAndPrevTopicNumber(const TCbsTopicNumber &, TCbsTopicNumber &, TCbsTopicNumber &, TInt &)

IMPORT_C TInt GetNextAndPrevTopicNumber ( const TCbsTopicNumber & aCurrentTopicNumber,
TCbsTopicNumber & aPrevTopicNumber,
TCbsTopicNumber & aNextTopicNumber,
TInt & aPosition
)

Returns the numbers of topics that precede and succeed the given topic in server-side topic list.

If the given topic is the first topic in list, aPosition has ECbsHead bit up. If the given topic is the last topic in list, aPosition has ECbsTail bit up.

Return code values: KErrNone aPrevTopicNumber, aNextTopicNumber and aPosition contain valid values. KErrNotFound aCurrentTopicNumber specified a topic that was not on topic list.

Parameters

const TCbsTopicNumber & aCurrentTopicNumber Number that specifies the topic whose surroundings are returned
TCbsTopicNumber & aPrevTopicNumber Returns: number of topic preceding the given topic
TCbsTopicNumber & aNextTopicNumber Returns: number of topic succeeding the given topic
TInt & aPosition Returns: position of current topic in list.

GetReceptionStatus(TBool &)

IMPORT_C void GetReceptionStatus ( TBool & aStatus )

Returns the reception status in aStatus, which is ETrue if the reception is on. Otherwise it is EFalse.

Parameters

TBool & aStatus The method returns the reception status in this parameter.

GetTopic(const TInt, TCbsTopic &)

IMPORT_C TInt GetTopic ( const TInt aIndex,
TCbsTopic & aTopic
)

Returns information about a topic from the topic list.

Return values: KErrArgument Topic was not found.

Rest of return values indicate a file error.

Parameters

const TInt aIndex It is the index to the topic.
TCbsTopic & aTopic It will contain the topic information.

GetTopicCount(TInt &)

IMPORT_C void GetTopicCount ( TInt & aCount )

Returns the total amount of topics the topic list contains.

Parameters

TInt & aCount It will contain the total amount of topics.

GetTopicDetectionStatus(TBool &)

IMPORT_C void GetTopicDetectionStatus ( TBool & aStatus )

Returns the topic detection status in aStatus, which is ETrue if the detection is on. Otherwise it is EFalse.

Parameters

TBool & aStatus The method returns the topic detection status in this parameter.

GetUnreadMessageCount(TInt &)

IMPORT_C void GetUnreadMessageCount ( TInt & aCount )

Returns the total amount of unread messages.

Parameters

TInt & aCount Return: number of unread messages

HasNextCollectionTopic()

IMPORT_C TBool HasNextCollectionTopic ( )

Returns ETrue, if there is a topic not accessed with NextTopic()

IsServerStarted()

TBool IsServerStarted ( ) [private]

Checks if the server is already started.

LockMessage(const TCbsMessageHandle &)

IMPORT_C TInt LockMessage ( const TCbsMessageHandle & aHandle )

Locks the message.

Note that a single topic messages subsession can have at most one locked message.

Message can be unlocked by trying to lock a null message. Locked message will also be automatically unlocked when subsession is closed. If a message is locked, then it will not be deleted from the database. Thus, deleting a message or trying to delete a topic that contains such a message will fail.

Locking a message does not prevent to save the message nor read the message.

Parameters

const TCbsMessageHandle & aHandle It is handle to the message to be locked.

NextCollectionTopic(TCbsTopicInfo &)

IMPORT_C TInt NextCollectionTopic ( TCbsTopicInfo & aInfo )

Returns the next topic in the topic collection skipping all topics with a topic number matching a topic already listed in the current topic list. This function will return KErrNotFound if the collection is tried to access beyond the end of the list. Otherwise the error code will be the same returned by GetTopicInfo().

Parameters

TCbsTopicInfo & aInfo The topic information will be stored here.

NotifyOnTopicListEvent(TRequestStatus &, const TInt, TCbsTopicListEvent &, TCbsTopicNumber &)

IMPORT_C void NotifyOnTopicListEvent ( TRequestStatus & aStatus,
const TInt aRequested,
TCbsTopicListEvent & aEvent,
TCbsTopicNumber & aNumber
)

Requests the server to notify the client whenever an event occurs that changes the information of the topics.

Note that the client may select what kind of events it is interested in. Note also that there can be at most one pending request per instance of the class.

Parameters

TRequestStatus & aStatus The variable that the server will modify whenever an event occurs.
const TInt aRequested Events the client is interested in
TCbsTopicListEvent & aEvent Indicates the variable that will contain the type of event that occured.
TCbsTopicNumber & aNumber Indicates the variable that will contain the topic number that was changed in event.

NotifyOnTopicListEventCancel()

IMPORT_C void NotifyOnTopicListEventCancel ( )

Cancels the pending notify request.

NotifySettingsChanged(TRequestStatus &, TCbsSettingsEvent &)

IMPORT_C void NotifySettingsChanged ( TRequestStatus & aStatus,
TCbsSettingsEvent & aEvent
)

Requests the server to notify the client whenever any settings will be changed.

Note that for each subsession only one this kind of request can be pending. Each client is responsible of assuring this.

Parameters

TRequestStatus & aStatus It is the variable that the server will modify whenever an event occurs.
TCbsSettingsEvent & aEvent The server will store the type of occurred event to this variable.

NotifySettingsChangedCancel()

IMPORT_C void NotifySettingsChangedCancel ( )

Cancels the request to notify the client.

NumberOfUnreadHotmarkedMessages()

IMPORT_C TInt NumberOfUnreadHotmarkedMessages ( )

Returns the number of unread messages in hotmarked topics.

This function is to used by the client when deciding whether the message or topic list view should be opened to display a hotmarked message(s).

ReadMessage(const TCbsMessageHandle &)

IMPORT_C TInt ReadMessage ( const TCbsMessageHandle & aHandle )

Sets the message as read.

Parameters

const TCbsMessageHandle & aHandle It is handle to the message to be set read.

SaveMessage(const TCbsMessageHandle &)

IMPORT_C TInt SaveMessage ( const TCbsMessageHandle & aHandle )

Saves a message (the saved message won't be deleted to make room for new messages).

Return codes: KErrNone Message is saved. KErrGeneral Message not saved -- total maximum of saved messages reached. KErrNotFound Message not saved -- no message associated with the given handle. KErrDiskFull Message not saved -- FFS out of space.

Parameters

const TCbsMessageHandle & aHandle Handle to the message to be saved.

SetLanguages(const TCbsSettingsLanguages &)

IMPORT_C TInt SetLanguages ( const TCbsSettingsLanguages & aLanguages )

Changes the preferred languages to aLanguages.

Parameters

const TCbsSettingsLanguages & aLanguages It contains the new preferred languages.

SetReceptionStatus(TBool)

IMPORT_C TInt SetReceptionStatus ( TBool aStatus )

Changes the reception status to aStatus.

Parameters

TBool aStatus It contains the new reception status.

SetTopicDetectionStatus(TBool)

IMPORT_C TInt SetTopicDetectionStatus ( TBool aStatus )

Changes the topic detection status to aStatus.

Parameters

TBool aStatus It contains the new topic detection status.

Shutdown()

IMPORT_C void Shutdown ( ) const

Forces the server to shut down.

StartCollectionBrowsing()

IMPORT_C void StartCollectionBrowsing ( )

Resets the iterator. Must be called prior any call to HasNextTopic() or NextTopic()!

StartServer()

TInt StartServer ( ) [private]

Starts the server.

Version()

IMPORT_C TVersion Version ( ) const

Returns the version of CbsClient.

CbsServer and CbsClient must be of same version.

operator=(const RCbs &)

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

Parameters

const RCbs &

Member Data Documentation

TBool iConnected

TBool iConnected [private]

RCbsSettings iSettings

RCbsSettings iSettings [private]

RCbsTopicCollection iTopicCollection

RCbsTopicCollection iTopicCollection [private]

RCbsTopicList iTopicList

RCbsTopicList iTopicList [private]

RCbsTopicMessages iTopicMessages

RCbsTopicMessages iTopicMessages [private]