Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: mtclbase.h
Link against: msgs.lib

Class CBaseMtm

CBaseMtm

Support

Supported from 5.0

Description

Provides a high-level interface for accessing and manipulating a Message Server entry.

Message client applications use the class to access such functionality polymorphically. MTM implementers implement a derived class to provide such functionality for their message protocol.

In pre-Unicode versions this class had the import library mcld.lib.

The following are some significant groups of functions:

Context functions: the SetCurrentEntryL() and SwitchCurrentEntryL() functions change the context—the entry on which later actions are performed. After creating a new Client-side MTM object, a message client application should set an initial context before using other functions. Note that: any changes made to an existing context are not automatically saved: the message client application should ensure this itself by calling SaveMessageL(); no message data for the new context is retrieved from the Message Server, to retrieve entry data, call LoadMessageL() after setting the context; calling Body() immediately after setting the context returns an empty CRichText object: this is because the private cache of context body text that the base class maintains is re-initialised to an empty value. MTM implementers should note that the virtual ContextEntrySwitched() is called from these functions to allow derived classes to also clear any caches of MTM-specific entry data.

Store and restore entry data functions: the changes that a message client application makes to a message context through Client-side MTM functions, such as altering the body text obtained through Body(), are, for efficiency, cached in memory by a Client-side MTM. The message store and restore functions are concerned with transferring data between that cache and committed storage. Note that, unlike message contexts, message client applications are not expected to manipulate directly service contexts. Instead, the corresponding User Interface MTM will provide dialogs to allow the user to alter service settings, and call Client-side MTM functions to handle their retrieval and storage. ER5 expects the base class functions to handle storage and retrieval for both message and service contexts, and their implementations must detect what the context is, and act accordingly. Post-ER5, the API is clarified by restricting the base class functions to handle message contexts only. To handle service contexts, a Client-side MTM must define its own functions for the User Interface MTM to call.

Store and restore body text functions: the base class maintains a private CRichText object cache to store the body text for the current context. This can be accessed for reading and writing by message client applications through Body(). StoreBodyL() and RestoreBodyL() encapsulate for implementers of derived classes the retrieval and storage of this CRichText object to a CMsvStore.

Address list functions: the format and storage of message addresses is MTM-specific. AddresseeList(), AddAddresseeL(), and RemoveAddressee() are designed to allow clients with no MTM-specific knowledge to access address information in a generic way. The base class has a protected data member iAddresseeList, an array of descriptors, which these functions manipulate. Implementations should save the address information to the appropriate place in the message store when the message is stored.

MTM-specific functionality: MTM components can offer protocol-specific functionality not provided by base class interface functions. MTM components define IDs that correspond to each protocol-specific operation offered, and implement the InvokeSyncFunctionL() and InvokeAsyncFunctionL() functions to allow clients to access these operations by passing in the appropriate ID. Two functions are provided to allow the MTM component to offer both synchronous and asynchronous functionality. Message client applications can dynamically add user-interface features for these operations using CBaseMtmUiData::MtmSpecificFunctions(). MTM developers should document the IDs if they wish to make the operations available to clients.

Derivation

CBaseBase class for all classes to be instantiated on the heap
CBaseMtmProvides a high-level interface for accessing and manipulating a Message Server entry
MMsvEntryObserverProvides the interface for notification of events associated with an entry

Defined in CBaseMtm:
AddAddresseeL(), AddresseeList(), BioTypeChangedL(), Body(), CBaseMtm(), ContextEntrySwitched(), CreateAttachmentL(), CreateMessageL(), DeleteAttachmentL(), Entry(), Find(), ForwardL(), HandleEntryEventL(), HasContext(), InvokeAsyncFunctionL(), InvokeSyncFunctionL(), LoadMessageL(), QueryCapability(), RemoveAddressee(), ReplyL(), RestoreBodyL(), RestoreL(), SaveMessageL(), Session(), SetCurrentEntryL(), SetSubjectL(), StoreBodyL(), StoreL(), SubjectL(), SwitchCurrentEntryL(), Type(), ValidateMessage(), iAddresseeList, iCharFormatLayer, iMsvEntry, iParaFormatLayer, ~CBaseMtm()

Inherited from CBase:
operator new()

Inherited from MMsvEntryObserver:
EMsvChildrenChanged, EMsvChildrenInvalid, EMsvChildrenMissing, EMsvContextInvalid, EMsvDeletedChildren, EMsvEntryChanged, EMsvEntryDeleted, EMsvEntryMoved, EMsvNewChildren, EMsvStoreCommitted, EMsvStoreCreated, EMsvStoreDeleted, HandleEntryEvent(), TMsvEntryEvent


Construction and destruction


CBaseMtm()

protected: CBaseMtm(CRegisteredMtmDll& aRegisteredMtmDll,CMsvSession& aSession);

Description

Creates a CBaseMtm with member variables initialised from the passed arguments.

Client applications do not use this function. It is relevant only to implementers of derived classes.

The value of aSession can be accessed through Session().

Derived classes can implement a constructor to perform any additional MTM-specific setup that can be safely carried out in a constructor. Such constructors must call the base class constructor function.

Derived classes also implement two-phase construction functions (NewL(), ConstructL()) to create a new instance of the object, in which any dynamic allocation should be performed. Client-side MTMs also implement a factory function by which a MTM registry can request an instance of the class.

Parameters

CRegisteredMtmDll& aRegisteredMtmDll

Registration data for the MTM DLL.

CMsvSession& aSession

The CMsvSession of the client requesting the object


~CBaseMtm()

~CBaseMtm();

Description

Cleans up the base class.

CBaseMtm -derived objects must be deleted by client applications when they are no longer required.

Derived classes can implement a destructor to do any additional clean up tasks that they require.

[Top]


Context functions


BioTypeChangedL()

virtual void BioTypeChangedL(TUid aBioTypeUid);

Support

Supported from 6.0

Description

Informs client-side MTM that the context's BIO field is being changed as a result of a call to CSendAs::SetBioTypeL().

CSendAs::SetBioTypeL() calls this function before setting the BIO field in the context's index entry. This allows a client-side MTM to perform MTM specific actions when the BIO type changes.

CSendAs will not change the BIO type if this function leaves.

The default implementation is to do nothing.

Parameters

TUid aBioTypeUid

New value for the BIO field

See also:


CreateMessageL()

virtual void CreateMessageL(TMsvId aServiceId);

Support

Supported from 6.0

Description

Creates a new message entry as a child of the current context.

The default implementation creates an empty entry with its visible flag set to false and its in-preparation flag set to true.

Parameters

TMsvId aServiceId

ID of the service to own the entry.


SetCurrentEntryL()

void SetCurrentEntryL(CMsvEntry* aEntry);

Description

Sets the entry on which later actions are performed to the specified CMsvEntry.

Parameters

CMsvEntry* aEntry

The entry on which all following actions will be performed

Leave codes

KErrNoMemory

Insufficient memory


SwitchCurrentEntryL()

void SwitchCurrentEntryL(TMsvId aId);

Description

Changes the entry on which later actions are performed to the entry with the specified TMsvId.

Parameters

TMsvId aId

The ID of the entry upon which all following actions will be performed

Leave codes

KErrNoMemory

Insufficient memory

KErrNotFound

The requested entry does not exist


ContextEntrySwitched()

protected: virtual void ContextEntrySwitched()=0;

Description

Called by the base class functions SwitchCurrentEntryL() and SetCurrentEntryL() when the context is changed to another entry.

Client applications do not use this function. It is relevant only to implementers of derived classes.

Requirements:

An implementation should clear:


HasContext()

TBool HasContext() const;

Description

Tests if an MTM context has been set.

A Client-side MTM has no context until one is set through SwitchCurrentEntryL() or SetCurrentEntryL() .

Return value

TBool

ETrue: context has been set EFalse: context has not been set

[Top]


Store and restore entry data


RestoreL()

virtual void RestoreL()=0;

Support

Withdrawn in 5.1

Description

Loads the cache with the message data for the current context—can be used for both message and service contexts.

It is typically used after the context has been set with SetCurrentEntryL() or SwitchCurrentEntryL(). CBaseMtm functions to manipulate the entry can only be called after this function has been called.

Requirements:

An implementation must restore the store and index entry relating to the context.

For a message context, typically, the message store should be opened for reading with CMsvEntry::ReadStoreL(). It should be then be read to set the following:

For a service context, the service settings should be read from the MTM-specific stream in which they are stored.


LoadMessageL()

virtual void LoadMessageL()=0;

Support

Supported from 5.1

Description

Loads the cache with the message data for the current context—can only be called on message contexts.

It is typically used after the context has been set with SetCurrentEntryL() or SwitchCurrentEntryL(). CBaseMtm functions to manipulate the entry can only be called after this function has been called.

Requirements:

An implementation must restore the store and index entry relating to the message context. Typically, the message store should be opened for reading with CMsvEntry::ReadStoreL(). It should be then be read to set the following:

The function should panic for non-message contexts.

Leave codes

 

Standard store-related errors.


StoreL()

virtual void StoreL()=0;

Support

Withdrawn in 5.1

Description

Commits cached changes to the storage controlled by the Message Server—can be used for both message and service contexts. It should be called in the following circumstances:

Requirements:

An implementation must update the store and index entry relating to the context.

For a message context, typically, the message store should be opened for editing with CMsvEntry::EditStoreL(). It should be updated as follows:

Changes can then be committed to the store with CMsvStore::CommitL().

The index entry should also be updated to reflect changes. Possible fields that may need updating include: Description (for subject changes); Details and Multiple Recipients (for recipient changes); and Size. Index entry changes are committed using CMsvEntry::ChangeL().

For a service context, the service settings should be written to the MTM-specific message store stream in which they are stored.

Leave codes

 

Standard store-related errors.


SaveMessageL()

virtual void SaveMessageL()=0;

Support

Supported from 5.1

Description

Commits cached changes to the storage controlled by the Message Server—can only be called on message contexts. It should be called in the following circumstances:

Requirements:

An implementation must update the store and index entry relating to the message context. Typically, the message store should be opened for editing with CMsvEntry::EditStoreL(). It should be updated as follows:

Changes can then be committed to the store with CMsvStore::CommitL().

The index entry should also be updated to reflect changes. Possible fields that may need updating include: Description (for subject changes); Details and Multiple Recipients (for recipient changes); and Size. Index entry changes are committed using CMsvEntry::ChangeL().

The function should panic for non-message contexts.

Leave codes

 

Standard store-related errors.

[Top]


Store and restore body text


StoreBodyL()

protected: void StoreBodyL(CMsvStore& aStore);

Description

Stores and commits the current cached CRichText body text to the appropriate stream in the specified message store. Client applications do not use this function. It is relevant only to implementers of derived classes.

The function overwrites any existing data in that stream. The implementation must have write access to aStore.

A typical use of this function is from SaveMessageL().

Parameters

CMsvStore& aStore

Message store in which to store the body text

Leave codes

KErrAccessDenied

The store was opened for read only

Other

Standard stream-related leave codes


RestoreBodyL()

protected: void RestoreBodyL(CMsvStore& aStore);

Description

Gets the current cached CRichText from the appropriate stream in the specified message store. Client applications do not use this function. It is relevant only to implementers of derived classes.

A typical use of this function is from LoadMessageL().

Parameters

CMsvStore& aStore

Message store from which to read the body text

Leave codes

 

Standard stream-related leave codes.

[Top]


Response message creation


ReplyL()

virtual CMsvOperation* ReplyL(TMsvId aDestination, TMsvPartList aPartlist, TRequestStatus& aCompletionStatus)=0;

Description

Creates a reply message to the current message context.

Some MTMs may support inclusion of elements, specified by aPartlist, from the original message in the reply. The parent for the new entry is specified in aDestination.

The returned CMsvOperation object completes when creating the reply is complete. On completion, the context is set to the reply message.

Requirements:

A typical implementation for this function would include the following steps:

If message replies are not supported, implementations should leave with KErrNotSupported.

The implementation of this function may be similar to that of ForwardL(), allowing opportunities for code sharing.

Parameters

TMsvId aDestination

The entry to which to assign the reply

TMsvPartList aPartlist

Defines the parts that are to be copied from the original message into the reply

TRequestStatus& aCompletionStatus

The request status to be completed when the operation has finished

Return value

CMsvOperation*

If successful, this is an asynchronously completing reply operation. If failed, this is a completed operation, with status set to the relevant error code.

Leave codes

KErrNotSupported

The Client-side MTM does not support reply operations

Other leave codes

Dependent on implementation


ForwardL()

virtual CMsvOperation* ForwardL(TMsvId aDestination, TMsvPartList aPartList, TRequestStatus& aCompletionStatus)=0;

Description

Creates a forwarded message from the current message context. Some MTMs may support inclusion of elements, specified by aPartlist, from the original message in the forwarded message. The parent for the new entry is specified in aDestination. The returned CMsvOperation object completes when editing the forwarded message is complete. On completion, the context is set to the forwarded message.

Requirements:

A typical implementation for this function would include the following steps:

If forwarded messages are not supported, implementations should leave with KErrNotSupported.

The implementation of this function may be similar to that of ReplyL(), allowing opportunities for code sharing.

Parameters

TMsvId aDestination

The entry to which to assign the forwarded message

TMsvPartList aPartList

Defines the parts that are to be copied from the original message into the forwarded message

TRequestStatus& aCompletionStatus

The request status to be completed when the operation has finished

Return value

CMsvOperation*

If successful, this is an asynchronously completing forward message operation. If failed, this is a completed operation, with status set to the relevant error code.

Leave codes

KErrNotSupported

The Client-side MTM does not support creation of forwarded messages

Other leave codes

Dependent on implementation

[Top]


Validation and search


ValidateMessage()

virtual TMsvPartList ValidateMessage(TMsvPartList aPartList)=0;

Description

Validates the current message context.

The precise validation performed is specific to the MTM, but, typically, checks that the specified message parts are well-formed.

Requirements:

Implementation of this function is highly protocol-specific. A minimum step is to check that the current context is a message.

Parameters

TMsvPartList aPartList

Indicates the message parts for which validation is requested

Return value

TMsvPartList

If valid, KErrNone If invalid, identifies the invalid part(s). The error value is the bitmask of the TMsvPartList IDs for each invalid part


Find()

virtual TMsvPartList Find(const TDesC& aTextToFind, TMsvPartList aPartList)=0;

Description

Searches the specified message part(s) for the plain-text version of the text to be found.

If the specified part list indicates a part that is not supported, or is not present in the current message, the function behaves as if the specified part exists but does not contain the required text.

Requirements:

The parts of the entry for which searching is allowed is implementation specific. If no searching is supported, always return 0.

Parameters

const TDesC& aTextToFind

The plain-text version of the text to be found.

TMsvPartList aPartList

Indicates the message parts which should be searched.

Return value

TMsvPartList

If the text was not found, or searching is unsupported, 0. If the text was found, a bitmask of the TMsvPartList IDs for each part in which the text was present.

[Top]


Address list


AddresseeList()

const CDesCArray& AddresseeList() const;

Description

Gets the list of intended recipients for the current context, which must be a message.

In the case of protocols that allow different classes of recipient (such as To, Cc and Bcc), the list returned is whatever the protocol defines as the default recipient list.

Requirements:

The default implementation simply returns the value of the protected data member iAddresseeList. As a consequence, Client-side MTM implementations should update this member whenever the address list is modified.

Return value

CDesCArray&

Array of recipients


AddAddresseeL()

virtual void AddAddresseeL(const TDesC& aRealAddress)=0;
virtual void AddAddresseeL(const TDesC& aRealAddress, const TDesC& aAlias)=0;

Description

Adds an addressee for the current context, which must be a message-overloaded function.

Addresses are not validated by checking their format by this function. Usually that is performed by calling Validate().

The second overload of the function allows an alias to be also supplied, which may be useful for some protocols. For example, for fax, if the address is the fax number, the alias could supply the recipient’s name.

Requirements:

Implementations should append the address to the object’s address cache in the protected iAddresseeList data member. Some implementations may also wish to store addresses in an internal data structure appropriate for the protocol, for example, a class holding message header information.

Parameters

const TDesC& aRealAddress

String representing an address to be added to the list for the current message

const TDesC& aAlias

Alias information

Leave codes

KErrNotSupported

The message already has the maximum number of addressees

Other leave codes

Dependent on implementation


RemoveAddressee()

virtual void RemoveAddressee(TInt aIndex)=0;

Description

Removes an address from the current address list. The address is specified by a zero-based index into the address list. If the index is not known, applications can use AddresseeList() to retrieve the entire list to find the item.

Requirements:

Implementations should call iAddresseeList->Delete(aIndex) to remove the address from in the address list protected data member.

Parameters

TInt aIndex

Index of address to be removed

[Top]


Data accessors and mutators


Body()

CRichText& Body() const;
const CRichText& Body() const;

Description

Gets the body text of the context, which must be a message. For non-message contexts, an empty CRichText is returned.

Return value

CRichText&

Body text of the context

See also:


SetSubjectL()

virtual void SetSubjectL(const TDesC& aSubject);

Description

Sets the subject text of the context, which must be a message.

Some Client-side MTMs may not support subject text, in which case the function leaves with KErrNotSupported.

Requirements:

If the message protocol supports subject text, implementations should maintain a private buffer to store this information, settable through this function.

Implementations should save the subject text to the appropriate place in the message store when the message is stored.

The default implementation leaves with KErrNotSupported.

Parameters

const TDesC& aSubject

Message subject text

Leave codes

KErrNotSupported

The Client-side MTMs does not support subject text

See also:


SubjectL()

virtual const TPtrC SubjectL() const;

Description

Gets the subject text of the context, which must be a message.

Some Client-side MTMs may not support subject text, in which case the function leaves with KErrNotSupported.

Requirements:

If the message protocol supports subject text, implementations should maintain a private buffer to store this information, gettable through this function.

The default implementation leaves with KErrNotSupported.

Return value

TPtrC

Message subject text

Leave codes

KErrNotSupported

The Client-side MTMs does not support subject text


Session()

CMsvSession& Session();

Description

Gets a reference to the session object passed by the creator of the Client-side MTM.

Return value

CMsvSession&

Session object used by the Client-side MTM


Type()

TUid Type() const;

Description

Gets the Type UID of the message type associated with the Client-side MTM.

Return value

TUid

UID of the message type associated with the MTM


Entry()

CMsvEntry& Entry() const;

Description

Gets a CMsvEntry for the current context. The message client application can then use this to manipulate the entry.

Implementers should note that this function returns the value of the protected data member iMsvEntry.

Return value

CMsvEntry&

CMsvEntry for the current context

[Top]


Context entry observer


HandleEntryEventL()

protected: void HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aT1, TAny* aT2, TAny* aT3);

Support

Supported from 5.1

Description

Indicates that an event has occurred.

Client applications do not use this function. It is relevant only to implementers of derived classes.

The Client-side MTM object is automatically set as an observer, through CMsvEntry::AddObserverL(), for the context whenever the context changes (by SetCurrentEntryL() or SwitchCurrentEntryL()).

The default implementation is defined to do nothing.

Requirements:

Implementations can override this function to handle events concerning the current context.

In pre-Unicode versions no default implementation of the MMsvEntryObserver interface is provided, and it must be implemented by the derived class.

Parameters

TMsvEntryEvent aEvent

Indicates the event type

TAny* aT1

Event specific argument value

TAny* aT2

Event specific argument value

TAny* aT3

Event specific argument value

See also:

[Top]


Querying MTM-specific functionality


QueryCapability()

virtual TInt QueryCapability(TUid aCapability, TInt& aResponse);

Description

Queries if the MTM supports a particular capability, specified by a UID.

For MTM-specific UIDs, see the documentation for the relevant MTM.

Requirements:

Implementations should check aCapability for the standard capability values, plus any MTM-specific capabilities, and if recognised, return a suitable response in aResponse. If aCapability is unknown, return KErrNotSupported.

The default implementation returns KErrNotSupported.

Parameters

TUid aCapability

UID of capability to be queried

TInt& aResponse

Response value. The format of the response varies according to the capability.

Return value

TInt

KErrNone: aCapability is a recognised value and a response is returned KErrNotSupported: aCapability is not a recognised value

See also:

[Top]


Calling MTM-specific functionality


InvokeAsyncFunctionL()

virtual CMsvOperation* InvokeAsyncFunctionL(TInt aFunctionId, const CMsvEntrySelection& aSelection, TDes8& aParameter, TRequestStatus& aCompletionStatus)=0;

Description

Invokes asynchronous protocol-specific operations. For synchronous operations, a similar function, InvokeSyncFunctionL(), is available.

aSelection and aParameter allow data to be passed to the operation. The TRequestStatus and CMsvOperation objects are used as normal to control and monitor the operation.

Requirements:

For functionality that requires message transport access, such as making a connection, the implementation should pass the request onto the corresponding Server-side MTM. This is done through calling CMsvSession::TransferCommandL(). Implementations may also provide protocol-specific functions themselves if this is useful.

InvokeAsyncFunctionL() should return a CMsvOperation-derived object to provide asynchronous control and monitoring of the operation. If CMsvSession::TransferCommandL() is called, this should be the CMsvOperation object returned by that function.

Parameters

TInt aFunctionId

ID of the requested operation

const CMsvEntrySelection& aSelection

Selection of message entries. This is used if the operation requires message entries to work on.

TDes8& aParameter

Buffer containing input and output parameters. The format of this is specific to the operation.

TRequestStatus& aCompletionStatus

The request status to be completed when the operation has finished

Return value

CMsvOperation*

If successful, this is an asynchronously completing operation. If failed, this is a completed operation, with status set to the relevant error code.

Leave codes

KErrNotSupported

aFunctionId is not a recognised operation ID

Other leave codes

Dependent on implementation


InvokeSyncFunctionL()

virtual void InvokeSyncFunctionL(TInt aFunctionId, const CMsvEntrySelection& aSelection, TDes8& aParameter)=0;

Description

Invokes synchronous protocol-specific operations. For asynchronous operations, a similar function, InvokeAsyncFunctionL(), is available.

aSelection and aParameter allow data to be passed to the operation.

Requirements:

For functionality that requires message transport access, such as making a connection, the implementation should pass the request onto the corresponding Server-side MTM. This is done through calling CMsvSession::TransferCommandL(). Implementations may also provide protocol-specific functions themselves if this is useful.

Parameters

TInt aFunctionId

ID of the requested operation

const CMsvEntrySelection& aSelection

Selection of message entries. This is used if the operation requires message entries to work on.

TDes8& aParameter

Buffer containing input and output parameters. The format of this is specific to the operation.

Leave codes

KErrNotSupported

aFunctionId is not a recognised operation ID

Other leave codes

Dependent on implementation

[Top]


Attachment management


CreateAttachmentL()

virtual void CreateAttachmentL(TMsvId& aAttachmentId, TFileName& aDirectory);

Support

Supported from 6.0

Description

Creates an entry for an attachment in the Message Server index.

The default implementation raises a panic if no message has been created.

Parameters

TMsvId& aAttachmentId

On return, the Message Server index ID of the attachment

TFileName& aDirectory

On return, the directory in which to save the attachment

Leave codes

 

In the default implementation, a leave can be propagated from both CMsvEntry::CreateL() and CMsvEntry::SetEntryL(). KErrNotSupported indicates that the MTM does not support attachments.


DeleteAttachmentL()

virtual void DeleteAttachmentL(TMsvId aMessageId, TMsvId aAttachmentId);

Support

Supported from 6.0

Description

Deletes an attachment from the message.

The default implementation deletes the attachment directory and any files in it. It raises a panic if no message has been created.

Parameters

TMsvId aMessageId

Message ID

TMsvId aAttachmentId

Identifies the attachment to be deleted

Leave codes

 

In the default implementation, a leave can be propagated from CMsvEntry::DeleteL(). The attachment is not deleted.

[Top]


Data members


iMsvEntry

protected: CMsvEntry* iMsvEntry

Description

The current context.


iAddresseeList

protected: CDesCArrayFlat* iAddresseeList

Description

The address list for the current context.


iParaFormatLayer

protected: CParaFormatLayer* iParaFormatLayer

Description

Paragraph formatting applied to the CRichText object for the body text, as returned by Body(). This is set to an empty CParaFormatLayer instance whenever the context is set.

Implementations can modify this if they wish to apply particular formatting to body text.


iCharFormatLayer

protected: CCharFormatLayer* iCharFormatLayer

Description

Character formatting applied to the CRichText object for the body text, as returned by Body().

Implementations can modify this if they wish to apply particular formatting to body text.