Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: mtsr.h
Link against: msgs.lib

Class CBaseServerMtm

CBaseServerMtm

Support

Supported from 5.0

Description

Base class for Server-side MTM components. Server-side MTMs provide all message transport functionality for a particular messaging protocol.

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

MTM implementers implement a derived class to provide such functionality for their message protocol. Writers of message client applications are never concerned with this class and its sub-classes, as these are only accessed by the Message Server.

Each MTM interprets the generic commands in different ways. For example, a Fax MTM would transmit a fax when asked to copy a fax from a local folder to a fax service. For the same function, an IMAP MTM would create a copy of the message on the remote server and update the message index to show the copy of the message on the remote server. An important initial design task is to the map the functions to the functionality provided by the protocol.

Server-side MTM functions are called by the Message Server as a result of a client request that requires some remote operation with the MTM’s protocol. The following steps give a simplified view of the usual sequence of events:

To qualify this somewhat:

For asynchronous requests, a Server-side MTM should always complete the TRequestStatus with KErrNone. Any errors should be returned in the progress information.

Note the following significant groups of functions:

Copy and move from remote functions: CopyToLocalL() and MoveToLocalL() are called by the Message Server to get a selection of entries from a remote location. For many protocols, this should be interpreted as message retrieval. For protocols where messages exist on a remote server, this function is typically used to download specific messages, after an initial connection has downloaded message headers.

Copy and move to remote functions: CopyFromLocalL() and MoveFromLocalL() are called by the Message Server to copy/move a selection of entries to a remote location. For many protocols, this should be interpreted as message sending.

Copy and move within remote functions: CopyWithinServiceL() and MoveWithinServiceL() are called by the Message Server to copy a selection of entries within a remote service. An example of their use might be for a user rearranging messages within remote folders.

Derivation

CActiveThe core class of the active object abstraction
CBaseBase class for all classes to be instantiated on the heap
CBaseServerMtm(No abstract)

Defined in CBaseServerMtm:
CBaseServerMtm(), ChangeL(), CommandExpected(), CopyFromLocalL(), CopyToLocalL(), CopyWithinServiceL(), CreateL(), DeleteAllL(), DoComplete(), DoRunL(), MoveFromLocalL(), MoveToLocalL(), MoveWithinServiceL(), Progress(), RunL(), SetInitialEntry(), StartCommandL(), iServerEntry, ~CBaseServerMtm()

Inherited from CActive:
Cancel(), Deque(), DoCancel(), EPriorityHigh, EPriorityIdle, EPriorityLow, EPriorityStandard, EPriorityUserInput, IsActive(), IsAdded(), Priority(), RunError(), SetActive(), SetPriority(), TPriority, iStatus

Inherited from CBase:
operator new()


Construction and destruction


CBaseServerMtm()

protected: CBaseServerMtm(CRegisteredMtmDll& aRegisteredMtmDll);

Support

Withdrawn in 5.1

Description

Initialises member variables from the passed arguments.

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.

Parameters

CRegisteredMtmDll& aRegisteredMtmDll

Registration data for the MTM DLL


CBaseServerMtm()

protected: CBaseServerMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvServerEntry* aServerEntry);

Support

Supported from 5.1

Description

Initialises member variables from the passed arguments. The object is passed a CMsvServerEntry object in aServerEntry. This object is used to access and change Message Server entries. Its context is initially set either to the parent of the entry or selection being operated on, or the entry itself. The base class constructor stores it in the protected iServerEntry member.

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.

For pre-Unicode releases, see the previous constructor definition and SetInitialEntry().

Parameters

CRegisteredMtmDll& aRegisteredMtmDll

Registration data for the MTM DLL

CMsvServerEntry* aInitialEntry

Context on which to operate


~CBaseServerMtm()

~CBaseServerMtm();

Description

Cleans up the base class. CBaseServerMtm-derived objects are deleted by the Message Server when they are no longer required.

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


SetInitialEntry()

virtual void SetInitialEntry(CMsvServerEntry* aEntry)=0;

Support

Withdrawn in 5.1

Description

Sets the initial context for the object when called by the Message Server. The context is initially set either to the parent of the entry or selection being operated on, or the entry itself.

The function should be implemented to store the passed CMsvServerEntry in a suitable piece of private data.

Parameters

CMsvServerEntry* aEntry

The entry that the object should set as its initial context.

[Top]


Create, change, delete


ChangeL()

virtual void ChangeL(TMsvEntry aNewEntry, TRequestStatus& aStatus)=0;

Description

Updates a remote entry with relevant data when called by the Message Server. Implementations should provide this function if the messaging protocol supports updating of remote entries. If this is not supported, implementations should leave with KErrNotSupported.

The Server-side MTM implementation must decide what information in the TMsvEntry is relevant to the remote entry, and translate it appropriately for the specific protocol. Most of the data contained in the TMsvEntry is specific to the EPOC Message Server, and would probably have no direct correlation with the protocol’s own storage format. Some entry data may however be useful. For example, if the protocol supports remote renaming of folders, the implementation could:

The implementation should also always update the local Message Server index through CMsvServerEntry::ChangeL().

Parameters

TMsvEntry aNewEntry

Data by which to update entry

TRequestStatus& aStatus

Asynchronous completion word for the operation.

Leave codes

KErrNotSupported

The Server-side MTM does not support this operation

Other leave codes

Dependent on implementation


CreateL()

virtual void CreateL(TMsvEntry aNewEntry, TRequestStatus& aStatus)=0;

Description

Creates a new remote entry with relevant data when called by the Message Server. Implementations should provide this function if the messaging protocol supports creation of remote entries. If this is not supported, implementations should leave with KErrNotSupported.

As with ChangeL(), the Server-side MTM implementation must decide what information in the TMsvEntry is relevant to the remote entry, and translate it appropriately for the specific protocol. Most of the data contained in the TMsvEntry is specific to the Message Server, and would probably have no direct correlation with the protocol’s own storage format. For example, for a folder, probably only the name and parent are needed, so if the protocol supports creation of remote folders, the implementation could:

Parameters

TMsvEntry aNewEntry

Data by which to create entry

TRequestStatus& aStatus

Asynchronous completion word for the operation.

Leave codes

KErrNotSupported

The Server-side MTM does not support this operation

Other leave codes

Dependent on implementation


DeleteAllL()

virtual void DeleteAllL(const CMsvEntrySelection& aSelection, TRequestStatus& aStatus)=0;

Description

Deletes each entry in the supplied selection when called by the message Server. If any of the entries in the selection is a parent entry, then all its children should also be deleted, recursively to the bottom of the ownership tree.

Implementations should provide this function if the messaging protocol supports deletion of remote entries. If this is not supported, implementations should leave with KErrNotSupported.

Parameters

const CMsvEntrySelection& aSelection

The collection of entries that are to be deleted.

TRequestStatus& aStatus

Asynchronous completion object.

Leave codes

KErrNotSupported

The Server-side MTM does not support this operation

Other leave codes

Dependent on implementation

[Top]


Copy and move from remote


CopyToLocalL()

virtual void CopyToLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus)=0;

Description

Copies a selection of entries from a remote location to a local location. This will only be meaningful for some protocols.

Requirements:

Implementations should provide this function if the messaging protocol supports retrieval of remote entries. If this is not supported, implementations should leave with KErrNotSupported.

Implementations of this function have three fundamental steps:

Parameters

const CMsvEntrySelection& aSelection

The collection of message index entries for which the copy/moving is required.

TMsvId aDestination

The entry ID to which the selection is to be copied

TRequestStatus& aStatus

Asynchronous completion word for the operation

Leave codes

KErrNotSupported

The Server-side MTM does not support this operation

Other leave codes

Dependent on implementation


MoveToLocalL()

virtual void MoveToLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus)=0;

Description

Moves a selection of entries from a remote location to a local location.

Requirements:

Implementations should provide this function if the messaging protocol supports retrieval of remote entries. If this is not supported, implementations should leave with KErrNotSupported.

Implementations of this function have three fundamental steps:

MoveToLocalL() should differ from CopyToLocalL() in additionally deleting the original remote data.

Parameters

const CMsvEntrySelection& aSelection

The collection of message index entries for which the moving is required.

TMsvId aDestination

The entry ID to which the selection is to be copied/moved

TRequestStatus& aStatus

Asynchronous completion word for the operation

Leave codes

KErrNotSupported

The Server-side MTM does not support this operation

Other leave codes

Dependent on implementation

[Top]


Copy and move to remote


CopyFromLocalL()

virtual void CopyFromLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus)=0;

Description

Copies a selection of entries from a local location to a remote location.

Requirements:

Implementations should provide this function if the messaging protocol supports retrieval of remote entries. If this is not supported, implementations should leave with KErrNotSupported.

Implementations of this function have three fundamental steps:

Parameters

const CMsvEntrySelection& aSelection

The collection of message index entries for which the copy is required

TMsvId aDestination

The entry ID of the service by which the entries should be transferred

TRequestStatus& aStatus

Asynchronous completion word for the operation

Leave codes

KErrNotSupported

The Server-side MTM does not support this operation

Other leave codes

Dependent on implementation


MoveFromLocalL()

virtual void MoveFromLocalL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus)=0;

Description

Moves a selection of entries from a local location to a remote location.

Requirements:

Implementations should provide this function if the messaging protocol supports retrieval of remote entries. If this is not supported, implementations should leave with KErrNotSupported.

Implementations of this function have three fundamental steps:

The implementation of MoveFromLocalL() should differ from CopyFromLocalL() in additionally deleting the original local data.

Parameters

const CMsvEntrySelection& aSelection

The collection of message index entries for which the move is required

TMsvId aDestination

The entry ID of the service by which the entries should be transferred

TRequestStatus& aStatus

Asynchronous completion word for the operation

Leave codes

KErrNotSupported

The Server-side MTM does not support this operation

Other leave codes

Dependent on implementation

[Top]


Copy and move within remote


CopyWithinServiceL()

virtual void CopyWithinServiceL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus)=0;

Description

Copies a selection of entries within a remote location.

Requirements:

Implementations should provide this function if the messaging protocol supports the ability to copy entries within a remote service. If this is not supported, implementations should leave with KErrNotSupported.

Parameters

const CMsvEntrySelection& aSelection

The collection of message index entries for which the copy is required

TMsvId aDestination

The server entry ID to which the selection is to be copied

TRequestStatus& aStatus

Asynchronous completion word for the operation

Leave codes

KErrNotSupported

The Server-side MTM does not support this operation

Other leave codes

Dependent on implementation


MoveWithinServiceL()

virtual void MoveWithinServiceL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aStatus)=0;

Description

Moves a selection of entries within a remote location.

Requirements:

Implementations should provide this function if the messaging protocol supports the ability to move entries within a remote service. If this is not supported, implementations should leave with KErrNotSupported.

The implementation of MoveWithinServiceL() should differ from CopyWithinServiceL() in additionally deleting the original data.

Parameters

const CMsvEntrySelection& aSelection

The collection of message index entries for which the move is required

TMsvId aDestination

The server entry ID to which the selection is to be moved

TRequestStatus& aStatus

Asynchronous completion word for the operation

Leave codes

KErrNotSupported

The Server-side MTM does not support this operation

Other leave codes

Dependent on implementation

[Top]


Command and progress


StartCommandL()

virtual void StartCommandL(CMsvEntrySelection& aSelection, TInt aCommand, const TDesC8& aParameter, TRequestStatus& aStatus)=0;

Description

Executes an MTM-specific operation on a selection of entries when called by the Message Server.

The call is made as a response to a client program invoking an MTM-specific operation through CBaseMtm::InvokeSyncFunctionL()/InvokeAsyncFunctionL(). The aSelection, aCommand, and aParameter arguments pass the values of the original aSelection, aFunctionId, and aParameter respectively arguments from such a call. The use (if any) of the aSelection and aParameter arguments by the function depends on the command.

Parameters

CMsvEntrySelection& aSelection

A selection of message entries on which the command is to be executed

TInt aCommand

The MTM-specific command to be carried out

const TDesC8& aParameter

Command-specific parameters

TRequestStatus& aStatus

Asynchronous completion word for the operation

Leave codes

 

The function can leave with MTM- and command-specific leave codes.


CommandExpected()

virtual TBool CommandExpected()=0;

Description

Tests if the Server-side MTM object should be deleted when called by the Message Server

It is useful to stop the MTM being deleted when more commands are expected shortly. This would be the case, for example, after receiving a command to go online.

If there are no more commands expected by the Server-side MTM object, then the function should return EFalse, and the Message Server will delete it.

Return value

TBool

ETrue: the MTM object should not be deleted EFalse: the MTM object can be deleted


Progress()

virtual const TDesC8& Progress()=0;

Description

This function is called by the Message Server to get progress information for the current asynchronous operation.

The call is made as a response to a client program requesting progress information through CMsvOperation::ProgressL(). The packing format used in the TDesC8 is MTM-specific. Only the implementation of the User Interface MTM progress information functions need to understand the format.

The progress buffer should have a maximum size of 256 bytes.

Return value

TDesC8&

Progress information on current asynchronous operation

See also:

[Top]


Active object completion


RunL()

void RunL();

Description

Provides a simple implementation of CActive::RunL() that calls the derived class's DoRunL() function. If that function leaves, then the leave is trapped, and DoComplete() is called to handle the error.

This implementation ensures that derived classes handle leave errors in RunL(), rather than the default of the error being passed to the active scheduler.


DoRunL()

protected: virtual void DoRunL()=0;

Description

Handles the completion of any asynchronous requests that it makes. It is called from the base class RunL() .

Note that any leaves made by this function result in DoComplete() being called with the leave code.


DoComplete()

virtual void DoComplete(TInt aError)=0;

Description

Called by the base class RunL() if DoRunL() leaves. It should be implemented to handle this error. For example, progress information could be updated to reflect the problem.

Parameters

TInt aError

The leave code given by DoRunL().

[Top]


Data members


iServerEntry

protected: CMsvServerEntry* iServerEntry

Support

Supported from 5.1

Description

The entry on which to operate. It is set in the constructor.

The destructor deletes this member.