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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Client MTM for the POP3 protocol
19 #if !defined (__POPCMTM_H__)
22 #if !defined (__MIUTMSG_H__)
25 #if !defined (__MIUTPARS_H__)
26 #include <miutpars.h> //TImMessageField
28 #if !defined (__POP3CMDS_H__)
29 #include <pop3cmds.h> // KPOP3MTMConnect etc
31 #if !defined (__POP3SET_H__)
32 #include <pop3set.h> // KPOP3MTMConnect etc
36 class CImEmailAutoSend;
39 class CPop3ClientMtm : public CBaseMtm
40 /** POP3 client MTM interface.
42 Most of the functions in this class are implementations of the virtual functions
43 defined by the base class CBaseMtm.
53 enum TImPopcNewEmailHeaderType
61 IMPORT_C static CPop3ClientMtm* NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
67 IMPORT_C void StoreSettingsL();
68 IMPORT_C void RestoreSettingsL();
70 CMsvOperation* ReplyL (TMsvId aId, TMsvPartList aPartlist, TRequestStatus& aCompletionStatus);
71 CMsvOperation* ForwardL(TMsvId aId, TMsvPartList aPartList, TRequestStatus& aCompletionStatus);
73 TUint ValidateMessage(TMsvPartList aPartList);
74 TMsvPartList Find(const TDesC& aTextToFind, TMsvPartList aPartList);
76 void AddAddresseeL(const TDesC& aRealAddress);
77 void AddAddresseeL(const TDesC& aRealAddress, const TDesC& aAlias);
78 void RemoveAddressee(TInt aIndex);
80 IMPORT_C void SetSettingsL(const CImPop3Settings& aSettings);
81 IMPORT_C const CImPop3Settings& Settings() const;
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);
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);
96 IMPORT_C virtual TMsvId DefaultServiceL() const;
97 IMPORT_C virtual void RemoveDefaultServiceL();
98 IMPORT_C virtual void ChangeDefaultServiceL(const TMsvId& aService);
101 CPop3ClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
103 void ContextEntrySwitched();
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);
115 CImPop3Settings* iImPop3Settings;
116 TImMessageField iTImMessageField;
119 HBufC* iEmailAddressFormatString; // defines format of email address used by "Send as" API eg _LIT("/"%S/" <%S>")
120 CImEmailOperation* iImEmailOperation;
121 CImPOP3GetMail* iImPOP3GetMail;
125 class CImPOP3GetMail : public CMsvOperation
126 /** Encapsulates an operation to copy/move POP3 emails from the remote inbox to
129 Functionality is provided to:
131 1. copy/move any new emails
133 2. copy/move a selection of emails
135 3. copy/move all emails
137 4. in the Remote Inbox to a local folder.
139 There are three cases for copying/moving the emails from the Remote Inbox:
141 1. the user is connected to the account so just copy/move the emails
143 2. the user is not connected to the account so connect, copy/move the emails,
146 3. the user is not connected to the account so connect, copy/move the emails,
149 Objects of this type are returned from CPop3ClientMtm::InvokeAsyncFunctionL()
150 when a suitable get command is requested.
156 /** Defines types of get mail operation. */
157 enum TImPOP3GetMailType
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
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();
191 const TDesC8& ProgressL();
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);
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();
208 enum TImPOP3GetMailState
213 ECopyMessageSelection,
214 EMoveMessageSelection,
217 EDisconnectFromMailbox,
221 CPop3ClientMtm& iPop3ClientMtm;
222 CMsvEntrySelection* iMsvEntrySelection;
223 CMsvOperation* iMsvOperation;
225 TPop3Progress iProgress;
226 TPop3Progress iErrorProgress;
227 TImPOP3GetMailState iState;
228 TImPOP3GetMailType iPOP3GetMailType;
229 TPckgBuf<TPop3Progress> iProgressBuf;
230 TPckgBuf<TImPop3GetMailInfo> iPop3GetMailInfo;
233 #endif // __POPCMTM_H__