williamr@2: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #if !defined (__SMTPSET_H__) williamr@2: #define __SMTPSET_H__ williamr@2: williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: /** Default SMTP server port number.*/ williamr@2: const TUint32 KSMTPDefaultPortNumber = 25; williamr@2: williamr@2: /** Default/maximum addresses to include in body header of reply/forward messages */ williamr@2: const TInt KSmtpToCcIncludeLimitDefault = 0; williamr@2: const TInt KSmtpToCcIncludeLimitMax = KMaxTInt; williamr@2: williamr@2: williamr@2: /** williamr@2: Defines options that allows the user to automatically email themselves a copy williamr@2: of all emails that are sent from the phone. williamr@2: williamr@2: @see CImSmtpSettings::SendCopyToSelf() williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TImSMTPSendCopyToSelf williamr@2: { williamr@2: /** Do not send a copy. */ williamr@2: ESendNoCopy, williamr@2: /** Send a copy, with the user's address added to the To address list. */ williamr@2: ESendCopyAsToRecipient, williamr@2: /** Send a copy, with the user's address added to the Cc: address list. */ williamr@2: ESendCopyAsCcRecipient, williamr@2: /** Send a copy, with the user's address added to the Bcc: address list. */ williamr@2: ESendCopyAsBccRecipient williamr@2: }; williamr@2: /** williamr@2: Defines sending options for new email messages. williamr@2: williamr@2: The option has no direct effect on the SMTP MTM, although messages in the williamr@2: outbox which are marked as ESendMessageOnNextConnection or ESendMessageImmediately williamr@2: will be appended automatically to the list of messages supplied by the client williamr@2: when either CBaseServerMtm::CopyFromLocal() or CBaseServerMtm::MoveFromLocal() williamr@2: are called. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TImSMTPSendMessageOption williamr@2: { williamr@2: /** Send message immediately. */ williamr@2: ESendMessageImmediately, williamr@2: /** Send message when the next connection occurs. */ williamr@2: ESendMessageOnNextConnection, williamr@2: /** Send message only when the user requests this. */ williamr@2: ESendMessageOnRequest williamr@2: }; williamr@2: williamr@2: /** williamr@2: Defines status values for the SMTP MTM. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TMsgImOutboxSendState williamr@2: { williamr@2: /** Idle. */ williamr@2: EMsgOutboxProgressWaiting, williamr@2: /** Connecting to server. */ williamr@2: EMsgOutboxProgressConnecting, williamr@2: /** Sending messages. */ williamr@2: EMsgOutboxProgressSending, williamr@2: /** Sending complete. */ williamr@2: EMsgOutboxProgressDone williamr@2: }; williamr@2: williamr@2: /** Sending state for SMTP. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TSmtpSessionState williamr@2: { williamr@2: /** Dialling, looking up DNS, or connecting to SMTP server. */ williamr@2: EConnectingToSmtp, williamr@2: /** Waiting for the SMTP server to send welcome message. */ williamr@2: EWaitingForReply, williamr@2: /** Sending HELO/EHLO command to the server. */ williamr@2: EAuthorisingSmtp, williamr@2: /** Sending the STARTTLS command, if a secure connection was requested. */ williamr@2: ESendingStarttls, williamr@2: /** Exchanging certificates with server, if a secure connection was requested. */ williamr@2: ESettingSecurity, williamr@2: /** Sending a message to the server. */ williamr@2: ESendingImail, williamr@2: /** Logging result. */ williamr@2: ELogDataEvent, williamr@2: /** Disconnecting from the SMTP server. */ williamr@2: EClosingSmtp, williamr@2: /** AUTH in progress. */ williamr@2: EAuthInProgress, williamr@2: /** RSET in progress. */ williamr@2: EResetSmtp williamr@2: }; williamr@2: williamr@2: class TImImailFileProgress williamr@2: /** williamr@2: Status information about the SMTP message which is being sent. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** williamr@2: Amount of data from the message already sent to the server in bytes. williamr@2: williamr@2: Note that the SMTP MTM encodes the text and binary data inside an email message williamr@2: while it is sending the data. As a result, iBytesToSend is likely to increase williamr@2: (by as much as one third) while a message is being sent. The size increase williamr@2: represents all additional bytes which have been added to the RFC 822 message williamr@2: to encode the data. williamr@2: */ williamr@2: TInt iBytesSent; williamr@2: /** Amount of data from the message still to be sent to the server in bytes. */ williamr@2: TInt iBytesToSend; williamr@2: /** Sending state. */ williamr@2: TSmtpSessionState iSessionState; williamr@2: }; williamr@2: williamr@2: class TImSmtpProgress williamr@2: /** williamr@2: Progress information for SMTP operations on the Internet Mail MTM. williamr@2: williamr@2: The information is obtained through calling CMsvOperation::Progress() williamr@2: on the operation. It is packaged into an 8-bit descriptor. williamr@2: williamr@2: Messaging clients use the getter functions to get various types williamr@2: of information about an operation's progress. The setter functions williamr@2: are for use by the MTM. williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: williamr@2: public: williamr@2: IMPORT_C TMsgImOutboxSendState Status() const; // Progress: current progress status of mail session williamr@2: IMPORT_C TInt MsgNo() const; // Progress: No. of message currently being sent; zero=1st message williamr@2: IMPORT_C TInt Error() const; // Summary: completion code from end of last session williamr@2: IMPORT_C TInt Sent() const; // Summary: No. messages sent successfully williamr@2: IMPORT_C TInt NotSent() const; // Summary: No. messages I didn't attempt to send williamr@2: IMPORT_C TInt FailedToSend() const; // Summary: No. messages attempted to send but failed williamr@2: IMPORT_C TInt SendTotal() const; // Sent() + NotSent() + FailedToSend() = SendTotal() williamr@2: IMPORT_C void SetError(TInt anError); williamr@2: IMPORT_C void SetStatus(TMsgImOutboxSendState aStatus); williamr@2: IMPORT_C void SetMsgNo(TInt aMsgNo); williamr@2: IMPORT_C void InitialiseTotal(const TInt& aTotal); williamr@2: IMPORT_C void UpdateSent(); williamr@2: IMPORT_C void UpdateFailedToSend(); williamr@2: IMPORT_C void DecrementSendTotal(); williamr@2: IMPORT_C TMsvId ServiceId() const; williamr@2: IMPORT_C void SetServiceId(TMsvId aServiceId); williamr@2: IMPORT_C TInt ConnectionState() const; williamr@2: IMPORT_C TInt ConnectionIAP() const; williamr@2: IMPORT_C void SetConnectionIAP(TInt aConnectionIAP); williamr@2: williamr@2: public: williamr@2: /** Status information about the message that is currently being sent (if williamr@2: sending is in progress). */ williamr@2: TImImailFileProgress iSendFileProgress; williamr@2: williamr@2: private: williamr@2: TMsgImOutboxSendState iStatus; williamr@2: TInt iError; williamr@2: TInt iMsgNo; williamr@2: TInt iSent; williamr@2: TInt iNotSent; williamr@2: TInt iFailedToSend; williamr@2: TInt iSendTotal; williamr@2: TMsvId iServiceId; williamr@2: }; williamr@2: williamr@2: class CImSmtpSettings : public CImBaseEmailSettings williamr@2: /** williamr@2: Run-time configuration settings for an SMTP account. williamr@2: williamr@2: Messaging clients should use an instance of this class to specify williamr@2: and retrieve configuration settings that are used by the SMTP service when williamr@2: executing email operations. williamr@2: williamr@2: Service settings such as the email body encoding, reply address, character set, williamr@2: and whether to attach a signature or vCard can be specified using this class. williamr@2: Storing and restoring from the message store is also supported. williamr@2: williamr@2: To use this class to change a setting: williamr@2: williamr@2: 1) Set the current context to the SMTP service entry using CMsvStore. williamr@2: williamr@2: 2) Create an instance of CImSmtpSettings and put it on the cleanup stack. williamr@2: williamr@2: 3) Retrieve the existing settings by calling CImSmtpSettings::RestoreL(). williamr@2: williamr@2: 4) Specify whether to add a vCard to outbound email by calling CImSmtpSettings::SetAddVCardToEmail(). williamr@2: williamr@2: 5) Save the new settings by calling CImSmtpSettings::StoreL(). williamr@2: williamr@2: 6) Pop and destroy the CImSmtpSettings instance. williamr@2: williamr@2: @see CMsvStore williamr@2: williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: { williamr@2: public: williamr@2: IMPORT_C CImSmtpSettings(); williamr@2: IMPORT_C virtual ~CImSmtpSettings(); williamr@2: IMPORT_C void Reset(); williamr@2: IMPORT_C const TPtrC EmailAlias() const; williamr@2: IMPORT_C void SetEmailAliasL(const TDesC& aEmailAlias); williamr@2: IMPORT_C const TPtrC EmailAddress() const; williamr@2: IMPORT_C void SetEmailAddressL(const TDesC& aEmailAddress); williamr@2: IMPORT_C const TPtrC ReplyToAddress() const; williamr@2: IMPORT_C void SetReplyToAddressL(const TDesC& aReplyToAddress); williamr@2: IMPORT_C const TPtrC ReceiptAddress() const; williamr@2: IMPORT_C void SetReceiptAddressL(const TDesC& aReceiptAddress); williamr@2: IMPORT_C TMsgOutboxBodyEncoding BodyEncoding() const; williamr@2: IMPORT_C void SetBodyEncoding(TMsgOutboxBodyEncoding aBodyEncoding); williamr@2: IMPORT_C const TUid DefaultMsgCharSet() const; williamr@2: IMPORT_C void SetDefaultMsgCharSet(TUid aDefaultMsgCharSet); williamr@2: IMPORT_C TBool AddVCardToEmail() const; williamr@2: IMPORT_C void SetAddVCardToEmail(TBool aFlag); williamr@2: IMPORT_C TBool AddSignatureToEmail() const; williamr@2: IMPORT_C void SetAddSignatureToEmail(TBool aFlag); williamr@2: IMPORT_C TBool RequestReceipts() const; williamr@2: IMPORT_C void SetRequestReceipts(TBool aFlag); williamr@2: IMPORT_C TImSMTPSendCopyToSelf SendCopyToSelf() const; williamr@2: IMPORT_C void SetSendCopyToSelf(TImSMTPSendCopyToSelf aSendCopyToSelf); williamr@2: IMPORT_C TImSMTPSendMessageOption SendMessageOption() const; williamr@2: IMPORT_C void SetSendMessageOption(TImSMTPSendMessageOption aSendMessageOption); williamr@2: IMPORT_C CImSmtpSettings& CopyL(const CImSmtpSettings& aCImSmtpSettings); williamr@2: IMPORT_C TBool operator==(const CImSmtpSettings& aCImSmtpSettings) const; williamr@2: IMPORT_C const TPtrC8 LoginName() const; williamr@2: IMPORT_C void SetLoginNameL(const TDesC8&); williamr@2: IMPORT_C const TPtrC8 Password() const; williamr@2: IMPORT_C void SetPasswordL(const TDesC8&); williamr@2: IMPORT_C TBool SMTPAuth() const; williamr@2: IMPORT_C void SetSMTPAuth(TBool aFlag); williamr@2: IMPORT_C TBool InboxLoginDetails() const; williamr@2: IMPORT_C void SetInboxLoginDetails(TBool aFlag); williamr@2: IMPORT_C TInt ToCcIncludeLimit() const; williamr@2: IMPORT_C void SetToCcIncludeLimitL(TInt aLimit); williamr@2: IMPORT_C void SetTlsSslDomainL(const TDesC8& aDomainName); williamr@2: IMPORT_C TPtrC8 TlsSslDomain() const; williamr@2: williamr@2: private: williamr@2: class TImSmtpSettingsExtension williamr@2: { williamr@2: public: williamr@2: inline TImSmtpSettingsExtension(); williamr@2: public: williamr@2: HBufC* iReceiptAddress; williamr@2: HBufC8* iLoginName; williamr@2: HBufC8* iPassword; williamr@2: HBufC8* iTlsSslDomain; williamr@2: TInt iToCcIncludeLimit; williamr@2: }; williamr@2: williamr@2: inline TImSmtpSettingsExtension* Extension() const; williamr@2: inline void CheckExtensionExistsL(); williamr@2: williamr@2: private: williamr@2: enum TImSMTPEmailSettings williamr@2: { williamr@2: KSmtpSettingsClearFlag = 0x00000000, williamr@2: KSmtpBaseEmailSettingsLastUsedFlag = CImBaseEmailSettings::EBaseEmailSettingsLastUsedFlag, //0x00000002 williamr@2: KSmtpAddVCardToEmailFlag = KSmtpBaseEmailSettingsLastUsedFlag << 1, //0x00000004 williamr@2: KSmtpAddSignatureToEmailFlag = KSmtpAddVCardToEmailFlag << 1, //0x00000008 williamr@2: KSmtpRequestReceipts = KSmtpAddSignatureToEmailFlag << 1, //0x00000010 williamr@2: KSmtpSmtpAuthFlag = KSmtpRequestReceipts << 1, //0x00000020 williamr@2: KSmtpInboxLoginDetails = KSmtpSmtpAuthFlag << 1, //0x00000040 williamr@2: KSmtpEmailSettingsLastUsedFlag = KSmtpInboxLoginDetails //0x00000040 williamr@2: }; williamr@2: williamr@2: HBufC* iEmailAlias; williamr@2: HBufC* iEmailAddress; williamr@2: HBufC* iReplyToAddress; williamr@2: TImSmtpSettingsExtension* iExtension; // renamed iReceiptAddress williamr@2: TMsgOutboxBodyEncoding iBodyEncoding; williamr@2: TUid iDefaultMsgCharSet; williamr@2: TImSMTPSendCopyToSelf iSendCopyToSelf; williamr@2: TImSMTPSendMessageOption iSendMessageOption; williamr@2: }; williamr@2: williamr@2: inline CImSmtpSettings::TImSmtpSettingsExtension* CImSmtpSettings::Extension() const williamr@2: { williamr@2: return iExtension; williamr@2: } williamr@2: williamr@2: inline void CImSmtpSettings::CheckExtensionExistsL() williamr@2: { williamr@2: if (!iExtension) williamr@2: iExtension=new (ELeave) CImSmtpSettings::TImSmtpSettingsExtension; williamr@2: } williamr@2: williamr@2: inline CImSmtpSettings::TImSmtpSettingsExtension::TImSmtpSettingsExtension() : iReceiptAddress(NULL),iLoginName(NULL),iPassword(NULL),iTlsSslDomain(NULL),iToCcIncludeLimit(KSmtpToCcIncludeLimitDefault) williamr@2: { williamr@2: } williamr@2: williamr@2: #endif // #define __SMTPSET_H__