epoc32/include/app/smtpset.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.
williamr@2
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#if !defined (__SMTPSET_H__)
williamr@2
    17
#define __SMTPSET_H__
williamr@2
    18
williamr@2
    19
 
williamr@2
    20
#include <msvuids.h>
williamr@2
    21
#include <miutset.h>
williamr@2
    22
williamr@2
    23
/** Default SMTP server port number.*/
williamr@2
    24
const TUint32 KSMTPDefaultPortNumber = 25;
williamr@2
    25
williamr@2
    26
/** Default/maximum addresses to include in body header of reply/forward messages */
williamr@2
    27
const TInt KSmtpToCcIncludeLimitDefault = 0;
williamr@2
    28
const TInt KSmtpToCcIncludeLimitMax = KMaxTInt;
williamr@2
    29
williamr@2
    30
williamr@2
    31
/**
williamr@2
    32
Defines options that allows the user to automatically email themselves a copy 
williamr@2
    33
of all emails that are sent from the phone.
williamr@2
    34
williamr@2
    35
@see CImSmtpSettings::SendCopyToSelf() 
williamr@2
    36
williamr@2
    37
@publishedAll
williamr@2
    38
@released
williamr@2
    39
*/
williamr@2
    40
enum TImSMTPSendCopyToSelf
williamr@2
    41
	{
williamr@2
    42
	/** Do not send a copy. */
williamr@2
    43
	ESendNoCopy,
williamr@2
    44
	/** Send a copy, with the user's address added to the To address list. */
williamr@2
    45
	ESendCopyAsToRecipient,
williamr@2
    46
	/** Send a copy, with the user's address added to the Cc: address list. */
williamr@2
    47
	ESendCopyAsCcRecipient,
williamr@2
    48
	/** Send a copy, with the user's address added to the Bcc: address list. */
williamr@2
    49
	ESendCopyAsBccRecipient
williamr@2
    50
	};
williamr@2
    51
/**
williamr@2
    52
Defines sending options for new email messages.
williamr@2
    53
williamr@2
    54
The option has no direct effect on the SMTP MTM, although messages in the 
williamr@2
    55
outbox which are marked as ESendMessageOnNextConnection or ESendMessageImmediately 
williamr@2
    56
will be appended automatically to the list of messages supplied by the client 
williamr@2
    57
when either CBaseServerMtm::CopyFromLocal() or CBaseServerMtm::MoveFromLocal() 
williamr@2
    58
are called. 
williamr@2
    59
williamr@2
    60
@publishedAll
williamr@2
    61
@released
williamr@2
    62
*/
williamr@2
    63
enum TImSMTPSendMessageOption
williamr@2
    64
	{
williamr@2
    65
	/** Send message immediately. */
williamr@2
    66
	ESendMessageImmediately,
williamr@2
    67
	/** Send message when the next connection occurs. */
williamr@2
    68
	ESendMessageOnNextConnection,
williamr@2
    69
	/** Send message only when the user requests this. */
williamr@2
    70
	ESendMessageOnRequest
williamr@2
    71
	};
williamr@2
    72
williamr@2
    73
/**
williamr@2
    74
Defines status values for the SMTP MTM. 
williamr@2
    75
williamr@2
    76
@publishedAll
williamr@2
    77
@released
williamr@2
    78
*/
williamr@2
    79
enum TMsgImOutboxSendState
williamr@2
    80
	{
williamr@2
    81
	/** Idle. */
williamr@2
    82
	EMsgOutboxProgressWaiting,
williamr@2
    83
	/** Connecting to server. */
williamr@2
    84
	EMsgOutboxProgressConnecting,
williamr@2
    85
	/** Sending messages. */
williamr@2
    86
	EMsgOutboxProgressSending,
williamr@2
    87
	/** Sending complete. */
williamr@2
    88
	EMsgOutboxProgressDone
williamr@2
    89
	};
williamr@2
    90
williamr@2
    91
/** Sending state for SMTP. 
williamr@2
    92
williamr@2
    93
@publishedAll
williamr@2
    94
@released
williamr@2
    95
*/
williamr@2
    96
enum TSmtpSessionState
williamr@2
    97
	{
williamr@2
    98
	/** Dialling, looking up DNS, or connecting to SMTP server. */
williamr@2
    99
	EConnectingToSmtp,
williamr@2
   100
	/** Waiting for the SMTP server to send welcome message. */
williamr@2
   101
	EWaitingForReply,
williamr@2
   102
	/** Sending HELO/EHLO command to the server. */
williamr@2
   103
	EAuthorisingSmtp,
williamr@2
   104
	/** Sending the STARTTLS command, if a secure connection was requested. */
williamr@2
   105
	ESendingStarttls,
williamr@2
   106
	/** Exchanging certificates with server, if a secure connection was requested. */
williamr@2
   107
	ESettingSecurity,
williamr@2
   108
	/** Sending a message to the server. */
williamr@2
   109
	ESendingImail,
williamr@2
   110
	/** Logging result. */
williamr@2
   111
	ELogDataEvent,
williamr@2
   112
	/** Disconnecting from the SMTP server. */
williamr@2
   113
	EClosingSmtp,
williamr@2
   114
	/** AUTH in progress. */
williamr@2
   115
	EAuthInProgress,
williamr@2
   116
	/** RSET in progress. */
williamr@2
   117
	EResetSmtp
williamr@2
   118
	};
williamr@2
   119
williamr@2
   120
class TImImailFileProgress				
williamr@2
   121
/** 
williamr@2
   122
Status information about the SMTP message which is being sent. 
williamr@2
   123
williamr@2
   124
@publishedAll
williamr@2
   125
@released
williamr@2
   126
*/
williamr@2
   127
	{
williamr@2
   128
public:
williamr@2
   129
	/**
williamr@2
   130
	Amount of data from the message already sent to the server in bytes.
williamr@2
   131
	
williamr@2
   132
	Note that the SMTP MTM encodes the text and binary data inside an email message 
williamr@2
   133
	while it is sending the data. As a result, iBytesToSend is likely to increase 
williamr@2
   134
	(by as much as one third) while a message is being sent. The size increase 
williamr@2
   135
	represents all additional bytes which have been added to the RFC 822 message 
williamr@2
   136
	to encode the data.
williamr@2
   137
	*/
williamr@2
   138
	TInt				iBytesSent;
williamr@2
   139
	/** Amount of data from the message still to be sent to the server in bytes. */
williamr@2
   140
	TInt				iBytesToSend;
williamr@2
   141
	/** Sending state. */
williamr@2
   142
	TSmtpSessionState	iSessionState;
williamr@2
   143
	};
williamr@2
   144
williamr@2
   145
class TImSmtpProgress
williamr@2
   146
/**
williamr@2
   147
Progress information for SMTP operations on the Internet Mail MTM.
williamr@2
   148
williamr@2
   149
The information is obtained through calling CMsvOperation::Progress() 
williamr@2
   150
on the operation. It is packaged into an 8-bit descriptor. 
williamr@2
   151
williamr@2
   152
Messaging clients use the getter functions to get various types
williamr@2
   153
of information about an operation's progress. The setter functions
williamr@2
   154
are for use by the MTM.
williamr@2
   155
williamr@2
   156
@publishedAll
williamr@2
   157
@released
williamr@2
   158
*/
williamr@2
   159
	{
williamr@2
   160
williamr@2
   161
public:
williamr@2
   162
	IMPORT_C TMsgImOutboxSendState	Status() const; // Progress: current progress status of mail session
williamr@2
   163
	IMPORT_C TInt MsgNo() const;		            // Progress: No. of message currently being sent; zero=1st message
williamr@2
   164
	IMPORT_C TInt Error() const;			        // Summary: completion code from end of last session
williamr@2
   165
	IMPORT_C TInt Sent() const;			            // Summary: No. messages sent successfully
williamr@2
   166
	IMPORT_C TInt NotSent() const;		            // Summary: No. messages I didn't attempt to send
williamr@2
   167
	IMPORT_C TInt FailedToSend() const;	            // Summary: No. messages attempted to send but failed
williamr@2
   168
	IMPORT_C TInt SendTotal() const;		        // Sent() + NotSent() + FailedToSend() = SendTotal()
williamr@2
   169
	IMPORT_C void SetError(TInt anError);
williamr@2
   170
	IMPORT_C void SetStatus(TMsgImOutboxSendState aStatus);
williamr@2
   171
	IMPORT_C void SetMsgNo(TInt aMsgNo);
williamr@2
   172
	IMPORT_C void InitialiseTotal(const TInt& aTotal);
williamr@2
   173
	IMPORT_C void UpdateSent();
williamr@2
   174
	IMPORT_C void UpdateFailedToSend();
williamr@2
   175
	IMPORT_C void DecrementSendTotal();
williamr@2
   176
	IMPORT_C TMsvId	ServiceId() const;
williamr@2
   177
	IMPORT_C void SetServiceId(TMsvId aServiceId);
williamr@2
   178
	IMPORT_C TInt ConnectionState() const;
williamr@2
   179
	IMPORT_C TInt ConnectionIAP() const;
williamr@2
   180
	IMPORT_C void SetConnectionIAP(TInt aConnectionIAP);
williamr@2
   181
williamr@2
   182
public:
williamr@2
   183
	/** Status information about the message that is currently being sent (if 
williamr@2
   184
	sending is in progress). */
williamr@2
   185
	TImImailFileProgress			iSendFileProgress;
williamr@2
   186
williamr@2
   187
private:
williamr@2
   188
	TMsgImOutboxSendState	iStatus;
williamr@2
   189
	TInt					iError;
williamr@2
   190
	TInt					iMsgNo;
williamr@2
   191
	TInt					iSent;
williamr@2
   192
	TInt					iNotSent;
williamr@2
   193
	TInt					iFailedToSend;
williamr@2
   194
	TInt					iSendTotal;
williamr@2
   195
	TMsvId					iServiceId;
williamr@2
   196
	};
williamr@2
   197
williamr@2
   198
class CImSmtpSettings : public CImBaseEmailSettings
williamr@2
   199
/**
williamr@2
   200
Run-time configuration settings for an SMTP account.
williamr@2
   201
williamr@2
   202
Messaging clients should use an instance of this class to specify
williamr@2
   203
and retrieve configuration settings that are used by the SMTP service when
williamr@2
   204
executing email operations.  
williamr@2
   205
williamr@2
   206
Service settings such as the email body encoding, reply address, character set,
williamr@2
   207
and whether to attach a signature or vCard can be specified using this class.
williamr@2
   208
Storing and restoring from the message store is also supported.
williamr@2
   209
williamr@2
   210
To use this class to change a setting:
williamr@2
   211
williamr@2
   212
1) Set the current context to the SMTP service entry using CMsvStore.
williamr@2
   213
williamr@2
   214
2) Create an instance of CImSmtpSettings and put it on the cleanup stack.
williamr@2
   215
williamr@2
   216
3) Retrieve the existing settings by calling CImSmtpSettings::RestoreL().
williamr@2
   217
williamr@2
   218
4) Specify whether to add a vCard to outbound email by calling CImSmtpSettings::SetAddVCardToEmail().
williamr@2
   219
williamr@2
   220
5) Save the new settings by calling CImSmtpSettings::StoreL().
williamr@2
   221
williamr@2
   222
6) Pop and destroy the CImSmtpSettings instance.
williamr@2
   223
williamr@2
   224
@see CMsvStore
williamr@2
   225
williamr@2
   226
@publishedAll
williamr@2
   227
@released
williamr@2
   228
*/
williamr@2
   229
	{
williamr@2
   230
public:
williamr@2
   231
	IMPORT_C CImSmtpSettings();
williamr@2
   232
	IMPORT_C virtual ~CImSmtpSettings();
williamr@2
   233
	IMPORT_C void Reset();
williamr@2
   234
	IMPORT_C const TPtrC EmailAlias() const;
williamr@2
   235
	IMPORT_C void SetEmailAliasL(const TDesC& aEmailAlias);
williamr@2
   236
	IMPORT_C const TPtrC EmailAddress() const;
williamr@2
   237
	IMPORT_C void SetEmailAddressL(const TDesC& aEmailAddress);
williamr@2
   238
	IMPORT_C const TPtrC ReplyToAddress() const;
williamr@2
   239
	IMPORT_C void SetReplyToAddressL(const TDesC& aReplyToAddress);
williamr@2
   240
	IMPORT_C const TPtrC ReceiptAddress() const;
williamr@2
   241
	IMPORT_C void SetReceiptAddressL(const TDesC& aReceiptAddress);
williamr@2
   242
	IMPORT_C TMsgOutboxBodyEncoding BodyEncoding() const;
williamr@2
   243
	IMPORT_C void SetBodyEncoding(TMsgOutboxBodyEncoding aBodyEncoding);
williamr@2
   244
	IMPORT_C const TUid DefaultMsgCharSet() const;
williamr@2
   245
	IMPORT_C void SetDefaultMsgCharSet(TUid aDefaultMsgCharSet);
williamr@2
   246
	IMPORT_C TBool AddVCardToEmail() const;
williamr@2
   247
	IMPORT_C void SetAddVCardToEmail(TBool aFlag);
williamr@2
   248
	IMPORT_C TBool AddSignatureToEmail() const;
williamr@2
   249
	IMPORT_C void SetAddSignatureToEmail(TBool aFlag);
williamr@2
   250
	IMPORT_C TBool RequestReceipts() const;
williamr@2
   251
	IMPORT_C void SetRequestReceipts(TBool aFlag);
williamr@2
   252
	IMPORT_C TImSMTPSendCopyToSelf SendCopyToSelf() const;
williamr@2
   253
	IMPORT_C void SetSendCopyToSelf(TImSMTPSendCopyToSelf aSendCopyToSelf);
williamr@2
   254
	IMPORT_C TImSMTPSendMessageOption SendMessageOption() const;
williamr@2
   255
	IMPORT_C void SetSendMessageOption(TImSMTPSendMessageOption aSendMessageOption);
williamr@2
   256
	IMPORT_C CImSmtpSettings& CopyL(const CImSmtpSettings& aCImSmtpSettings);
williamr@2
   257
	IMPORT_C TBool operator==(const CImSmtpSettings& aCImSmtpSettings) const;
williamr@2
   258
	IMPORT_C const TPtrC8 LoginName() const;
williamr@2
   259
	IMPORT_C void SetLoginNameL(const TDesC8&);
williamr@2
   260
	IMPORT_C const TPtrC8 Password() const;
williamr@2
   261
	IMPORT_C void SetPasswordL(const TDesC8&);
williamr@2
   262
	IMPORT_C TBool SMTPAuth() const;
williamr@2
   263
	IMPORT_C void SetSMTPAuth(TBool aFlag);
williamr@2
   264
	IMPORT_C TBool InboxLoginDetails() const;
williamr@2
   265
	IMPORT_C void SetInboxLoginDetails(TBool aFlag);
williamr@2
   266
	IMPORT_C TInt ToCcIncludeLimit() const;
williamr@2
   267
	IMPORT_C void SetToCcIncludeLimitL(TInt aLimit);
williamr@2
   268
	IMPORT_C void SetTlsSslDomainL(const TDesC8& aDomainName);
williamr@2
   269
	IMPORT_C TPtrC8 TlsSslDomain() const;
williamr@2
   270
williamr@2
   271
private:
williamr@2
   272
	class TImSmtpSettingsExtension
williamr@2
   273
		{
williamr@2
   274
	public:
williamr@2
   275
		inline TImSmtpSettingsExtension();
williamr@2
   276
	public:
williamr@2
   277
		HBufC*	iReceiptAddress;
williamr@2
   278
		HBufC8* iLoginName;
williamr@2
   279
		HBufC8* iPassword;
williamr@2
   280
		HBufC8*	iTlsSslDomain;
williamr@2
   281
		TInt	iToCcIncludeLimit;
williamr@2
   282
		};
williamr@2
   283
williamr@2
   284
	inline TImSmtpSettingsExtension* Extension() const;
williamr@2
   285
	inline void CheckExtensionExistsL();
williamr@2
   286
williamr@2
   287
private:
williamr@2
   288
	enum TImSMTPEmailSettings
williamr@2
   289
		{
williamr@2
   290
		KSmtpSettingsClearFlag				= 0x00000000,
williamr@2
   291
		KSmtpBaseEmailSettingsLastUsedFlag	= CImBaseEmailSettings::EBaseEmailSettingsLastUsedFlag,	//0x00000002
williamr@2
   292
		KSmtpAddVCardToEmailFlag			= KSmtpBaseEmailSettingsLastUsedFlag << 1,	//0x00000004
williamr@2
   293
		KSmtpAddSignatureToEmailFlag		= KSmtpAddVCardToEmailFlag << 1,			//0x00000008
williamr@2
   294
		KSmtpRequestReceipts				= KSmtpAddSignatureToEmailFlag << 1,		//0x00000010
williamr@2
   295
		KSmtpSmtpAuthFlag					= KSmtpRequestReceipts << 1,				//0x00000020
williamr@2
   296
		KSmtpInboxLoginDetails				= KSmtpSmtpAuthFlag << 1,					//0x00000040
williamr@2
   297
		KSmtpEmailSettingsLastUsedFlag		= KSmtpInboxLoginDetails					//0x00000040
williamr@2
   298
		};
williamr@2
   299
williamr@2
   300
	HBufC*						iEmailAlias;
williamr@2
   301
	HBufC*						iEmailAddress;
williamr@2
   302
	HBufC*						iReplyToAddress;
williamr@2
   303
	TImSmtpSettingsExtension*	iExtension; // renamed iReceiptAddress
williamr@2
   304
	TMsgOutboxBodyEncoding		iBodyEncoding;
williamr@2
   305
	TUid						iDefaultMsgCharSet;
williamr@2
   306
	TImSMTPSendCopyToSelf		iSendCopyToSelf;
williamr@2
   307
	TImSMTPSendMessageOption	iSendMessageOption;
williamr@2
   308
	};
williamr@2
   309
	
williamr@2
   310
inline CImSmtpSettings::TImSmtpSettingsExtension* CImSmtpSettings::Extension() const
williamr@2
   311
	{
williamr@2
   312
	return iExtension;
williamr@2
   313
	}
williamr@2
   314
williamr@2
   315
inline void CImSmtpSettings::CheckExtensionExistsL()
williamr@2
   316
	{
williamr@2
   317
	if (!iExtension)
williamr@2
   318
		iExtension=new (ELeave) CImSmtpSettings::TImSmtpSettingsExtension;
williamr@2
   319
	}
williamr@2
   320
williamr@2
   321
inline CImSmtpSettings::TImSmtpSettingsExtension::TImSmtpSettingsExtension() : iReceiptAddress(NULL),iLoginName(NULL),iPassword(NULL),iTlsSslDomain(NULL),iToCcIncludeLimit(KSmtpToCcIncludeLimitDefault)
williamr@2
   322
	{
williamr@2
   323
	}
williamr@2
   324
williamr@2
   325
#endif    // #define __SMTPSET_H__