1 // Copyright (c) 1998-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
15 // Client MTM for the SMTP protocol
19 #if !defined (__SMTCMTM_H__)
22 #if !defined (__E32BASE_H__)
23 #include <e32base.h> // CActive, TFileName)
26 #if !defined(__BADESCA_H__)
30 #if !defined (__MSVAPI_H__)
34 #if !defined (__MTCLBASE_H__)
38 #if !defined (__MIUTHDR_H__)
42 #if !defined (__MIUTPARS_H__)
43 #include <miutpars.h> //TImMessageField
46 #if !defined (__MIUTMSG_H__)
47 #include <miutmsg.h> //CImEmailMessage
50 #if !defined (__SMTPSET_H__)
54 #if !defined (__SMTPCMDS_H__)
59 class CMtmDllRegistry;
62 class CRegisteredMtmDll;
63 class CImSmtpSettings;
65 class CImAttachmentWaiter;
67 /////// Smtp Client MTM /////////////////////////////////////////////////////////////////////////////
68 class CSmtpClientMtm : public CBaseMtm
69 /** SMTP client MTM interface.
71 Most of the functions in this class are implementations of the virtual functions
72 defined by the base class CBaseMtm.
78 IMPORT_C static CSmtpClientMtm* NewL(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
84 IMPORT_C void StoreSettingsL();
85 IMPORT_C void RestoreSettingsL();
87 CMsvOperation* ReplyL (TMsvId aReplyEntryId, TMsvPartList aPartlist, TRequestStatus& aCompletionStatus);
88 CMsvOperation* ForwardL(TMsvId aForwardEntryId, TMsvPartList aPartList, TRequestStatus& aCompletionStatus);
90 TMsvPartList ValidateMessage(TMsvPartList aPartList);
91 TMsvPartList Find(const TDesC& aTextToFind, TMsvPartList aPartList);
93 // addresssee list (used by objects with no MTM knowledge)
94 void AddAddresseeL(const TDesC& aRealAddress);
95 void AddAddresseeL(const TDesC& aRealAddress, const TDesC& aAlias);
96 void AddAddresseeL(TMsvRecipientType aType, const TDesC& aRealAddress);
97 void AddAddresseeL(TMsvRecipientType aType, const TDesC& aRealAddress, const TDesC& aAlias);
98 void RemoveAddressee(TInt aIndex);
100 IMPORT_C void SetSettingsL(const CImSmtpSettings& aSettings);
101 IMPORT_C const CImSmtpSettings& Settings() const;
102 IMPORT_C void SetSubjectL(const TDesC& aSubject);
103 IMPORT_C const TPtrC SubjectL() const;
105 // --- RTTI functions ---
106 TInt QueryCapability(TUid aCapability, TInt& aResponse);
107 void InvokeSyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter);
108 CMsvOperation* InvokeAsyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter, TRequestStatus& aCompletionStatus);
110 // Attachment functions to support the SendAs API
111 IMPORT_C virtual void AddAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus);
112 IMPORT_C virtual void AddAttachmentL(RFile& aFile, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus);
113 IMPORT_C virtual void AddLinkedAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus);
114 IMPORT_C virtual void AddEntryAsAttachmentL(TMsvId aAttachmentId, TRequestStatus& aStatus);
115 IMPORT_C virtual void CreateAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus);
116 IMPORT_C virtual void CreateMessageL(TMsvId aServiceId);
118 IMPORT_C virtual TMsvId DefaultServiceL() const;
119 IMPORT_C virtual void RemoveDefaultServiceL();
120 IMPORT_C virtual void ChangeDefaultServiceL(const TMsvId& aService);
121 IMPORT_C void CancelAttachmentOperation();
124 CSmtpClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession);
127 void ContextEntrySwitched(); // called after the context of this instance has been changed to another entry
129 TBool ValidateAddress(const TPtrC& anAddress);
132 void RestoreEmailMessageL();
133 void StoreEmailMessageL();
134 void SetAddresseeListL();
135 void GetBodyTextL(CImEmailMessage& aMessage, TMsvId aMsvId);
136 TInt32 GetAttachmentSizeL(CImEmailMessage& aMessage, TMsvId aMsvId);
137 TMsvPartList DoFindL(const TDesC& aTextToFind, TMsvPartList aPartList);
140 CMsvOperationActiveSchedulerWait* iWait;
141 CImSmtpSettings* iImSmtpSettings;
145 TImMessageField iTImMessageField;
146 HBufC* iEmailAddressFormatString; // defines format of email address used by "Send as" API eg _LIT("/"%S/" <%S>")
147 CMsvEntrySelection* iEntrySelection;
148 CImEmailOperation* iImEmailOperation;
149 CImAttachmentWaiter* iAttachmentWaiter;
150 CImEmailMessage* iEmailMessage;
154 #endif // __SMTCMTM_H__