email/imap4mtm/imapsettings/src/cimapsettings.cpp
changeset 0 72b543305e3a
child 25 fa1df4b99609
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2006-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 // cimapsettings.cpp
       
    15 //
       
    16 
       
    17 #include "cimapsettings.h"
       
    18 #include "imappaniccodes.h"
       
    19 
       
    20 #include <barsc.h>
       
    21 #include <barsread.h>		// TResourceReader
       
    22 #include <bautils.h>
       
    23 #include <cemailaccounts.h>
       
    24 #include <f32file.h>
       
    25 #include <imcm.rsg>			// resource definition for IMCV
       
    26 #include <miuthdr.h>		// For KImEngineResourceFile
       
    27 #include <msvutils.h>
       
    28 #include <iapprefs.h>
       
    29 #include <cimaptransportbuffersizes.h>
       
    30 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS  
       
    31 #include "timrfc822datefield.h"
       
    32 #endif
       
    33 const TInt KMaxOutstandingFetchRequests = 2;
       
    34 
       
    35 /**
       
    36 Static factory constructor
       
    37 
       
    38 @return
       
    39 The constructed CImapSettings object
       
    40 */
       
    41 EXPORT_C CImapSettings* CImapSettings::NewL(CMsvServerEntry& aServerEntry)
       
    42 	{
       
    43 	CImapSettings* self = new (ELeave) CImapSettings(aServerEntry);
       
    44 	CleanupStack::PushL(self);
       
    45 	self->ConstructL();
       
    46 	CleanupStack::Pop(self);
       
    47 	return self;
       
    48 	}
       
    49 
       
    50 CImapSettings::~CImapSettings()
       
    51 	{
       
    52 	delete iServiceSettings;
       
    53 	delete iIapPrefs;
       
    54 	delete iDefaultPartialMessageFooter;
       
    55 	delete iDefaultAttachmentName;
       
    56 	delete iSyncDownloadRules;
       
    57 	delete iTransportBufferSizes;
       
    58 	}
       
    59 
       
    60 CImapSettings::CImapSettings(CMsvServerEntry& aServerEntry)
       
    61 : iServerEntry(aServerEntry)
       
    62 	{
       
    63 	iServiceId = aServerEntry.Entry().Id();
       
    64 	}
       
    65 
       
    66 void CImapSettings::ConstructL()
       
    67 	{
       
    68 	// create a new CImImap4Settings object initialised to default values.
       
    69 	iServiceSettings = new (ELeave) CImImap4Settings;
       
    70 
       
    71 	iIapPrefs = CImIAPPreferences::NewLC();
       
    72 	CleanupStack::Pop(iIapPrefs);
       
    73 
       
    74 	iSyncDownloadRules = CImapSyncDownloadRules::NewL();
       
    75 
       
    76 	iTransportBufferSizes = CImapTransportBufferSizes::NewL();
       
    77 
       
    78 	// read data from resource file (KImEngineResourceFile)
       
    79 	ReadResourceFileL();
       
    80 	}
       
    81 	
       
    82 /**
       
    83 Returns whether the imap settings are loaded from the central repository.
       
    84 
       
    85 @return ETrue  account settings have been loaded
       
    86 		EFalse otherwise
       
    87 */
       
    88 EXPORT_C TBool CImapSettings::SettingsLoaded() const
       
    89 	{
       
    90 	return iSettingsLoaded;
       
    91 	}
       
    92 
       
    93 /**
       
    94 Loads the settings for the specified IMAP Service from the central repository.
       
    95 
       
    96 Note that this function may modify the context of the CMsvServerEntry passed at
       
    97 construction.
       
    98 
       
    99 @param aId
       
   100 The TMsvId for the IMAP Service (or any message entry below the service).
       
   101 */
       
   102 EXPORT_C void CImapSettings::LoadSettingsL(const TMsvId aId)
       
   103 	{
       
   104 	// delete existing service settings
       
   105 	delete iServiceSettings;
       
   106 	iServiceSettings=NULL;
       
   107 
       
   108 	// Get somewhere to store service settings
       
   109 	iServiceSettings=new (ELeave) CImImap4Settings;
       
   110 
       
   111 	delete iIapPrefs;
       
   112 	iIapPrefs = NULL;
       
   113 	iIapPrefs = CImIAPPreferences::NewLC();
       
   114 	CleanupStack::Pop(iIapPrefs);
       
   115 
       
   116 	delete iSyncDownloadRules;
       
   117 	iSyncDownloadRules = NULL;
       
   118 	iSyncDownloadRules = CImapSyncDownloadRules::NewL();
       
   119 
       
   120 	delete iTransportBufferSizes;
       
   121 	iTransportBufferSizes = NULL;
       
   122 	iTransportBufferSizes = CImapTransportBufferSizes::NewL();
       
   123 
       
   124 	// find the service
       
   125 	User::LeaveIfError(iServerEntry.SetEntry(aId));
       
   126 	while (iServerEntry.Entry().iType != KUidMsvServiceEntry)
       
   127 		{
       
   128 		User::LeaveIfError(iServerEntry.SetEntry(iServerEntry.Entry().Parent()));
       
   129 		}
       
   130 
       
   131 	// has the service ID changed?
       
   132 	TMsvId serviceId = iServerEntry.Entry().Id();
       
   133 	if (iServiceId != serviceId && iServiceId != 0)
       
   134 		{
       
   135 		TImapServerPanic::ImapPanic(TImapServerPanic::EImapSettingsInvalidService);
       
   136 		}
       
   137 		
       
   138 	iServiceId = serviceId;
       
   139 
       
   140 	// Get settings for this service
       
   141 	CEmailAccounts* account = CEmailAccounts::NewLC();
       
   142  	TImapAccount accountId;
       
   143 	accountId.iImapAccountId = iServerEntry.Entry().MtmData2();  // iMtmData2 of the service entry contains TImapAccountId
       
   144 	accountId.iImapAccountName = iServerEntry.Entry().iDetails;
       
   145 	accountId.iImapService = iServerEntry.Entry().iServiceId;
       
   146 	accountId.iSmtpService = iServerEntry.Entry().iRelatedId;
       
   147 	account->LoadImapSettingsL(accountId, *iServiceSettings);
       
   148 	account->LoadImapIapSettingsL(accountId, *iIapPrefs);
       
   149 	account->LoadImapSyncDownloadRulesL(accountId, *iSyncDownloadRules);
       
   150 	account->LoadImapTransportBufferSizesL(*iTransportBufferSizes);
       
   151 	CleanupStack::PopAndDestroy(account);
       
   152 
       
   153 	if (iServiceSettings->PathSeparator() != 0)
       
   154 		{
       
   155 		// Store the path separator as a 16 bit descriptor.
       
   156 		TText16 sep = iServiceSettings->PathSeparator();
       
   157 		iPathSeparator.Des().Copy(&sep, 1);
       
   158 		}
       
   159 
       
   160 	iSettingsLoaded = ETrue;
       
   161 	}
       
   162 
       
   163 /**
       
   164 Opens the client MTM resource files and reads the values which are used by the
       
   165 server MTM. When all values are read, the resource file will be closed. The default 
       
   166 resource file is defined by KImEngineResourceFile in miuthdr.h
       
   167 
       
   168 @leave KErrNotFound if the resource file does not exist
       
   169 */
       
   170 void CImapSettings::ReadResourceFileL()
       
   171 	{
       
   172 	RFs fs;
       
   173 	fs.Connect();
       
   174 	CleanupClosePushL(fs);
       
   175 	
       
   176 	//	NB need to check on all drives - won't necessarily be on
       
   177 	//	the same one as IMPS.DLL
       
   178 	TFileName fileName(KImEngineResourceFile);
       
   179 	MsvUtils::AddPathAndExtensionToResFileL(fileName);
       
   180 	BaflUtils::NearestLanguageFile( fs, fileName );
       
   181 	
       
   182 	if (!BaflUtils::FileExists(fs,fileName))
       
   183 		{
       
   184 		User::Leave(KErrNotFound);
       
   185 		}
       
   186 	RResourceFile resourceFile;
       
   187 	resourceFile.OpenL(fs,fileName);		// Qualified: no leavescan error
       
   188 	CleanupClosePushL(resourceFile);
       
   189 
       
   190 	HBufC8* buffer = NULL;
       
   191 	TResourceReader reader;
       
   192 	
       
   193 	// Read iStore8BitData flag.
       
   194 	buffer = resourceFile.AllocReadLC( STORE_8BIT_BODY_TEXT );
       
   195 	reader.SetBuffer(buffer);
       
   196 	iStore8BitData = reader.ReadInt8();
       
   197 	CleanupStack::PopAndDestroy(buffer);
       
   198 	buffer = NULL;
       
   199 
       
   200 	//Read iStorePlainBodyText flag
       
   201 	buffer = resourceFile.AllocReadLC( STORE_PLAIN_BODY_TEXT );
       
   202 	reader.SetBuffer(buffer);
       
   203 	iStorePlainBodyText = reader.ReadInt8();
       
   204 	CleanupStack::PopAndDestroy(buffer);
       
   205 	buffer = NULL;
       
   206 	
       
   207 	// Read iDefaultAttachmentName
       
   208 	buffer = resourceFile.AllocReadLC( DEFAULT_ATTACHMENT_NAME );
       
   209 	reader.SetBuffer(buffer);
       
   210 	
       
   211 	iDefaultAttachmentName=reader.ReadTPtrC().AllocL();	
       
   212 	
       
   213 	CleanupStack::PopAndDestroy(buffer);
       
   214 	buffer = NULL;
       
   215 
       
   216 	// Read the string for remaining mail size for footer	
       
   217 	buffer = resourceFile.AllocReadLC( PARTIAL_DOWNLOAD_FOOTER_MESSAGE );
       
   218 	reader.SetBuffer(buffer);
       
   219 	
       
   220 	iDefaultPartialMessageFooter = buffer;
       
   221 	// No need to destroy buffer-pointer, this class takes ownership
       
   222 	CleanupStack::Pop(buffer);
       
   223 	
       
   224 	CleanupStack::PopAndDestroy(2, &fs);	// resourcefile, fs
       
   225 	}
       
   226 	
       
   227 /**
       
   228 Saves modified settings to the central repository.
       
   229 */
       
   230 void CImapSettings::SaveSettingsL()
       
   231 	{
       
   232 	User::LeaveIfError(iServerEntry.SetEntry(iServiceId));
       
   233 
       
   234 	// Update service entry
       
   235   	CEmailAccounts* account = CEmailAccounts::NewLC();
       
   236  	TImapAccount accountId;
       
   237 	accountId.iImapAccountId = iServerEntry.Entry().MtmData2();  // iMtmData2 of the service entry contains TImapAccountId
       
   238 	accountId.iImapAccountName = KNullDesC;  // So that account name is not updated
       
   239 	accountId.iImapService = iServerEntry.Entry().iServiceId;
       
   240 	accountId.iSmtpService = iServerEntry.Entry().iRelatedId;
       
   241  	account->SaveImapSettingsL(accountId, *iServiceSettings);
       
   242  	account->SaveImapIapSettingsL(accountId, *iIapPrefs);
       
   243  	account->SaveImapSyncDownloadRulesL(accountId, *iSyncDownloadRules);
       
   244  	account->SaveImapTransportBufferSizesL(*iTransportBufferSizes);
       
   245  	CleanupStack::PopAndDestroy(account);
       
   246 	}
       
   247 
       
   248 /**
       
   249 Retrieves the service ID for the connected IMAP service.
       
   250 
       
   251 If settings have not been loaded, this will return zero
       
   252 
       
   253 @return
       
   254 TMsvId for the IMAP service, or zero otherwise.
       
   255 */
       
   256 EXPORT_C TMsvId CImapSettings::ServiceId() const
       
   257 	{
       
   258 	return iServiceId;
       
   259 	}
       
   260 	
       
   261 /**
       
   262 Retrieves the configured IP address or host name of the email server.
       
   263 
       
   264 @return
       
   265 Email server IP address if it is configured, or empty if not configured.
       
   266 */
       
   267 EXPORT_C const TPtrC CImapSettings::ServerAddress() const
       
   268 	{
       
   269 	return iServiceSettings->ServerAddress();
       
   270 	}
       
   271 
       
   272 /**
       
   273 Retrieves the port number of an email server when establishing
       
   274 a TCP connection.
       
   275 
       
   276 @return
       
   277 Email server TCP port number.
       
   278 */
       
   279 EXPORT_C TUint CImapSettings::Port() const
       
   280 	{
       
   281 	return iServiceSettings->Port();
       
   282 	}
       
   283 
       
   284 /** 
       
   285 Retrieves whether a secure TLS connection will be negotiated over an
       
   286 unsecure TCP socket connection when a connection is being established.
       
   287 
       
   288 Refer to RFC 2595 - "Using TLS with IMAP, POP3 and ACAP" for information
       
   289 on how a secure socket is established when retrieving email from a POP3
       
   290 or IMAP4 server.
       
   291 
       
   292 @return
       
   293 ETrue if secure sockets are enabled.
       
   294 */
       
   295 EXPORT_C TBool CImapSettings::SecureSockets() const
       
   296 	{
       
   297 	return iServiceSettings->SecureSockets();
       
   298 	}
       
   299 
       
   300 /**
       
   301 Whether secure sockets will be used. 
       
   302 
       
   303 Retrieves whether a secure TLS connection will be established 
       
   304 directly over a TLS/SSL socket when connecting to the email server.
       
   305 
       
   306 The well known port number for a secure TLS IMAP4 connection is 993.
       
   307 
       
   308 @return
       
   309 ETrue if a secure TLS connection will be attempted when establishing
       
   310 a connection.
       
   311 */
       
   312 EXPORT_C TBool CImapSettings::SSLWrapper() const
       
   313 	{
       
   314 	return iServiceSettings->SSLWrapper();
       
   315 	}
       
   316 	
       
   317 /**
       
   318 Whether bearer mobility is to be used.
       
   319 
       
   320 @return
       
   321 ETrue if the email service has been configured to use bearer mobility
       
   322 */
       
   323 EXPORT_C TBool CImapSettings::BearerMobility() const
       
   324 	{
       
   325 	return iServiceSettings->BearerMobility();
       
   326 	}
       
   327 
       
   328 
       
   329 /**
       
   330 Retrieves the configured login user name (mailbox) of the IMAP4 service.
       
   331 
       
   332 @return 
       
   333 The user name.
       
   334 */
       
   335 EXPORT_C const TPtrC8 CImapSettings::LoginName() const
       
   336 	{
       
   337 	return iServiceSettings->LoginName();
       
   338 	}
       
   339 
       
   340 /**
       
   341 Retrieves the configured login password that will be sent during
       
   342 authentication with the IMAP4 server.
       
   343 
       
   344 @return 
       
   345 The password.
       
   346 */
       
   347 EXPORT_C const TPtrC8 CImapSettings::Password() const
       
   348 	{
       
   349 	return iServiceSettings->Password();
       
   350 	}
       
   351 
       
   352 /**
       
   353 Retrieves the configured path of the IMAP4 mailbox on the server if the user's
       
   354 primary mailbox is not in the Inbox folder.
       
   355 
       
   356 Most of the time this setting will not have to be configured, however this may need
       
   357 to be altered by the user for use with some IMAP4 servers. Refer to RFC 3501
       
   358 Section 5.1 Mailbox Naming for more information.
       
   359 
       
   360 The default setting is empty. 
       
   361 
       
   362 @return
       
   363 The folder path.
       
   364 */
       
   365 EXPORT_C const TPtrC8 CImapSettings::FolderPath() const
       
   366 	{
       
   367 	return iServiceSettings->FolderPath();
       
   368 	}
       
   369 
       
   370 /**
       
   371 Retrieves the string to insert when performing search or fetch operations when
       
   372 synchronising.
       
   373 
       
   374 Allows the client to filter the messages to be synchronised.
       
   375 
       
   376 @return
       
   377 The search string.
       
   378 */
       
   379 EXPORT_C const TPtrC8 CImapSettings::SearchString() const
       
   380 	{
       
   381 	return iServiceSettings->SearchString();
       
   382 	}
       
   383 
       
   384 /**
       
   385 Retrieves the character configured to separate hierarchical mailbox names on
       
   386 the IMAP4 server. Refer to RFC 3501 section 5.1.1 for more information.
       
   387 
       
   388 The default setting an empty null-terminated string.
       
   389 
       
   390 @return
       
   391 The path separator character.
       
   392 */
       
   393 EXPORT_C const TDesC& CImapSettings::PathSeparator() const
       
   394 	{
       
   395 	return iPathSeparator;
       
   396 	}
       
   397 	
       
   398 
       
   399 /**
       
   400 Checks if disconnected user mode is configured.
       
   401 
       
   402 If disconnected user mode is enabled by calling SetDisconnectedUserMode(), 
       
   403 then the IMAP4 client MTM (CImap4ClientMtm) will accept message operations, 
       
   404 such as deleting messages from a server, while the user is offline.
       
   405 The operations are stored and executed when the user connects again.
       
   406 
       
   407 @see
       
   408 CImap4ClientMtm
       
   409 
       
   410 @return 
       
   411 ETrue if disconnected user mode is enabled.
       
   412 */
       
   413 EXPORT_C TBool CImapSettings::DisconnectedUserMode() const
       
   414 	{
       
   415 	return iServiceSettings->DisconnectedUserMode();
       
   416 	}
       
   417 
       
   418 
       
   419 /**
       
   420 Retrieves the method for synchronising folder information with the server. 
       
   421 
       
   422 The default setting is EUseRemote.
       
   423 
       
   424 @see
       
   425 TFolderSyncType
       
   426 
       
   427 @return
       
   428 The folder synchronisation method.
       
   429 */
       
   430 EXPORT_C TFolderSyncType CImapSettings::Synchronise() const
       
   431 	{
       
   432 	return iServiceSettings->Synchronise();
       
   433 	}
       
   434 
       
   435 /**
       
   436 Retrieves the configured method for synchronising IMAP4 subscription information
       
   437 with a server.
       
   438 
       
   439 The default setting is EUpdateNeither.
       
   440 
       
   441 @see
       
   442 TFolderSubscribeType
       
   443 
       
   444 @return
       
   445 The subscription method.
       
   446 */
       
   447 EXPORT_C TFolderSubscribeType CImapSettings::Subscribe() const
       
   448 	{
       
   449 	return iServiceSettings->Subscribe();
       
   450 	}
       
   451 
       
   452 /** 
       
   453 Checks whether the caller has enabled messages marked to be deleted while offline
       
   454 to be expunged from the server when disconnecting from the next online session.
       
   455 
       
   456 Otherwise they are marked for delete and expunged during the initial
       
   457 synchronisation.
       
   458 
       
   459 @return
       
   460 ETrue if emails are to be deleted during the disconnection phase.
       
   461 */
       
   462 EXPORT_C TBool CImapSettings::DeleteEmailsWhenDisconnecting() const
       
   463 	{
       
   464 	return iServiceSettings->DeleteEmailsWhenDisconnecting();
       
   465 	}
       
   466 
       
   467 /** 
       
   468 Returns whether or not the IMAP4 service will synchronise the Inbox folder
       
   469 after connecting, or the maximum number of new messages that will be synchronised
       
   470 if there are new messages on the server.
       
   471 
       
   472 @return
       
   473 If negative, the IMAP4 service will synchronise all emails after connecting.
       
   474 If zero, the IMAP4 service will not synchronise after connecting.
       
   475 If positive, the IMAP4 service will synchronise to the n most recent emails,
       
   476 where n is this return value.
       
   477 */
       
   478 EXPORT_C TInt32 CImapSettings::InboxSynchronisationLimit() const
       
   479 	{
       
   480 	return iServiceSettings->InboxSynchronisationLimit();
       
   481 	}
       
   482 
       
   483 /** 
       
   484 Returns whether or not the IMAP4 service will synchronise folders
       
   485 other than the Inbox after connecting, or the maximum number of messages that
       
   486 will be synchronised in the folders.
       
   487 
       
   488 @return
       
   489 If negative, the IMAP4 service will synchronise all emails after connecting.
       
   490 If zero, the IMAP4 service will not synchronise after connecting.
       
   491 If positive, the IMAP4 service will synchronise to the n most recent emails,
       
   492 where n is this return value.
       
   493 */
       
   494 EXPORT_C TInt32 CImapSettings::MailboxSynchronisationLimit() const
       
   495 	{
       
   496 	return iServiceSettings->MailboxSynchronisationLimit();
       
   497 	}
       
   498 
       
   499 /**
       
   500 Retrieves whether the IMAP4 seen flag of new messages will be set on the server only
       
   501 when the message has been marked as read, or when the message has been synchronised.
       
   502 
       
   503 The default setting is EFalse which means that the seen flag will be set on the
       
   504 server when the new message has been synchronised with the client. The messaging
       
   505 application can mark the message as being read (seen) by calling TMsvEntry::SetUnread().
       
   506 
       
   507 @see TMsvEntry
       
   508 
       
   509 @return
       
   510 Returns ETrue if the seen flag is set on the IMAP4 server only when
       
   511 the message has been marked as read.
       
   512 Returns EFalse if the seen flag is set on the IMAP4 server when the new message
       
   513 is retrieved from the server. 
       
   514 */
       
   515 EXPORT_C TBool CImapSettings::UpdatingSeenFlags() const
       
   516 	{
       
   517 	return iServiceSettings->UpdatingSeenFlags();
       
   518 	}
       
   519 
       
   520 /**
       
   521 Retrieves the IMAP fetch size.
       
   522 
       
   523 When downloading large attachments, data is requested (fetched) in increments. 
       
   524 The larger the fetch size, fewer fetch commands are sent to the IMAP4 server.
       
   525 This speeds up the attachment download rate, but only to a limit.  The limit is
       
   526 network specific.  A fetch size that is too large will degrade performance shortly
       
   527 after downloading an attachment is cancelled, because the fetched data will still
       
   528 be incomming on the socket after cancellation. 
       
   529 
       
   530 @return
       
   531 The IMAP fetch size in bytes.
       
   532 */
       
   533 EXPORT_C TUint CImapSettings::FetchSize() const
       
   534 	{
       
   535 	return iServiceSettings->FetchSize();
       
   536 	}
       
   537 
       
   538 /**
       
   539 Retrieves whether the IMAP IDLE command should be used as defined in RFC2177.
       
   540 
       
   541 The default setting is ETrue which means that the IMAP IDLE command will be used
       
   542 if the server supports it.
       
   543 
       
   544 @return
       
   545 Returns ETrue if the IMAP IDLE command should be used provided the server supports it.
       
   546 Returns EFalse if the IMAP IDLE command should not be used. 
       
   547 */	
       
   548 EXPORT_C TBool CImapSettings::ImapIdle() const
       
   549 	{
       
   550 	return iServiceSettings->ImapIdle();
       
   551 	}
       
   552 
       
   553 /**
       
   554 Retrieves the IMAP IDLE timeout in seconds.
       
   555 
       
   556 @return
       
   557 The IMAP IDLE timeout in seconds. A value of zero specifies that the 
       
   558 IDLE command should not timeout.
       
   559 */	
       
   560 EXPORT_C TInt CImapSettings::ImapIdleTimeout() const
       
   561 	{
       
   562 	return iServiceSettings->ImapIdleTimeout();
       
   563 	}
       
   564 
       
   565 /**
       
   566 Retrieves the SSL domain name
       
   567 
       
   568 @return SSL domain name
       
   569 */	
       
   570 EXPORT_C TPtrC8 CImapSettings::TlsSslDomain() const
       
   571 	{
       
   572 	return iServiceSettings->TlsSslDomain();
       
   573 	}
       
   574 
       
   575 /**
       
   576 Retrieves the IAP preferences.
       
   577 
       
   578 @return
       
   579 The IAP preferences.
       
   580 */	
       
   581 EXPORT_C const CImIAPPreferences& CImapSettings::IAPPreferences() const
       
   582 	{
       
   583 	return *iIapPrefs;
       
   584 	}
       
   585 
       
   586 /**
       
   587 Retrieves the value of the Store8BitData flag. The value of the flag is read
       
   588 from a resource file during construction of this class.
       
   589 
       
   590 @return
       
   591 0 indicates that the message must be converted to 16 bits before storing in the
       
   592 message store, every other value indicates that the message is not converted.
       
   593 */
       
   594 EXPORT_C TInt CImapSettings::Store8BitData() const
       
   595 	{
       
   596 	return iStore8BitData;
       
   597 	}
       
   598 
       
   599 /**
       
   600 Retrieves the default attachment name. The descriptor is read from a
       
   601 resource file during construction of this class.
       
   602 
       
   603 @return
       
   604 The default attachment name descriptor as stored in the resource file.
       
   605 */
       
   606 EXPORT_C const TDesC& CImapSettings::DefaultAttachmentName() const
       
   607 	{
       
   608 	__ASSERT_DEBUG( iDefaultAttachmentName, 
       
   609 					TImapServerPanic::ImapPanic(TImapServerPanic::EImapSettingsNoDefaultAttachmentFile) );
       
   610 	return *iDefaultAttachmentName;
       
   611 	}
       
   612 
       
   613 /**
       
   614 Retrieves the default partial message footer. The descriptor is read from a
       
   615 resource file during construction of this class.
       
   616 
       
   617 @return
       
   618 The the default partial message footer descriptor as stored in the resource file
       
   619 */
       
   620 EXPORT_C const HBufC8* CImapSettings::DefaultPartialMessageFooter() const
       
   621 	{
       
   622 	__ASSERT_DEBUG( iDefaultPartialMessageFooter, 
       
   623 					TImapServerPanic::ImapPanic(TImapServerPanic::EImapSettingsNoMessageFooter) );
       
   624 	return iDefaultPartialMessageFooter;
       
   625 	}
       
   626 
       
   627 
       
   628 /**
       
   629 Allows the path separator used by the server to be set. This parameter is
       
   630 returned in the response to a LIST command.
       
   631 
       
   632 The settings are written to the central repository.
       
   633 
       
   634 @param  aPathSeparator
       
   635 The path separator used by the remote server.
       
   636 */	
       
   637 EXPORT_C void CImapSettings::SetPathSeparatorL(const TText8 aPathSeparator)
       
   638 	{
       
   639 	iServiceSettings->SetPathSeparator(aPathSeparator);
       
   640 	SaveSettingsL();
       
   641 
       
   642 	// Store the path separator as a 16 bit descriptor.
       
   643 	TText16 sep = aPathSeparator;
       
   644 	iPathSeparator.Des().Copy(&sep, 1);
       
   645 	}
       
   646 
       
   647 /**
       
   648 Check whether the KImap4EmailExpungeFlag is set in 
       
   649 CImImap4Settings
       
   650 
       
   651 @return
       
   652 Returns ETrue if the KImap4EmailExpungeFlag was set in
       
   653 CImImap4Settings::SetUseExpunge.
       
   654 */
       
   655 EXPORT_C TBool CImapSettings::UseExpunge() const
       
   656 	{	
       
   657 	return iServiceSettings->UseExpunge();
       
   658 	}
       
   659 
       
   660 /**
       
   661 Indicates whether to use download rules during account synchronisation
       
   662 operations.
       
   663 
       
   664 @return ETrue if download rules should be used, EFalse if not
       
   665 */
       
   666 EXPORT_C TBool CImapSettings::UseSyncDownloadRules() const
       
   667 	{	
       
   668 	return iServiceSettings->UseSyncDownloadRules();
       
   669 	}
       
   670 
       
   671 /**
       
   672 Allows the current bearer type to be set.
       
   673 
       
   674 @param aBearerType: the current bearer type
       
   675 */
       
   676 EXPORT_C void CImapSettings::SetCurrentBearerType(TUint32 aBearerType)
       
   677 	{
       
   678 	iCurrentBearerType = aBearerType;
       
   679 	}
       
   680 
       
   681 /**
       
   682 Gets the synchronisation download rule for the currently connected bearer type.
       
   683 
       
   684 A rule is returned only if the bearer types associated with the rule contain
       
   685 all the bearer types specified in the passed in value.
       
   686 
       
   687 Invalid arguments passed to the routine will cause a panic on debug builds
       
   688 but a leave with KErrArgument on a release build.
       
   689 
       
   690 @param aType Type of folder the rule is for (inbox or other folder)
       
   691 @param aMailInfo On successful completion, this holds the mail info for the rule
       
   692 
       
   693 @return The position of the rule in the list, or KErrNotFound if no matching
       
   694         bearer type was found.
       
   695 */
       
   696 EXPORT_C TInt CImapSettings::GetSyncDownloadRuleL(CImapSyncDownloadRules::TRulesType aType, TImImap4GetPartialMailInfo& aMailInfo) const
       
   697 	{
       
   698 	if (iCurrentBearerType != 0)
       
   699 		{
       
   700 		return iSyncDownloadRules->GetMailInfoL(aType, iCurrentBearerType, aMailInfo);
       
   701 		}
       
   702 	else
       
   703 		{
       
   704 		return KErrNotFound;	
       
   705 		}
       
   706 	
       
   707 	}
       
   708 
       
   709 /**
       
   710 Gets the transport buffer sizes for the currently connected bearer type.
       
   711 
       
   712 The buffer sizes specify the amount of data fetched for each fetch command,
       
   713 and also the number of outstanding requests that may be pipelined at any one
       
   714 time. These parameters are configurable on a per-bearer-type basis, via the
       
   715 client mtms API CImapTransportBufferSizes.
       
   716 
       
   717 If a settings entry is not included for the current bearer-type, the maximum 
       
   718 fetch size is taken from the CImap4Settings class for the account, and the
       
   719 number of outstanding requests is set to the default value.
       
   720 
       
   721 @param aType Type of folder the rule is for (inbox or other folder)
       
   722 @param aMailInfo On successful completion, this holds the mail info for the rule
       
   723 
       
   724 @return The position of the rule in the list, or KErrNotFound if no matching
       
   725         bearer type was found.
       
   726 */
       
   727 EXPORT_C void CImapSettings::GetTransportBufferSizesL(TUint& aFetchRequestSize, TUint& aMaxOutstandingFetchResponses) const
       
   728 	{
       
   729 	TInt err = KErrNotFound;
       
   730 
       
   731 	if (iCurrentBearerType != 0)
       
   732 		{
       
   733 		err = iTransportBufferSizes->GetSizesL(iCurrentBearerType, (TInt&) aFetchRequestSize, (TInt&) aMaxOutstandingFetchResponses);
       
   734 		}
       
   735 
       
   736 	if (err < KErrNone)
       
   737 		{
       
   738 		aFetchRequestSize = FetchSize();
       
   739 		aMaxOutstandingFetchResponses = KMaxOutstandingFetchRequests;
       
   740 		}
       
   741 	}
       
   742 
       
   743 /**
       
   744 Retrieves the value of the StorePlainBodyText flag. The value of the 
       
   745 flag is read from a resource file during construction of this class.
       
   746 
       
   747 @return
       
   748 1 indicates that the message must be stored in chunks in the message store, 
       
   749 0 indicates that the message must be stored entirely in a single Store operation.
       
   750 */
       
   751 EXPORT_C TInt CImapSettings::StorePlainText() const
       
   752 	{
       
   753 	return iStorePlainBodyText;
       
   754 	}
       
   755 
       
   756 /**
       
   757 Check whether the KImap4EmailSettingsFolderSyncDisabled is set in 
       
   758 CImImap4Settings, ie returns true if folder sync is disabled.
       
   759 
       
   760 @return
       
   761 Returns ETrue if the KImap4EmailSettingsFolderSyncDisabled
       
   762 was set in CImImap4Settings::SetFolderSyncDisabled.
       
   763 */
       
   764 EXPORT_C TBool CImapSettings::FolderSyncDisabled() const
       
   765 	{
       
   766 	return iServiceSettings->FolderSyncDisabled();
       
   767 	}
       
   768 	
       
   769 #if (defined SYMBIAN_EMAIL_CAPABILITY_SUPPORT)
       
   770 /**
       
   771 Check whether the KImap4EmailSettingsFallBackIsOnFlagEnabled is set in 
       
   772 CImImap4Settings, ie returns true if Fallback   is enabled.
       
   773 
       
   774 @return
       
   775 Returns ETrue if the KImap4EmailSettingsFallBackIsOnFlagEnabled
       
   776 was set in CImapSettings::SetFallBack() Enabled.
       
   777 */
       
   778 EXPORT_C TBool CImapSettings::FallBack() const
       
   779 	{
       
   780 	return iServiceSettings->FallBack();
       
   781 	}
       
   782 
       
   783 /**
       
   784 Check whether the KImap4EmailSettingsAuthenticationFlagEnabled is set in 
       
   785 CImImap4Settings, ie returns true if Authentication   is enabled.
       
   786 
       
   787 @return
       
   788 Returns ETrue if the KImap4EmailSettingsAuthenticationFlagEnabled
       
   789 was set in CImapSettings::SetIMAP4Auth() Enabled.
       
   790 */
       
   791 EXPORT_C TBool CImapSettings::IMAP4Auth() const
       
   792 	{
       
   793 	return iServiceSettings->IMAP4Auth();
       
   794 	}
       
   795 #endif