Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <IMPCMTM.H>
Link against: imcm.lib

Class CImap4ClientMtm

class CImap4ClientMtm : public CBaseMtm, public MImUndoOffLineOperation;

Description

IMAP4 client MTM interface, providing access to the email services using the IMAP4 protocol.

The class provides support for:

Note that CImap4ClientMtm does not support many of the generic functions defined by the CBaseMtm base class. In particular:

IMAP specific commands are issued through the CImap4ClientMtm::InvokeAsyncFunctionL(TInt,const CMsvEntrySelection &,TDes8 &,TRequestStatus &) function, with the commands defined in the TImap4Cmds enumeration. Details of particular commands are given in the documentation for that enumeration, but the following describes some of the key concepts required to use those commands. Note that usually these commands do not correspond directly to the IMAP protocol commands described in RFC 3501. Instead, they are at a higher level, to simplify the logic required for an email client program.

--------------------------------------

Connection and services

Settings for connection to and use of an IMAP4 mail server and its mailboxes are encapsulated in an CImImap4Settings object, created and accessed through CEmailAccounts. Preferences for the network connection (e.g. the ISP to use) to be made to access an IMAP server are also accessed through CEmailAccounts.

The settings are associated with a service-type entry in the Message Server's message store. Message and folder type entries under the service entry store a local copy of the mailboxes and messages that are present on an IMAP server. For this reason, the service is sometimes referred to as the local mirror of an IMAP server.

By default, it is assumed that the user has a primary mailbox on the server called INBOX, though this can be changed if necessary using CImImap4Settings::SetFolderPathL(const TDesC8 &). (To avoid confusion, the term "Inbox" used in the IMAP MTM documentation refers to this mailbox, rather than the Message Server's standard local Inbox folder.)

The settings store the user's log-in details required to access the IMAP server, and other settings not related to connection, but which affect the behaviour of commands, such as synchronisation, made to the service.

--------------------------------------

Synchronisation

The IMAP4 MTM provides the means to synchronise message headers on a remote IMAP mailboxes with the messages headers on the phone. Note that synchronisation only refers to message headers. Once headers are synchronised, populate operations (i.e. getting the message bodies) can be done.

The basic steps involved in a full synchronisation are:

Queued offline operations (see below) pending on the Inbox or subscribed folders are performed prior to the relevant folder being synchronised.

Synchronisations can be performed in the background or the foreground. A foreground synchronisation means no other requests, such as message fetching, can be made to the MTM, until the synchronisation is complete. A background synchronisation allows some types of command to be given while it is in progress. Commands that write to the remote server are not allowed however while a background synchronisation is in progress. A client is informed of the state of a background synchronisation through the MMsvImapConnectionObserver callback interface.

Synchronisations commands are made through CImap4ClientMtm::InvokeAsyncFunctionL(TInt,const CMsvEntrySelection &,TDes8 &,TRequestStatus &). There a variety of commands available that give different options for compounding synchronisation with other commands, such as connection, and synchronising only particular folders. See TImap4Cmds for details. Progress information for synchronisation commands can be obtained from the CMsvOperation object returned by the CImap4ClientMtm::InvokeAsyncFunctionL(TInt,const CMsvEntrySelection &,TDes8 &,TRequestStatus &). Synchronisation progress information is encapsulated in a TImap4SyncProgress object.

Settings that affect how a synchronisation is performed include:

--------------------------------------

Getting and copying messages

After messages headers have been synchronised, message bodies and attachments can be fetched from the remote email server. Getting message parts and saving them in the mirror service is calling populating them.

Commands for these actions can be made through CImap4ClientMtm::InvokeAsyncFunctionL(TInt,const CMsvEntrySelection &,TDes8 &,TRequestStatus &). There are a large number of commands, for different combinations of these options:

For the populate type commands, further options can be set that control the message getting behaviour. Basic options control, encapsulated in TImImap4GetMailInfo, specify whether body text and/or attachments are fetched, and a maximum message size. There are also options, encapsulated in TImImap4GetPartialMailInfo, that allow size limits to be separately specified for body text and/or attachments. If the the body is larger than the limit, then the body is partially downloaded up to the limit. Only attachments smaller than the specified size are downloaded. A partially downloaded message can later be fully downloaded.

For the copy or move type commands, a TImImap4GetMailInfo parameter is supplied, in order to specify the destination folder for the messages, and a maximum message size.

Progress information for getting commands can be obtained from the CMsvOperation object returned by the CImap4ClientMtm::InvokeAsyncFunctionL(TInt,const CMsvEntrySelection &,TDes8 &,TRequestStatus &). Progress information is encapsulated in a TImap4GenericProgress object.

Fetching and then copying or moving specified messages can also be performed by using the standard Messaging Framework CMsvEntry::CopyL() and CMsvEntry::MoveL() functions on entries under the remote service. If these functions are used, then the entire message is fetched without size limits.

CMsvEntry functions can also be used to:

Note that changing an existing entry through CMsvEntry is not supported. An MTM- specific command KIMAP4MTMRenameFolder is instead provided to rename a remote folder.

The page "CMsvEntry functions for IMAP4 message entries", linked to in the "See also" section below, provides more details on using CMsvEntry.

--------------------------------------

Offline operations

Some operations can only be performed while online, while other commands may be stored while offline for processing when next connected. An attempt to perform a command while offline that requires the MTM to be connected results in immediate completion with the error code KErrDisconnected.

Permitted offline operations include:

Queued offline operations are usually performed when a connection is made, prior to the relevant folder being synchronised. Delete operations can alternatively be set to be done on disconnection using the service setting CImImap4Settings::SetDeleteEmailsWhenDisconnecting(TBool).

Note that:

--------------------------------------

IMAP IDLE support

IMAP IDLE (RFC 2177) is an optional expansion of the IMAP email accessing protocol that allows the server to send updates to the client that messages have been created or deleted in real time. The IDLE command is sent from the client to the server when the client is ready to accept unsolicited mailbox update messages. Whether the client requests the server to provide IDLE support is set in the CImImap4Settings::SetImapIdle(TBool) service setting. When the IMAP MTM receives such a notification, it synchronises the changed folder. Email clients can be notified of such changes by setting a MMsvEntryObserver observer on a folder.

Derivation

Members

Defined in CImap4ClientMtm:

Inherited from CBase:

Inherited from CBaseMtm:

Inherited from MMsvEntryObserver:


Construction and destruction


NewL(CRegisteredMtmDll &,CMsvSession &)

IMPORT_C static CImap4ClientMtm* NewL(CRegisteredMtmDll &aRegisteredMtmDll, CMsvSession &aSession);

Description

IMAP4 client MTM factory function.

This function is not called directly by messaging clients. To create a client MTM object, use CClientMtmRegistry::NewMtmL(TUid).

Parameters

CRegisteredMtmDll &aRegisteredMtmDll

MTM registry information

CMsvSession &aSession

Message server session

Return value

CImap4ClientMtm *

New IMAP4 client MTM object

See also:

[Top]


Member functions


ReplyL(TMsvId,TMsvPartList,TRequestStatus &)

virtual CMsvOperation* ReplyL(TMsvId aDestination, TMsvPartList aPartList, TRequestStatus &aCompletionStatus);

Description

Creates an SMTP reply message to the current message context.

Parameters

TMsvId aDestination

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.


ForwardL(TMsvId,TMsvPartList,TRequestStatus &)

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

Description

Creates an forwarded SMTP message from the current message context.

Parameters

TMsvId aDestination

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.


Find(const TDesC &,TMsvPartList)

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

Description

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

Parameters

const TDesC16 &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.


SaveMessageL()

virtual void SaveMessageL();

Description

Empty implementation of base class function.

To edit an IMAP message, use CImEmailMessage.


LoadMessageL()

virtual void LoadMessageL();

Description

Loads the cache with the message data for the current message context.

The current context should be an IMAP service or a message. If the current context is an IMAP service, then the function loads the service settings from the Central Repository. This is the same behaviour as CImap4ClientMtm::RestoreSettingsL().


StoreSettingsL()

IMPORT_C void StoreSettingsL();

Description

If the current context of the client MTM is an IMAP4 service, stores settings in the Central Repository.

Panic codes

IMCM

33 MTM has no current context (debug builds only)

IMCM

44 Current context is not a service (debug builds only)


RestoreSettingsL()

IMPORT_C void RestoreSettingsL();

Description

If the current context of the client MTM is on an IMAP4 service, restores settings from the Central Repository.

The restored settings can be accessed through the CImap4ClientMtm::Imap4Settings()const function.

Panic codes

IMCM

33 MTM has no current context (debug builds only)


QueryCapability(TUid,TInt &)

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

Description

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

Parameters

TUid aCapability

UID of capability to be queried. See MTMDEF.HRH for definition of UIDs.

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


InvokeSyncFunctionL(TInt,const CMsvEntrySelection &,TDes8 &)

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

Description

Invokes synchronous IMAP-specific operations.

Parameters

TInt aFunctionId

ID of the requested function. Supported IDs are KIMAP4MTMIsConnected and KIMAP4MTMBusy.

const CMsvEntrySelection &aSelection

Collection of function entries to invoke.

TDes8 &aParameter

Buffer containing input and output parameters.

Leave codes

KErrNotSupported

Function does not provide function specified by aFunctionId

Panic codes

IMCM

33 MTM has no current context (debug builds only)

See also:


InvokeAsyncFunctionL(TInt,const CMsvEntrySelection &,TDes8 &,TRequestStatus &)

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

Description

Invokes asynchronous IMAP-specific operations.

This provides support for a large number of IMAP-specific functions, including operations to:

For details of operations, see TImap4Cmds.

Parameters

TInt aFunctionId

Specifies which operation to perform e.g. connect, copy new mail etc. The specific operations are defined by the TImap4Cmds enumeration.

const CMsvEntrySelection &aSelection

A selection of messages. The use is dependant upon the command specified by aFunctionID .

TDes8 &aParameter

Use is dependant upon the command specified by aFunctionID

TRequestStatus &aCompletionStatus

The status when the operation completes.

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

KErrNotFound

The selection of email to be moved or copied is empty

KErrNotSupported

The specified operation is not recognised

Panic codes

IMCM

33 MTM has no current context (debug builds only)

See also:


AddAddresseeL(const TDesC &)

virtual void AddAddresseeL(const TDesC &aRealAddress);

Description

Message address function required by the base class, but not used for IMAP.

To modify message address information, use the address functions in CImHeader.

Parameters

const TDesC16 &aRealAddress

Address.


AddAddresseeL(const TDesC &,const TDesC &)

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

Description

Message address function required by the base class, but not used for IMAP.

To modify message address information, use the address functions in CImHeader.

Parameters

const TDesC16 &aRealAddress

Address.

const TDesC16 &aAlias

Alias information.


RemoveAddressee(TInt)

virtual void RemoveAddressee(TInt aIndex);

Description

Message address function required by the base class, but not used for IMAP.

To modify message address information, use the address functions in CImHeader.

Parameters

TInt aIndex

Index of address to be removed.


AddAttachmentL(const TDesC &,const TDesC8 &,TUint,TRequestStatus &)

IMPORT_C virtual void AddAttachmentL(const TDesC &aFilePath, const TDesC8 &aMimeType, TUint aCharset, TRequestStatus &aStatus);

Description

Unsupported client MTM base class function.

To modify message attachments, use CImEmailMessage.

Parameters

const TDesC16 &aFilePath

Unused

const TDesC8 &aMimeType

Unused

TUint aCharset

Unused

TRequestStatus &aStatus

Unused

Leave codes

KErrNotSupported

Function not supported.


AddAttachmentL(RFile &,const TDesC8 &,TUint,TRequestStatus &)

IMPORT_C virtual void AddAttachmentL(RFile &aFile, const TDesC8 &aMimeType, TUint aCharset, TRequestStatus &aStatus);

Description

Unsupported client MTM base class function.

To modify message attachments, use CImEmailMessage.

Parameters

RFile &aFile

Unused

const TDesC8 &aMimeType

Unused

TUint aCharset

Unused

TRequestStatus &aStatus

Unused

Leave codes

KErrNotSupported

Function not supported.


AddLinkedAttachmentL(const TDesC &,const TDesC8 &,TUint,TRequestStatus &)

IMPORT_C virtual void AddLinkedAttachmentL(const TDesC &aFilePath, const TDesC8 &aMimeType, TUint aCharset, TRequestStatus &aStatus);

Description

Unsupported client MTM base class function.

To modify message attachments, use CImEmailMessage.

Parameters

const TDesC16 &aFilePath

Unused

const TDesC8 &aMimeType

Unused

TUint aCharset

Unused

TRequestStatus &aStatus

Unused

Leave codes

KErrNotSupported

Function not supported.


AddEntryAsAttachmentL(TMsvId,TRequestStatus &)

IMPORT_C virtual void AddEntryAsAttachmentL(TMsvId aAttachmentId, TRequestStatus &aStatus);

Description

Unsupported client MTM base class function.

To modify message attachments, use CImEmailMessage.

Parameters

TMsvId aAttachmentId

Unused

TRequestStatus &aStatus

Unused

Leave codes

KErrNotSupported

Function not supported.


CreateAttachmentL(const TDesC &,RFile &,const TDesC8 &,TUint,TRequestStatus &)

IMPORT_C virtual void CreateAttachmentL(const TDesC &aFileName, RFile &aAttachmentFile, const TDesC8 &aMimeType, TUint aCharset, TRequestStatus &aStatus);

Description

Unsupported client MTM base class function.

To modify message attachments, use CImEmailMessage.

Parameters

const TDesC16 &aFileName

Unused

RFile &aAttachmentFile

Unused

const TDesC8 &aMimeType

Unused

TUint aCharset

Unused

TRequestStatus &aStatus

Unused

Leave codes

KErrNotSupported

Function not supported.


CreateMessageL(TMsvId)

IMPORT_C virtual void CreateMessageL(TMsvId aServiceId);

Description

Unsupported client MTM base class function.

To create a new message, use CImEmailOperation.

Parameters

TMsvId aServiceId

Unused

Leave codes

KErrNotSupported

Function not supported.


DefaultServiceL()const

IMPORT_C virtual TMsvId DefaultServiceL() const;

Description

Unsupported client MTM base class function.

Return value

TMsvId

KErrNotSupported Function not supported.

Leave codes

KErrNotSupported

Function not supported.


RemoveDefaultServiceL()

IMPORT_C virtual void RemoveDefaultServiceL();

Description

Unsupported client MTM base class function.

Leave codes

KErrNotSupported

Function not supported.


ChangeDefaultServiceL(const TMsvId &)

IMPORT_C virtual void ChangeDefaultServiceL(const TMsvId &aService);

Description

Unsupported client MTM base class function.

Parameters

const TMsvId &aService

Unused

Leave codes

KErrNotSupported

Function not supported.


Imap4Settings()const

IMPORT_C const CImImap4Settings& Imap4Settings() const;

Description

Gets the IMAP4 email service settings currently being used by the client MTM, if they exist.

If no settings exist, then an empty settings object will be returned by this function. Settings will only exist if a prior call has been made to the CImap4ClientMtm::RestoreL() function when the client MTM was positioned over an IMAP4 service in the message store.

Return value

const CImImap4Settings &

IMAP4 service settings


SetImap4SettingsL(const CImImap4Settings &)

IMPORT_C void SetImap4SettingsL(const CImImap4Settings &aSettings);

Description

Sets the IMAP4 email service settings.

This can be called at any time to override any current email settings (if they exist). However, new settings are only used by the MTM if they have been stored and then a new IMAP4 email session has been started: i.e. settings cannot be changed in mid-session.

Parameters

const CImImap4Settings &aSettings

New IMAP4 service settings


UndoOffLineChangesL(const CImOffLineOperation &,TMsvId)

virtual void UndoOffLineChangesL(const CImOffLineOperation &aDeleted, TMsvId aFolderId);

Description

This function is not supported.

Parameters

const CImOffLineOperation &aDeleted

Unused

TMsvId aFolderId

Unused


ContextEntrySwitched()

protected: virtual void ContextEntrySwitched();

Description

Called by the base class functions CBaseMtm::SwitchCurrentEntryL(TMsvId) and CBaseMtm::SetCurrentEntryL(CMsvEntry *) 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:

1. address data stored in iAddresseeList

2. any caches of MTM-specific entry data relating to a previous context. For example, if the implementation has a private buffer storing a message subject, for access through Subject(), this buffer should be cleared.