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 TIntAddTopic(TCbsTopic &)
IMPORT_C TIntChangeTopicHotmarkStatus(TCbsTopicNumber, TBool)
IMPORT_C TIntChangeTopicNameAndNumber(TCbsTopicNumber, TCbsTopicNumber, const TCbsTopicName &)
IMPORT_C TIntChangeTopicSubscriptionStatus(TCbsTopicNumber, TBool)
IMPORT_C voidClose()
IMPORT_C TIntConnect()
IMPORT_C TBoolConnected()
IMPORT_C TIntDeleteAllTopics()
IMPORT_C TIntDeleteMessage(const TCbsMessageHandle &)
IMPORT_C TIntDeleteTopic(TCbsTopicNumber)
IMPORT_C TIntFindMessageByHandle(const TCbsMessageHandle &, TCbsMessage &)
IMPORT_C TIntFindTopicByNumber(TCbsTopicNumber, TCbsTopic &)
IMPORT_C voidGetHotmarkedMessageHandle(TCbsMessageHandle &)
IMPORT_C voidGetLanguages(TCbsSettingsLanguages &)
IMPORT_C TIntGetLatestTopicNumber(TCbsTopicNumber &)
IMPORT_C TIntGetMessage(TCbsTopicNumber, TInt, TCbsMessage &)
IMPORT_C TIntGetMessageContents(const TCbsMessageHandle &, TDes &)
IMPORT_C TIntGetMessageCount(TCbsTopicNumber, TInt &)
IMPORT_C TIntGetMessageIndexByHandle(const TCbsMessageHandle &, TInt &)
IMPORT_C TIntGetNewTopicsCount(TInt &)
IMPORT_C TIntGetNextAndPrevMessageHandle(const TCbsMessageHandle &, TCbsMessageHandle &, TCbsMessageHandle &, TInt &)
IMPORT_C TIntGetNextAndPrevTopicNumber(const TCbsTopicNumber &, TCbsTopicNumber &, TCbsTopicNumber &, TInt &)
IMPORT_C voidGetReceptionStatus(TBool &)
IMPORT_C TIntGetTopic(const TInt, TCbsTopic &)
IMPORT_C voidGetTopicCount(TInt &)
IMPORT_C voidGetTopicDetectionStatus(TBool &)
IMPORT_C voidGetUnreadMessageCount(TInt &)
IMPORT_C TBoolHasNextCollectionTopic()
IMPORT_C TIntLockMessage(const TCbsMessageHandle &)
IMPORT_C TIntNextCollectionTopic(TCbsTopicInfo &)
IMPORT_C voidNotifyOnTopicListEvent(TRequestStatus &, const TInt, TCbsTopicListEvent &, TCbsTopicNumber &)
IMPORT_C voidNotifyOnTopicListEventCancel()
IMPORT_C voidNotifySettingsChanged(TRequestStatus &, TCbsSettingsEvent &)
IMPORT_C voidNotifySettingsChangedCancel()
IMPORT_C TIntNumberOfUnreadHotmarkedMessages()
IMPORT_C TIntReadMessage(const TCbsMessageHandle &)
IMPORT_C TIntSaveMessage(const TCbsMessageHandle &)
IMPORT_C TIntSetLanguages(const TCbsSettingsLanguages &)
IMPORT_C TIntSetReceptionStatus(TBool)
IMPORT_C TIntSetTopicDetectionStatus(TBool)
IMPORT_C voidShutdown()
IMPORT_C voidStartCollectionBrowsing()
IMPORT_C TVersionVersion()
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_CRCbs()

Constructor.

RCbs(const RCbs &)

RCbs(const RCbs &)[private]

Parameters

const RCbs &

~RCbs()

IMPORT_C~RCbs()

Destructor.

Member Functions Documentation

AddTopic(TCbsTopic &)

IMPORT_C TIntAddTopic(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 & aTopicContains the information of the new topic. On return, aTopic also contains the topic handle.

ChangeTopicHotmarkStatus(TCbsTopicNumber, TBool)

IMPORT_C TIntChangeTopicHotmarkStatus(TCbsTopicNumberaNumber,
TBoolaNewStatus
)

Changes topic hotmark status.

Parameters

TCbsTopicNumber aNumberNumber of the topic
TBool aNewStatusNew hotmark status

ChangeTopicNameAndNumber(TCbsTopicNumber, TCbsTopicNumber, const TCbsTopicName &)

IMPORT_C TIntChangeTopicNameAndNumber(TCbsTopicNumberaOldNumber,
TCbsTopicNumberaNewNumber,
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 aOldNumberNumber of the topic to be changed
TCbsTopicNumber aNewNumberNumber to be given for the topic
const TCbsTopicName & aNameName to be given for the topic

ChangeTopicSubscriptionStatus(TCbsTopicNumber, TBool)

IMPORT_C TIntChangeTopicSubscriptionStatus(TCbsTopicNumberaNumber,
TBoolaNewStatus
)

Changes topic subscription status.

Parameters

TCbsTopicNumber aNumberNumber of the topic
TBool aNewStatusNew subscription status

Close()

IMPORT_C voidClose()

Closes the session to the server.

Connect()

IMPORT_C TIntConnect()

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 TBoolConnected()const

Returns ETrue if CbsServer session has been established.

DeleteAllTopics()

IMPORT_C TIntDeleteAllTopics()

Delete all topics.

DeleteMessage(const TCbsMessageHandle &)

IMPORT_C TIntDeleteMessage(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 & aHandleIt is handle to the message.

DeleteTopic(TCbsTopicNumber)

IMPORT_C TIntDeleteTopic(TCbsTopicNumberaNumber)

Deletes an existing topic.

Parameters

TCbsTopicNumber aNumberNumber of the topic to be deleted

FindMessageByHandle(const TCbsMessageHandle &, TCbsMessage &)

IMPORT_C TIntFindMessageByHandle(const TCbsMessageHandle &aHandle,
TCbsMessage &aMessage
)

Finds a message by given handle.

Parameters

const TCbsMessageHandle & aHandleHandle to the message.
TCbsMessage & aMessageReturn: contains the message information.

FindTopicByNumber(TCbsTopicNumber, TCbsTopic &)

IMPORT_C TIntFindTopicByNumber(TCbsTopicNumberaNumber,
TCbsTopic &aTopic
)

Finds the topic by the given number.

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

Parameters

TCbsTopicNumber aNumberNumber of the topic
TCbsTopic & aTopicReturn: contains the topic information

GetHotmarkedMessageHandle(TCbsMessageHandle &)

IMPORT_C voidGetHotmarkedMessageHandle(TCbsMessageHandle &aMessage)

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

Parameters

TCbsMessageHandle & aMessageHandle to the message

GetLanguages(TCbsSettingsLanguages &)

IMPORT_C voidGetLanguages(TCbsSettingsLanguages &aLanguages)

Returns the preferred languages in aLanguages.

Parameters

TCbsSettingsLanguages & aLanguagesThe method returns the languages in this parameter.

GetLatestTopicNumber(TCbsTopicNumber &)

IMPORT_C TIntGetLatestTopicNumber(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 & aNumberReturns: number of the topic last added

GetMessage(TCbsTopicNumber, TInt, TCbsMessage &)

IMPORT_C TIntGetMessage(TCbsTopicNumberaNumber,
TIntaIndex,
TCbsMessage &aMessage
)

Returns message information.

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

Parameters

TCbsTopicNumber aNumberNumber of the topic
TInt aIndexIndex to the message in topic.
TCbsMessage & aMessageReturns: the message information

GetMessageContents(const TCbsMessageHandle &, TDes &)

IMPORT_C TIntGetMessageContents(const TCbsMessageHandle &aHandle,
TDes &aBuffer
)

Returns the message contents.

Parameters

const TCbsMessageHandle & aHandleIt is handle to the message.
TDes & aBufferIt will contain the contents (as much as it fits).

GetMessageCount(TCbsTopicNumber, TInt &)

IMPORT_C TIntGetMessageCount(TCbsTopicNumberaNumber,
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 aNumberNumber of the topic.
TInt & aCountNumber of messages in given topic.

GetMessageIndexByHandle(const TCbsMessageHandle &, TInt &)

IMPORT_C TIntGetMessageIndexByHandle(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 & aHandleHandle of the message
TInt & aIndexReturn: index of the message in message topic

GetNewTopicsCount(TInt &)

IMPORT_C TIntGetNewTopicsCount(TInt &aCount)

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

Parameters

TInt & aCountIt will contain the amount of new topics.

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

IMPORT_C TIntGetNextAndPrevMessageHandle(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 & aCurrentMsgHandleHandle that specifies the message whose surroundings are returned
TCbsMessageHandle & aPrevMsgHandleReturns: handle of message preceding the given message
TCbsMessageHandle & aNextMsgHandleReturns: handle of message succeeding the given topic
TInt & aPositionReturns: position of current topic in list

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

IMPORT_C TIntGetNextAndPrevTopicNumber(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 & aCurrentTopicNumberNumber that specifies the topic whose surroundings are returned
TCbsTopicNumber & aPrevTopicNumberReturns: number of topic preceding the given topic
TCbsTopicNumber & aNextTopicNumberReturns: number of topic succeeding the given topic
TInt & aPositionReturns: position of current topic in list.

GetReceptionStatus(TBool &)

IMPORT_C voidGetReceptionStatus(TBool &aStatus)

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

Parameters

TBool & aStatusThe method returns the reception status in this parameter.

GetTopic(const TInt, TCbsTopic &)

IMPORT_C TIntGetTopic(const TIntaIndex,
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 aIndexIt is the index to the topic.
TCbsTopic & aTopicIt will contain the topic information.

GetTopicCount(TInt &)

IMPORT_C voidGetTopicCount(TInt &aCount)

Returns the total amount of topics the topic list contains.

Parameters

TInt & aCountIt will contain the total amount of topics.

GetTopicDetectionStatus(TBool &)

IMPORT_C voidGetTopicDetectionStatus(TBool &aStatus)

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

Parameters

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

GetUnreadMessageCount(TInt &)

IMPORT_C voidGetUnreadMessageCount(TInt &aCount)

Returns the total amount of unread messages.

Parameters

TInt & aCountReturn: number of unread messages

HasNextCollectionTopic()

IMPORT_C TBoolHasNextCollectionTopic()

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 TIntLockMessage(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 & aHandleIt is handle to the message to be locked.

NextCollectionTopic(TCbsTopicInfo &)

IMPORT_C TIntNextCollectionTopic(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 & aInfoThe topic information will be stored here.

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

IMPORT_C voidNotifyOnTopicListEvent(TRequestStatus &aStatus,
const TIntaRequested,
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 & aStatusThe variable that the server will modify whenever an event occurs.
const TInt aRequestedEvents the client is interested in
TCbsTopicListEvent & aEventIndicates the variable that will contain the type of event that occured.
TCbsTopicNumber & aNumberIndicates the variable that will contain the topic number that was changed in event.

NotifyOnTopicListEventCancel()

IMPORT_C voidNotifyOnTopicListEventCancel()

Cancels the pending notify request.

NotifySettingsChanged(TRequestStatus &, TCbsSettingsEvent &)

IMPORT_C voidNotifySettingsChanged(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 & aStatusIt is the variable that the server will modify whenever an event occurs.
TCbsSettingsEvent & aEventThe server will store the type of occurred event to this variable.

NotifySettingsChangedCancel()

IMPORT_C voidNotifySettingsChangedCancel()

Cancels the request to notify the client.

NumberOfUnreadHotmarkedMessages()

IMPORT_C TIntNumberOfUnreadHotmarkedMessages()

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 TIntReadMessage(const TCbsMessageHandle &aHandle)

Sets the message as read.

Parameters

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

SaveMessage(const TCbsMessageHandle &)

IMPORT_C TIntSaveMessage(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 & aHandleHandle to the message to be saved.

SetLanguages(const TCbsSettingsLanguages &)

IMPORT_C TIntSetLanguages(const TCbsSettingsLanguages &aLanguages)

Changes the preferred languages to aLanguages.

Parameters

const TCbsSettingsLanguages & aLanguagesIt contains the new preferred languages.

SetReceptionStatus(TBool)

IMPORT_C TIntSetReceptionStatus(TBoolaStatus)

Changes the reception status to aStatus.

Parameters

TBool aStatusIt contains the new reception status.

SetTopicDetectionStatus(TBool)

IMPORT_C TIntSetTopicDetectionStatus(TBoolaStatus)

Changes the topic detection status to aStatus.

Parameters

TBool aStatusIt contains the new topic detection status.

Shutdown()

IMPORT_C voidShutdown()const

Forces the server to shut down.

StartCollectionBrowsing()

IMPORT_C voidStartCollectionBrowsing()

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

StartServer()

TInt StartServer()[private]

Starts the server.

Version()

IMPORT_C TVersionVersion()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]