epoc32/include/app/popcmtm.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Client MTM for the POP3 protocol
    15 // 
    16 //
    17 
    18 
    19 #if !defined (__POPCMTM_H__)
    20 #define __POPCMTM_H__
    21 
    22 #if !defined (__MIUTMSG_H__)
    23 #include <miutmsg.h>
    24 #endif
    25 #if !defined (__MIUTPARS_H__)
    26 #include <miutpars.h>		//TImMessageField
    27 #endif
    28 #if !defined (__POP3CMDS_H__)
    29 #include <pop3cmds.h>		// KPOP3MTMConnect etc
    30 #endif
    31 #if !defined (__POP3SET_H__)
    32 #include <pop3set.h>		// KPOP3MTMConnect etc
    33 #endif
    34 
    35 class CImPOP3GetMail;
    36 class CImEmailAutoSend;
    37  
    38 //  Pop3 Client MTM  //
    39 class CPop3ClientMtm : public CBaseMtm
    40 /** POP3 client MTM interface.
    41 
    42 Most of the functions in this class are implementations of the virtual functions 
    43 defined by the base class CBaseMtm. 
    44 @publishedAll
    45 @released
    46 */
    47 	{
    48 /** 
    49 @deprecated
    50 */
    51 
    52 public:
    53 	enum TImPopcNewEmailHeaderType
    54 		{
    55 		EForwardedEmail,
    56 		EReplyToEmail,
    57 		EReceiptToEmail
    58 		};
    59 
    60 public:
    61 	IMPORT_C static CPop3ClientMtm* NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
    62 	~CPop3ClientMtm();
    63 
    64 	void SaveMessageL();
    65 	void LoadMessageL();
    66 
    67 	IMPORT_C void StoreSettingsL();
    68 	IMPORT_C void RestoreSettingsL();
    69 
    70 	CMsvOperation* ReplyL  (TMsvId aId, TMsvPartList aPartlist, TRequestStatus& aCompletionStatus);
    71 	CMsvOperation* ForwardL(TMsvId aId, TMsvPartList aPartList, TRequestStatus& aCompletionStatus);
    72 
    73 	TUint ValidateMessage(TMsvPartList aPartList);
    74 	TMsvPartList Find(const TDesC& aTextToFind, TMsvPartList aPartList);
    75 
    76 	void AddAddresseeL(const TDesC& aRealAddress);
    77 	void AddAddresseeL(const TDesC& aRealAddress, const TDesC& aAlias);
    78 	void RemoveAddressee(TInt aIndex);
    79 
    80 	IMPORT_C void SetSettingsL(const CImPop3Settings& aSettings);
    81 	IMPORT_C const CImPop3Settings& Settings() const; 
    82 
    83 	// --- RTTI functions ---
    84 	TInt QueryCapability(TUid aCapability, TInt& aResponse);
    85 	void InvokeSyncFunctionL(TInt aFunctionId, const CMsvEntrySelection& aSelection, TDes8& aParameter);
    86 	CMsvOperation* InvokeAsyncFunctionL(TInt aFunctionId, const CMsvEntrySelection& aSelection, TDes8& aParameter, TRequestStatus& aCompletionStatus);
    87 
    88 	// Attachment functions to support the SendAs API
    89 	IMPORT_C virtual void AddAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus);
    90 	IMPORT_C virtual void AddAttachmentL(RFile& aFile, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus);
    91 	IMPORT_C virtual void AddLinkedAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus);
    92 	IMPORT_C virtual void AddEntryAsAttachmentL(TMsvId aAttachmentId, TRequestStatus& aStatus);	
    93 	EXPORT_C virtual void CreateAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus);
    94 	IMPORT_C virtual void CreateMessageL(TMsvId aServiceId);
    95 
    96 	IMPORT_C virtual TMsvId DefaultServiceL() const;
    97 	IMPORT_C virtual void RemoveDefaultServiceL();
    98 	IMPORT_C virtual void ChangeDefaultServiceL(const TMsvId& aService);
    99 
   100 protected:
   101 	CPop3ClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
   102 	void ConstructL();
   103 	void ContextEntrySwitched();
   104 
   105 private:
   106 	TBool ValidateAddress(const TPtrC& anAddress);
   107 	void SendOnNextConnectionL();
   108 	TMsvPartList DoFindL(const TDesC& aTextToFind, TMsvPartList aPartList);
   109 	CMsvEntrySelection* FilteredChildrenLC(TBool aNewOnly, TInt aMaxEmailSize);
   110 	CMsvEntrySelection* FilteredSelectionLC(TInt aMaxEmailSize, const CMsvEntrySelection& aSelection);
   111 		
   112 
   113 
   114 private:
   115 	CImPop3Settings* iImPop3Settings;
   116 	TImMessageField iTImMessageField;
   117 	CImHeader* iHeader;
   118 
   119 	HBufC* iEmailAddressFormatString;	// defines format of email address used by "Send as" API eg _LIT("/"%S/" <%S>")
   120 	CImEmailOperation* iImEmailOperation;
   121 	CImPOP3GetMail* iImPOP3GetMail;
   122 	};
   123 
   124 
   125 class CImPOP3GetMail : public CMsvOperation
   126 /** Encapsulates an operation to copy/move POP3 emails from the remote inbox to 
   127 any local folder.
   128 
   129 Functionality is provided to:
   130 
   131 1. copy/move any new emails
   132 
   133 2. copy/move a selection of emails
   134 
   135 3. copy/move all emails
   136 
   137 4. in the Remote Inbox to a local folder.
   138 
   139 There are three cases for copying/moving the emails from the Remote Inbox:
   140 
   141 1. the user is connected to the account so just copy/move the emails
   142 
   143 2. the user is not connected to the account so connect, copy/move the emails, 
   144 and then disconnect
   145 
   146 3. the user is not connected to the account so connect, copy/move the emails, 
   147 and then stay online
   148 
   149 Objects of this type are returned from CPop3ClientMtm::InvokeAsyncFunctionL() 
   150 when a suitable get command is requested. 
   151 @publishedAll
   152 @released
   153 */
   154 	{
   155 public:
   156 	/** Defines types of get mail operation. */
   157 	enum TImPOP3GetMailType
   158 	{
   159 	/** Connect and copy new mail and stay online. */
   160 		EConnectAndCopyNewMailAndStayOnline,
   161 	/** Connect and copy new mail and disconnect. */
   162 		EConnectAndCopyNewMailAndDisconnect,
   163 	/** Connect and move new mail and stay online. */
   164 		EConnectAndMoveNewMailAndStayOnline,
   165 	/** Connect and move new mail and disconnect. */
   166 		EConnectAndMoveNewMailAndDisconnect,
   167 	/** Connect and copy mail selection and stay online. */
   168 		EConnectAndCopyMailSelectionAndStayOnline,
   169 	/** Connect and copy mail selection and disconnect. */
   170 		EConnectAndCopyMailSelectionAndDisconnect,
   171 	/** Connect and move mail selection and stay online. */
   172 		EConnectAndMoveMailSelectionAndStayOnline,
   173 	/** Connect and move mail selection and disconnect. */
   174 		EConnectAndMoveMailSelectionAndDisconnect,
   175 	/** Connect and copy all mail and stay online. */
   176 		EConnectAndCopyAllMailAndStayOnline,
   177 	/** Connect and copy all mail and disconnect. */
   178 		EConnectAndCopyAllMailAndDisconnect,
   179 	/** Connect and move all mail and stay online. */
   180 		EConnectAndMoveAllMailAndStayOnline,
   181 	/** Connect and move all mail and disconnect. */
   182 		EConnectAndMoveAllMailAndDisconnect
   183 	};
   184 
   185 public:
   186 	IMPORT_C CMsvOperation* GetMailL(CPop3ClientMtm& aPop3ClientMtm, TRequestStatus& aObserverRequestStatus, const CMsvEntrySelection& aMsvEntrySelection, TDes8& aPop3GetMailInfo, TImPOP3GetMailType aPOP3GetMailType);
   187 	IMPORT_C const TDesC8& FinalProgress();
   188 	IMPORT_C ~CImPOP3GetMail();
   189 	void DoCancel();
   190 	void RunL();
   191 	const TDesC8& ProgressL();
   192 private:
   193 	CImPOP3GetMail(CMsvSession& aMsvSession, TRequestStatus& aObserverRequestStatus, CPop3ClientMtm& aPop3ClientMtm, TImPOP3GetMailType aPOP3GetMailType);
   194 	void ConstructL(const CMsvEntrySelection& aMsvEntrySelection, TDes8& aPop3GetMailInfo);
   195 	void SelectNextStateL();					// selects next state to go to
   196 	void ChangeStateL();					// initiates the next state operation
   197 	void SelectAndChangeToNextStateL();
   198 	void RequestComplete(TInt aError);
   199 	void Complete();
   200 	void ConnectToMailboxL();
   201 	void CopyMoveNewMessagesL(TBool aCopy);
   202 	void CopyMoveMessageSelectionL(TBool aCopy);
   203 	void CopyMoveAllMessagesL(TBool aCopy);
   204 	void DisconnectFromMailboxL();
   205 	void ResetProgress();
   206 	void StoreProgressL();
   207 private:
   208 	enum TImPOP3GetMailState
   209 		{
   210 		EConnectToMailbox,
   211 		ECopyNewMessages,
   212 		EMoveNewMessages,
   213 		ECopyMessageSelection,
   214 		EMoveMessageSelection,
   215 		ECopyAllMessages,
   216 		EMoveAllMessages,
   217 		EDisconnectFromMailbox,
   218 		EFinished
   219 		};
   220 	
   221 	CPop3ClientMtm& iPop3ClientMtm;
   222 	CMsvEntrySelection* iMsvEntrySelection;
   223 	CMsvOperation* iMsvOperation;
   224 
   225 	TPop3Progress iProgress;
   226 	TPop3Progress iErrorProgress;
   227 	TImPOP3GetMailState iState;
   228 	TImPOP3GetMailType iPOP3GetMailType;
   229 	TPckgBuf<TPop3Progress> iProgressBuf;
   230 	TPckgBuf<TImPop3GetMailInfo> iPop3GetMailInfo;
   231 	};
   232 
   233 #endif // __POPCMTM_H__