email/pop3andsmtpmtm/clientmtms/src/SMTPSET.CPP
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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 "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 //
       
    15 
       
    16 #include "SMTPSET.H" 
       
    17 #include <nifvar.h>				// For KLinkLayerOpen
       
    18 
       
    19 
       
    20 GLREF_C TPtrC8 LimitStringSize(const TPtrC8& aString, TInt aMaxSize);
       
    21 GLREF_C TPtrC16 LimitStringSize(const TPtrC16& aString, TInt aMaxSize);
       
    22 
       
    23 
       
    24 EXPORT_C CImSmtpSettings::CImSmtpSettings()
       
    25 /** 
       
    26 Allocates and creates a new CImImap4Settings object initialised to
       
    27 default values.
       
    28 */
       
    29 	{
       
    30 	Reset();
       
    31 	} 
       
    32 
       
    33 
       
    34 EXPORT_C CImSmtpSettings::~CImSmtpSettings()
       
    35 /**
       
    36 Destructor.
       
    37 */
       
    38 	{
       
    39 	Reset();
       
    40 
       
    41 	delete iExtension;
       
    42 	iExtension=NULL;
       
    43 	}
       
    44 
       
    45 
       
    46 EXPORT_C void CImSmtpSettings::Reset()
       
    47 /**
       
    48 Resets the settings to their default values.
       
    49 */
       
    50 	{
       
    51 	CImBaseEmailSettings::Reset();
       
    52 	
       
    53 	iPortNumber = KSMTPDefaultPortNumber;
       
    54 	iBodyEncoding = EMsgOutboxMIME;
       
    55 
       
    56 	delete iEmailAlias;
       
    57 	iEmailAlias = NULL;
       
    58 
       
    59 	delete iEmailAddress;
       
    60 	iEmailAddress = NULL;
       
    61 
       
    62 	delete iReplyToAddress;
       
    63 	iReplyToAddress=NULL;
       
    64 	
       
    65 	if (Extension())
       
    66 		{
       
    67 		delete Extension()->iReceiptAddress;
       
    68 		Extension()->iReceiptAddress=NULL;
       
    69 		
       
    70 		delete Extension()->iLoginName;
       
    71 		Extension()->iLoginName=NULL;
       
    72 
       
    73 		delete Extension()->iTlsSslDomain;
       
    74 		Extension()->iTlsSslDomain=NULL;
       
    75 		
       
    76 		delete Extension()->iPassword;
       
    77 		Extension()->iPassword=NULL;
       
    78 		
       
    79 		Extension()->iToCcIncludeLimit=KSmtpToCcIncludeLimitDefault;
       
    80 		}
       
    81 	}
       
    82 
       
    83 
       
    84 EXPORT_C const TPtrC CImSmtpSettings::EmailAlias() const
       
    85 /**
       
    86 Retrieves the configured email alias (display name) that will be sent
       
    87 with outbound email.
       
    88 
       
    89 This is normally set to the real name of the user, e.g. "John Smith".
       
    90 Set this value by calling SetEmailAliasL().
       
    91 
       
    92 @return 
       
    93 The email alias (display name) if set, empty if not.
       
    94 */
       
    95 	{
       
    96 	return iEmailAlias ? TPtrC(*iEmailAlias) : TPtrC();
       
    97 	}
       
    98 
       
    99 
       
   100 EXPORT_C const TPtrC CImSmtpSettings::EmailAddress() const
       
   101 /**
       
   102 Retrieves the configured SMTP email address of the user,
       
   103 e.g. "john.smith@work.com".
       
   104 
       
   105 @return
       
   106 SMTP email address of the user if set, empty if not.
       
   107 */
       
   108 	{
       
   109 	return iEmailAddress ? TPtrC(*iEmailAddress) : TPtrC();
       
   110 	}
       
   111 
       
   112 
       
   113 EXPORT_C const TPtrC CImSmtpSettings::ReplyToAddress() const
       
   114 /** Gets the internet email address that the user wishes replies to emails to be 
       
   115 sent to. 
       
   116 
       
   117 This may be set to be the same as for EmailAddress(), or may be set to be 
       
   118 a different email address, e.g. "groupenquiries\@work.com".
       
   119 
       
   120 @return Internet email address that the user wishes replies to emails to be 
       
   121 sent to */
       
   122 	{
       
   123 	return iReplyToAddress ? TPtrC(*iReplyToAddress) : TPtrC();
       
   124 	}
       
   125 
       
   126 
       
   127 EXPORT_C const TPtrC CImSmtpSettings::ReceiptAddress() const
       
   128 /** Gets the internet email address that the user wishes receipts to be returned 
       
   129 to.
       
   130 
       
   131 This would normally be set to be the same as for ReplyToAddress(), e.g. "groupenquiries\@work.com".
       
   132 
       
   133 @return Internet email address that the user wishes receipts to be returned 
       
   134 to. */
       
   135 	{
       
   136 	if (Extension() && Extension()->iReceiptAddress)
       
   137 		return TPtrC(*(Extension()->iReceiptAddress));
       
   138 	return TPtrC();
       
   139 	}
       
   140 
       
   141 
       
   142 EXPORT_C TMsgOutboxBodyEncoding CImSmtpSettings::BodyEncoding() const
       
   143 /**
       
   144 Retrieves the method of encoding email messages if the encoding is not
       
   145 specified when they are sent.
       
   146 
       
   147 The default value (EMsgOutboxMIME) is set so that text parts of the message
       
   148 are sent as MIME multipart/alternative text/html parts, and are encoded using
       
   149 UTF-8.
       
   150 	
       
   151 @see TMsgOutboxBodyEncoding
       
   152 
       
   153 @return
       
   154 Method of encoding.
       
   155 */
       
   156 	{
       
   157 	return iBodyEncoding;
       
   158 	}
       
   159 
       
   160 
       
   161 EXPORT_C const TUid CImSmtpSettings::DefaultMsgCharSet() const
       
   162 /**
       
   163 Retrieves which character set is used to send text in MIME email messages.
       
   164 
       
   165 The default character set is ISO-8859-1 (Latin 1). The UIDs used to identify 
       
   166 all character sets are defined in the Character Conversion API. 
       
   167 
       
   168 @return
       
   169 Character set identifier.
       
   170 */
       
   171 	{
       
   172 	return iDefaultMsgCharSet;
       
   173 	}
       
   174 
       
   175 
       
   176 EXPORT_C void CImSmtpSettings::SetEmailAliasL(const TDesC& aEmailAlias)
       
   177 /**
       
   178 Specifies the configured email alias (display name) that will be sent
       
   179 with outbound email.
       
   180 
       
   181 This is normally set to the real name of the user.  For example, "John Smith".
       
   182 
       
   183 @param aEmailAlias
       
   184 The email alias (display name).
       
   185 */
       
   186 	{
       
   187 	HBufC* newEmailAlias = aEmailAlias.AllocL();
       
   188 	delete iEmailAlias;
       
   189 	iEmailAlias = newEmailAlias;
       
   190 	}
       
   191 
       
   192 
       
   193 EXPORT_C void CImSmtpSettings::SetEmailAddressL(const TDesC& aEmailAddress)
       
   194 /**
       
   195 Specifies the SMTP email address of the user.
       
   196 
       
   197 @param aEmailAddress
       
   198 SMTP email address of the user.
       
   199 */
       
   200 	{
       
   201 	HBufC* newEmailAddress = aEmailAddress.AllocL();
       
   202 	delete iEmailAddress;
       
   203 	iEmailAddress = newEmailAddress;
       
   204 	}
       
   205 
       
   206 
       
   207 EXPORT_C void CImSmtpSettings::SetReplyToAddressL(const TDesC& aReplyToAddress)
       
   208 /**
       
   209 Specifies the email address that the user wishes replies to emails to be 
       
   210 sent to. If this is not specified, replies will be sent to the address
       
   211 set by calling SetEmailAddressL(). 
       
   212 
       
   213 @param aReplyToAddress
       
   214 SMTP email address that the user wishes replies 
       
   215 to emails to be sent to.
       
   216 */
       
   217 	{
       
   218 	HBufC* newReplyToAddress = aReplyToAddress.AllocL();
       
   219 	delete iReplyToAddress;
       
   220 	iReplyToAddress = newReplyToAddress;
       
   221 	}
       
   222 
       
   223 
       
   224 EXPORT_C void CImSmtpSettings::SetReceiptAddressL(const TDesC& aReceiptAddress)
       
   225 /**
       
   226 Specifies the SMTP email address that the user wishes email receipts to be
       
   227 returned to.
       
   228 
       
   229 @param aReceiptAddress
       
   230 SMTP email address that the user wishes receipts to be returned to.
       
   231 */
       
   232 	{
       
   233 	CheckExtensionExistsL();
       
   234 	HBufC* newReceiptAddress = aReceiptAddress.AllocL();
       
   235 	delete Extension()->iReceiptAddress;
       
   236 	Extension()->iReceiptAddress = newReceiptAddress;
       
   237 	}
       
   238 
       
   239 
       
   240 EXPORT_C void CImSmtpSettings::SetBodyEncoding(TMsgOutboxBodyEncoding aBodyEncoding)
       
   241 /**
       
   242 Specifies the default method of encoding email messages if the encoding is
       
   243 not specified when sent.
       
   244 
       
   245 The default value (EMsgOutboxMIME) is set so that text parts of the message
       
   246 are sent as MIME multipart/alternative text/html parts, and are encoded using
       
   247 UTF-8.
       
   248 	
       
   249 @see TMsgOutboxBodyEncoding
       
   250 
       
   251 @param aBodyEncoding
       
   252 Default method of encoding
       
   253 */
       
   254 	{
       
   255 	iBodyEncoding = aBodyEncoding;
       
   256 	}
       
   257 
       
   258 
       
   259 EXPORT_C void CImSmtpSettings::SetDefaultMsgCharSet(TUid aDefaultMsgCharSet)
       
   260 /**
       
   261 Specifies which character set is used to send text in MIME email messages.
       
   262 
       
   263 The default character set is ISO-8859-1 (Latin 1). The UIDs used to identify 
       
   264 all character sets are defined in the Character Conversion API. 
       
   265 
       
   266 @param aDefaultMsgCharSet
       
   267 Character set identifier.
       
   268 */
       
   269 	{
       
   270 	iDefaultMsgCharSet = aDefaultMsgCharSet;
       
   271 	}
       
   272 
       
   273 
       
   274 EXPORT_C TBool CImSmtpSettings::AddVCardToEmail() const
       
   275 /**
       
   276 Retrieves whether email messages will have a VCard containing the user's
       
   277 details from the Contacts Database when they are sent.
       
   278 
       
   279 This is supported as an alternative method of adding contact information into 
       
   280 email messages if the user does not wish to send signature text in their emails.
       
   281 
       
   282 @return
       
   283 ETrue if the user's VCard is to be attached when sending.
       
   284 */
       
   285 	{
       
   286 	return iFlags & KSmtpAddVCardToEmailFlag;
       
   287 	}
       
   288 
       
   289 
       
   290 EXPORT_C void CImSmtpSettings::SetAddVCardToEmail(TBool aFlag)
       
   291 /** 
       
   292 Specifies whether the email messages will have a VCard containing the user's
       
   293 details from the Contacts Database when they are sent.
       
   294 
       
   295 @param aFlag
       
   296 ETrue if the user's VCards will be added when the email is sent.
       
   297 */
       
   298 	{
       
   299 	iFlags = (iFlags & ~KSmtpAddVCardToEmailFlag) | (aFlag ? KSmtpAddVCardToEmailFlag : KSmtpSettingsClearFlag);
       
   300 	}
       
   301 
       
   302 
       
   303 EXPORT_C TBool CImSmtpSettings::AddSignatureToEmail() const
       
   304 /**
       
   305 Retrieves whether email messages will have the user's signature text appended
       
   306 to the text of the messages when they are sent.
       
   307 
       
   308 The signature is stored in the SMTP service entry as a rich text body stream.
       
   309 
       
   310 If there is no signature body text stored in the SMTP service entry, then the
       
   311 email is sent with no signature. This method does not check whether the signature
       
   312 body text exists in the SMTP entry or not.
       
   313 
       
   314 This method is supported as an alternative method for adding contact 
       
   315 information into email messages if the user does not wish to send VCards in 
       
   316 emails. 
       
   317 
       
   318 @return ETrue
       
   319 If a signature text will be appended if it axists.
       
   320 */
       
   321 	{
       
   322 	return iFlags & KSmtpAddSignatureToEmailFlag;
       
   323 	}
       
   324 
       
   325 
       
   326 EXPORT_C void CImSmtpSettings::SetAddSignatureToEmail(TBool aFlag)
       
   327 /**
       
   328 Specifies whether email messages will have the user's signature text appended
       
   329 to the text of the messages when they are sent.
       
   330 
       
   331 The signature is stored in the SMTP service entry as a rich text body stream.
       
   332 
       
   333 If there is no signature body text stored in the SMTP service entry, then the
       
   334 email is sent with no signature. This method does not check whether the signature
       
   335 body text exists in the SMTP entry or not.
       
   336 
       
   337 This method is supported as an alternative method for adding contact 
       
   338 information into email messages if the user does not wish to send VCards in 
       
   339 emails. 
       
   340 
       
   341 @param aFlag
       
   342 ETrue if a signature text should be attempted to be appended to outbound email.
       
   343 */
       
   344 	{
       
   345 	iFlags = (iFlags & ~KSmtpAddSignatureToEmailFlag) | (aFlag ? KSmtpAddSignatureToEmailFlag : KSmtpSettingsClearFlag);
       
   346 	}
       
   347 
       
   348 
       
   349 EXPORT_C TBool CImSmtpSettings::RequestReceipts() const
       
   350 /**
       
   351 Retrieves whether outbound email messages will contain a header that requests
       
   352 receipts to be returned to the address identified by ReceiptAddress().
       
   353 
       
   354 If no receipt address has been set,then no receipt is requested. It is entirely
       
   355 up to the receiving mail client whether or not it will comply with this request.
       
   356 
       
   357 @return
       
   358 ETrue if receipts are requested.
       
   359 */
       
   360 	{
       
   361 	return iFlags & KSmtpRequestReceipts;
       
   362 	}
       
   363 
       
   364 
       
   365 EXPORT_C void CImSmtpSettings::SetRequestReceipts(TBool aFlag)
       
   366 /**
       
   367 Specifies whether outbound email messages will have a header added that requests
       
   368 a receipt from the recipient.
       
   369 
       
   370 If no receipt address has been set,then no receipt is requested. It is entirely
       
   371 up to the receiving mail client whether or not it will comply with this request.
       
   372 
       
   373 @param aFlag
       
   374 ETrue if receipts will be requested.
       
   375 */
       
   376 	{
       
   377 	iFlags = (iFlags & ~KSmtpRequestReceipts) | (aFlag ? KSmtpRequestReceipts : KSmtpSettingsClearFlag);
       
   378 	}
       
   379 
       
   380 
       
   381 EXPORT_C TImSMTPSendCopyToSelf CImSmtpSettings::SendCopyToSelf() const
       
   382 /**
       
   383 Retrieves the setting of the option that allows the user to automatically email 
       
   384 themselves a copy of all emails that are sent. 
       
   385 
       
   386 @see TImSMTPSendCopyToSelf
       
   387 
       
   388 @return
       
   389 Option setting.
       
   390 */
       
   391 	{
       
   392 	return iSendCopyToSelf;
       
   393 	}
       
   394 
       
   395 
       
   396 EXPORT_C void CImSmtpSettings::SetSendCopyToSelf(TImSMTPSendCopyToSelf aSendCopyToSelf)
       
   397 /**
       
   398 Specifies the option that allows the user to automatically email themselves a copy 
       
   399 of all emails that are sent. 
       
   400 
       
   401 @see TImSMTPSendCopyToSelf
       
   402 
       
   403 @param aSendCopyToSelf
       
   404 Option setting.
       
   405 */
       
   406 	{
       
   407 	iSendCopyToSelf = aSendCopyToSelf;
       
   408 	}
       
   409 
       
   410 
       
   411 EXPORT_C TImSMTPSendMessageOption CImSmtpSettings::SendMessageOption() const
       
   412 /**
       
   413 Retrieves the setting of the sending option for new email messages if it is not
       
   414 specified while sending.
       
   415 
       
   416 This option is intended to be acted on by the message client.
       
   417 The default value is send the message immediately (ESendMessageImmediately).
       
   418 
       
   419 @see TImSMTPSendMessageOption
       
   420 
       
   421 @return
       
   422 Default sending option.
       
   423 */
       
   424 	{
       
   425 	return iSendMessageOption;
       
   426 	}
       
   427 
       
   428 
       
   429 EXPORT_C void CImSmtpSettings::SetSendMessageOption(TImSMTPSendMessageOption aSendMessageOption)
       
   430 /**
       
   431 Specifies the sending option for outbound email messages if it is not
       
   432 specified while sending.
       
   433 
       
   434 The default value is to send the message immediately (ESendMessageImmediately).
       
   435 
       
   436 @see TImSMTPSendMessageOption
       
   437 
       
   438 @param aSendMessageOption
       
   439 Default sending option.
       
   440 */
       
   441 	{
       
   442 	iSendMessageOption = aSendMessageOption;
       
   443 	}
       
   444 
       
   445 
       
   446 EXPORT_C CImSmtpSettings& CImSmtpSettings::CopyL(const CImSmtpSettings& aCImSmtpSettings)
       
   447 /**
       
   448 Copies the configuration settings from another SMTP settings object into this object.
       
   449 
       
   450 @param aCImSmtpSettings
       
   451 Specifies the object to copy.
       
   452 
       
   453 @return
       
   454 This object after copying.
       
   455 */
       
   456 	{
       
   457 	// CheckExtensionExistsL() called at the start of the function, since it's allocation will be longer lived
       
   458 	CheckExtensionExistsL();
       
   459 	Reset();
       
   460 	CImBaseEmailSettings::CopyL(aCImSmtpSettings);
       
   461 	iEmailAlias					=	aCImSmtpSettings.EmailAlias().AllocL();
       
   462 	iEmailAddress				=	aCImSmtpSettings.EmailAddress().AllocL();
       
   463 	iReplyToAddress				=	aCImSmtpSettings.ReplyToAddress().AllocL();
       
   464 	Extension()->iReceiptAddress=	aCImSmtpSettings.ReceiptAddress().AllocL();
       
   465 	iBodyEncoding				=	aCImSmtpSettings.BodyEncoding();
       
   466 	iDefaultMsgCharSet			=	aCImSmtpSettings.DefaultMsgCharSet();
       
   467 	iSendCopyToSelf				=	aCImSmtpSettings.SendCopyToSelf();
       
   468 	iSendMessageOption			=	aCImSmtpSettings.SendMessageOption();
       
   469 	Extension()->iLoginName		=	aCImSmtpSettings.LoginName().AllocL();
       
   470 	Extension()->iPassword		=	aCImSmtpSettings.Password().AllocL();
       
   471 	Extension()->iTlsSslDomain	=	aCImSmtpSettings.TlsSslDomain().AllocL();
       
   472 	Extension()->iToCcIncludeLimit	=	aCImSmtpSettings.ToCcIncludeLimit();
       
   473 	return (*this);
       
   474 	}
       
   475 
       
   476 
       
   477 EXPORT_C TBool CImSmtpSettings::operator==(const CImSmtpSettings& aCImSmtpSettings) const
       
   478 /**
       
   479 Equality operator.
       
   480 
       
   481 @param aCImSmtpSettings
       
   482 Specifies the SMTP settings object to compare with.
       
   483 
       
   484 @return
       
   485 ETrue if the settings are the same.
       
   486 */
       
   487 	{
       
   488 	return ((CImBaseEmailSettings::operator==(aCImSmtpSettings)) &&
       
   489 			!((EmailAlias().Compare(aCImSmtpSettings.EmailAlias())) ||
       
   490 			 (EmailAddress().Compare(aCImSmtpSettings.EmailAddress())) ||
       
   491 			 (ReplyToAddress().Compare(aCImSmtpSettings.ReplyToAddress())) ||
       
   492 			 (ReceiptAddress().Compare(aCImSmtpSettings.ReceiptAddress()))) &&
       
   493 			(BodyEncoding()	==	aCImSmtpSettings.BodyEncoding()) &&
       
   494 			(DefaultMsgCharSet() == aCImSmtpSettings.DefaultMsgCharSet()) &&
       
   495 			(SendCopyToSelf() == aCImSmtpSettings.SendCopyToSelf()) &&
       
   496 			(SendMessageOption() == aCImSmtpSettings.SendMessageOption()) &&
       
   497 			(ToCcIncludeLimit() == aCImSmtpSettings.ToCcIncludeLimit()) &&
       
   498 			!(LoginName().Compare(aCImSmtpSettings.LoginName())) &&
       
   499 			!(Password().Compare(aCImSmtpSettings.Password())));
       
   500 	}
       
   501 
       
   502 
       
   503 EXPORT_C const TPtrC8 CImSmtpSettings::LoginName() const
       
   504 /**
       
   505 Retrieves the login user name used when SMTP authentication is enabled by
       
   506 calling SetSMTPAuth(). 
       
   507 
       
   508 @return
       
   509 The login user name.
       
   510 */
       
   511 	{
       
   512 	if (Extension() && Extension()->iLoginName)
       
   513 		return TPtrC8(*(Extension()->iLoginName));
       
   514 	return TPtrC8();
       
   515 	}
       
   516 
       
   517 
       
   518 EXPORT_C void CImSmtpSettings::SetLoginNameL(const TDesC8& aLoginName)
       
   519 /**
       
   520 Specifies the login user name used when SMTP authentication is enabled by
       
   521 calling SetSMTPAuth(). 
       
   522 
       
   523 @param aLoginName
       
   524 The login user name.
       
   525 */
       
   526 	{
       
   527 	CheckExtensionExistsL();
       
   528 	HBufC8* newLoginName = aLoginName.AllocL();
       
   529 	delete Extension()->iLoginName;
       
   530 	Extension()->iLoginName = newLoginName;
       
   531 	}
       
   532 
       
   533 
       
   534 EXPORT_C const TPtrC8 CImSmtpSettings::Password() const
       
   535 /**
       
   536 Retrieves the password used when SMTP authentication is enabled by
       
   537 calling SetSMTPAuth(). 
       
   538 
       
   539 @return
       
   540 The password.
       
   541 */
       
   542 	{
       
   543 	if (Extension() && Extension()->iPassword)
       
   544 		return TPtrC8(*(Extension()->iPassword));
       
   545 	return TPtrC8();
       
   546 	}
       
   547 
       
   548 
       
   549 EXPORT_C void CImSmtpSettings::SetPasswordL(const TDesC8& aPassword)
       
   550 /**
       
   551 Specifies the password used when SMTP authentication is enabled by
       
   552 calling SetSMTPAuth().
       
   553 
       
   554 @param aPassword
       
   555 The password.
       
   556 */
       
   557 	{
       
   558 	CheckExtensionExistsL();
       
   559 	HBufC8* newPassword = aPassword.AllocL();
       
   560 	delete Extension()->iPassword;
       
   561 	Extension()->iPassword = newPassword;
       
   562 	}
       
   563 
       
   564 
       
   565 EXPORT_C TBool CImSmtpSettings::SMTPAuth() const
       
   566 /**
       
   567 Retrieves whether SMTP authentication will be used when sending emails.
       
   568 Read RFC 2554 "SMTP Service Extension for Authentication" for more details.
       
   569 
       
   570 @return
       
   571 ETrue if SMTP authentication is enabled.
       
   572 */
       
   573 	{
       
   574 	return iFlags & KSmtpSmtpAuthFlag;
       
   575 	}
       
   576 
       
   577 
       
   578 EXPORT_C void CImSmtpSettings::SetSMTPAuth(TBool aFlag)
       
   579 /**
       
   580 Enables or disables SMTP authentication when sending emails.
       
   581 Read RFC 2554 "SMTP Service Extension for Authentication" for more details.
       
   582 
       
   583 @param aFlag
       
   584 ETrue to enable SMTP authentication.
       
   585 */
       
   586 	{
       
   587 	iFlags = (iFlags & ~KSmtpSmtpAuthFlag) | (aFlag ? KSmtpSmtpAuthFlag : KSmtpSettingsClearFlag);
       
   588 	}
       
   589 
       
   590 
       
   591 EXPORT_C TBool CImSmtpSettings::InboxLoginDetails() const
       
   592 /*
       
   593 This function should not be used. Use SMTPAuth() for testing if 
       
   594 SMTP authentication should be used.
       
   595 @return Unused
       
   596 @deprecated
       
   597 */
       
   598 	{
       
   599 	return iFlags & KSmtpInboxLoginDetails;
       
   600 	}
       
   601 
       
   602 
       
   603 EXPORT_C void CImSmtpSettings::SetInboxLoginDetails(TBool aFlag)
       
   604 /*
       
   605 This function should not be used. Use SetSMTPAuth() for flagging that 
       
   606 SMTP authentication should be used.
       
   607 @param aFlag Unused
       
   608 @deprecated
       
   609 */
       
   610 	{
       
   611 	iFlags = (iFlags & ~KSmtpInboxLoginDetails) | (aFlag ? KSmtpInboxLoginDetails : KSmtpSettingsClearFlag);
       
   612 	}
       
   613 	
       
   614 /**
       
   615 Retrieves the setting for inclusion of original To and CC email addresses 
       
   616 in the body text of reply and forwarded emails.
       
   617 
       
   618 @return
       
   619 The maximum number of addresses to include in either field.
       
   620 */
       
   621 EXPORT_C TInt CImSmtpSettings::ToCcIncludeLimit() const
       
   622 	{
       
   623 	if (Extension())
       
   624 		{
       
   625 		return (Extension()->iToCcIncludeLimit);
       
   626 		}
       
   627 	else
       
   628 		{
       
   629 		return KSmtpToCcIncludeLimitDefault;
       
   630 		}
       
   631 	}
       
   632 
       
   633 /**
       
   634 Specifies maximum number of original To and CC addresses to include in 
       
   635 the body header when replying-to and forwarding emails.
       
   636 The default (0) indicates that no addresses should be included.
       
   637 
       
   638 @param aLimit 
       
   639 The maximum number of addresses to include in each field.
       
   640 */
       
   641 EXPORT_C void CImSmtpSettings::SetToCcIncludeLimitL(TInt aLimit)
       
   642 	{
       
   643 	__ASSERT_DEBUG( aLimit>=0, User::Invariant() );
       
   644 	CheckExtensionExistsL();
       
   645 	if (aLimit<0)
       
   646 		{
       
   647 		Extension()->iToCcIncludeLimit = KSmtpToCcIncludeLimitDefault;
       
   648 		}
       
   649 	else
       
   650 		{
       
   651 		Extension()->iToCcIncludeLimit = aLimit;
       
   652 		}
       
   653 	}
       
   654 
       
   655 /**
       
   656 Sets the domain name to use during TLS/SSL certificate validation.
       
   657 
       
   658 @param aDomainName Domain name
       
   659 */
       
   660 EXPORT_C void CImSmtpSettings::SetTlsSslDomainL(const TDesC8& aDomainName)
       
   661 	{
       
   662 	CheckExtensionExistsL();
       
   663 	HBufC8* newTlsSslDomain = aDomainName.AllocL();
       
   664 	delete Extension()->iTlsSslDomain;
       
   665 	Extension()->iTlsSslDomain = newTlsSslDomain;
       
   666 	}
       
   667 
       
   668 /**
       
   669 Gets the domain name used during TLS/SSL certificate validation.
       
   670 
       
   671 @return Domain name
       
   672 */
       
   673 EXPORT_C TPtrC8 CImSmtpSettings::TlsSslDomain() const
       
   674 	{
       
   675 	if (Extension() && Extension()->iTlsSslDomain)		
       
   676 		return TPtrC8(*(Extension()->iTlsSslDomain));
       
   677 	return TPtrC8();
       
   678 	}
       
   679 
       
   680 
       
   681 /** Gets the sending status of the SMTP operation.
       
   682 
       
   683 @return Sending status
       
   684 */
       
   685 EXPORT_C TMsgImOutboxSendState TImSmtpProgress::Status() const
       
   686 	{
       
   687 	return iStatus;	
       
   688 	}
       
   689 
       
   690 
       
   691 /** Sets the sending status of the SMTP operation
       
   692 
       
   693 @param aStatus New sending status
       
   694 */
       
   695 EXPORT_C void TImSmtpProgress::SetStatus(TMsgImOutboxSendState aStatus)
       
   696 	{
       
   697 	iStatus = aStatus;
       
   698 	}
       
   699 
       
   700 
       
   701 /** Sets an error code for the operation.
       
   702 
       
   703 @param anError Error code
       
   704 */
       
   705 EXPORT_C void TImSmtpProgress::SetError(TInt anError)
       
   706 	{
       
   707 	iError=anError;
       
   708 	}
       
   709 
       
   710 
       
   711 /** Gets an operation error code.
       
   712 
       
   713 This is set only when a send operation has completed.
       
   714 
       
   715 @return Operation error code
       
   716 */
       
   717 EXPORT_C TInt TImSmtpProgress::Error() const
       
   718 	{
       
   719 	return iError;
       
   720 	}
       
   721 
       
   722 
       
   723 /** Gets the index of the message that is currently being sent.
       
   724 
       
   725 The index range is from 0 to SendTotal().
       
   726 
       
   727 @return Index of the message being sent
       
   728 */
       
   729 EXPORT_C TInt TImSmtpProgress::MsgNo() const
       
   730 	{
       
   731 	if (Status() == EMsgOutboxProgressConnecting)
       
   732 		{
       
   733 		// While the status is EMsgOutboxProgressConnecting, the iMsgNo variable contains
       
   734 		//  the connection progress value.  Therefore return 0 instead.
       
   735 		return 0;
       
   736 		}
       
   737 	else
       
   738 		{
       
   739 		return iMsgNo;
       
   740 		}
       
   741 	}
       
   742 
       
   743 
       
   744 /** Sets the index of the message that is currently being sent.
       
   745 
       
   746 @param aMsgNo Index of the message being sent
       
   747 */
       
   748 EXPORT_C void TImSmtpProgress::SetMsgNo(TInt aMsgNo)
       
   749 	{
       
   750 	iMsgNo = aMsgNo;
       
   751 	}
       
   752 
       
   753 
       
   754 /** Gets the number of messages sent so far in this SMTP session.
       
   755 
       
   756 @return Number of messages
       
   757 */
       
   758 EXPORT_C TInt TImSmtpProgress::Sent() const
       
   759 	{
       
   760 	if (Status() == EMsgOutboxProgressConnecting)
       
   761 		{
       
   762 		// While the status is EMsgOutboxProgressConnecting, the iSent variable contains
       
   763 		//  the connection IAP value.  Therefore return 0 instead.
       
   764 		return 0;
       
   765 		}
       
   766 	else
       
   767 		{
       
   768 		return iSent;	
       
   769 		}
       
   770 	}
       
   771 
       
   772 
       
   773 /** Gets the number of messages that the MTM did not attempt to send in this session.
       
   774 
       
   775 A possible reason is because the message store was locked by another client.
       
   776 
       
   777 @return Number of messages
       
   778 */
       
   779 EXPORT_C TInt TImSmtpProgress::NotSent() const
       
   780 	{
       
   781 	return iNotSent;	
       
   782 	}
       
   783 
       
   784 
       
   785 /** Gets the number of messages that the MTM failed to send this session.
       
   786 
       
   787 For example, failure could be because the SMTP server refused to accept a message.
       
   788 
       
   789 @return Number of messages
       
   790 */
       
   791 EXPORT_C TInt TImSmtpProgress::FailedToSend() const
       
   792 	{
       
   793 	return iFailedToSend;	
       
   794 	}
       
   795 
       
   796 
       
   797 /** Gets the total number of messages that the MTM is attempting to send in this session. 
       
   798 
       
   799 The following equation is always true: Sent() + NotSent() + FailedToSend() = SendTotal().
       
   800 
       
   801 @return Number of messages
       
   802 */
       
   803 EXPORT_C TInt TImSmtpProgress::SendTotal() const
       
   804 	{
       
   805 	return iSendTotal;	
       
   806 	}
       
   807 
       
   808 
       
   809 /** Set the progress variables to initial values.
       
   810 
       
   811 The "send total" and "not sent" variables are set to aTotal. Other counter
       
   812 variables are set to 0. The initial status is set to EMsgOutboxProgressWaiting.
       
   813 
       
   814 @param aTotal Number of messages to send
       
   815 */
       
   816 EXPORT_C void TImSmtpProgress::InitialiseTotal(const TInt& aTotal)
       
   817 	{
       
   818 	iNotSent=aTotal;
       
   819 	iSendTotal=aTotal;
       
   820 	iSent=0;
       
   821 	iFailedToSend=0;
       
   822 	iError=0;
       
   823 	iMsgNo=0;
       
   824 	iSendFileProgress.iBytesSent=0;
       
   825 	iSendFileProgress.iBytesToSend=0;
       
   826 	iSendFileProgress.iSessionState=EConnectingToSmtp;
       
   827 	iStatus=EMsgOutboxProgressWaiting;
       
   828 	}
       
   829 
       
   830 
       
   831 /** Updates progress variables for when a message is successfully sent.
       
   832 
       
   833 The "message sent" count is incremented; the "not sent" count is decremented.
       
   834 */
       
   835 EXPORT_C void TImSmtpProgress::UpdateSent()
       
   836 	{
       
   837 	iNotSent--;
       
   838 	iSent++;
       
   839 	}
       
   840 
       
   841 
       
   842 /** Updates progress variables for when a message fails to be sent.
       
   843 
       
   844 The "failed to send" count is incremented; the "not sent" count is decremented.
       
   845 */
       
   846 EXPORT_C void TImSmtpProgress::UpdateFailedToSend()
       
   847 	{
       
   848 	iNotSent--;
       
   849 	iFailedToSend++;	// only changed if message was couldn't be sent
       
   850 	}
       
   851 
       
   852 
       
   853 /** Decrements the send total.
       
   854 
       
   855 This can be used to adjust the total if a message is found to be deleted 
       
   856 before it can be sent. 
       
   857 */
       
   858 EXPORT_C void TImSmtpProgress::DecrementSendTotal()
       
   859 	{
       
   860 	// used to lower send total when I discover one message in collection 
       
   861 	// which has been deleted before I had a chance to send it.
       
   862 	iSendTotal--;
       
   863 	iNotSent--;
       
   864 	}
       
   865 
       
   866 
       
   867 /** Gets the message server entry ID of the SMTP service being used.
       
   868 
       
   869 @return Message server entry ID of the SMTP service
       
   870 */
       
   871 EXPORT_C TMsvId TImSmtpProgress::ServiceId() const
       
   872 	{
       
   873 	return iServiceId;
       
   874 	}
       
   875 
       
   876 
       
   877 /** Sets the message server entry ID of the SMTP service being used.
       
   878 
       
   879 @param aServiceId Message server entry ID of the SMTP service
       
   880 */
       
   881 EXPORT_C void TImSmtpProgress::SetServiceId(TMsvId aServiceId)
       
   882 	{
       
   883 	iServiceId = aServiceId;
       
   884 	}
       
   885 
       
   886 
       
   887 EXPORT_C TInt TImSmtpProgress::ConnectionState() const
       
   888 /**
       
   889 Retrieves the stage of the connection process as defined in nifvar.h and csdprog.h
       
   890 while the service is connecting to the SMTP server.
       
   891 
       
   892 @return
       
   893 KLinkLayerOpen if the SMTP service has successfully connected, or
       
   894 KErrNotFound if the SMTP service is disconnected, or 
       
   895 the current connection stage (declared in nifvar.h and csdprog.h) while
       
   896 establishing a connection.
       
   897 */
       
   898 	{
       
   899 	switch(iStatus )
       
   900 		{
       
   901 	case EMsgOutboxProgressConnecting:
       
   902 		// Return the connection state temporarily stored in iMsgNo
       
   903 		//  while connection is in progress
       
   904 		return iMsgNo;
       
   905 	case EMsgOutboxProgressWaiting:
       
   906 		// If we're definately in a disconnected state, return KErrNotFound
       
   907 		return KErrNotFound;
       
   908 	default:
       
   909 		// If we're in one of the connected states, return KLinkLayerOpen
       
   910 		return KLinkLayerOpen;
       
   911 		}
       
   912 	}
       
   913 
       
   914 EXPORT_C TInt TImSmtpProgress::ConnectionIAP() const
       
   915 /**
       
   916 Retrieves the internet access point that is used when connecting to the
       
   917 SMTP service.
       
   918 
       
   919 @return
       
   920 KErrNotFound if the SMTP service is not connecting, otherwise the
       
   921 internet access point number.
       
   922 */
       
   923 	{
       
   924 	if (Status() == EMsgOutboxProgressConnecting)
       
   925 		{
       
   926 		// Return the connection IAP temporarily stored in iSent
       
   927 		// while connection is in progress
       
   928 		return iSent;
       
   929 		}
       
   930 	else
       
   931 		{
       
   932 		return KErrNotFound;
       
   933 		}
       
   934 	}
       
   935 
       
   936 EXPORT_C void TImSmtpProgress::SetConnectionIAP(TInt aConnectionIAP)
       
   937 /**
       
   938 Sets the ConnectionIAP value.
       
   939 
       
   940 @param aConnectionIAP
       
   941 The value that the ConnectionIAP will be set to.
       
   942 */
       
   943 	{
       
   944 	// Only store the Connection IAP value in iSent if we're in the Connectiong state
       
   945 	if (Status() == EMsgOutboxProgressConnecting)
       
   946 		{
       
   947 		iSent = aConnectionIAP;
       
   948 		}
       
   949 	}