email/pop3andsmtpmtm/clientmtms/inc/cemailaccounts.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2004-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 #ifndef __CEMAILACCOUNTS_H__
       
    17 #define __CEMAILACCOUNTS_H__
       
    18 
       
    19 
       
    20 #include <e32std.h>
       
    21 #include <e32base.h>
       
    22 #include <msvapi.h>
       
    23 
       
    24 
       
    25 class CImIAPPreferences;
       
    26 class CImPop3Settings;
       
    27 class CImImap4Settings;
       
    28 class CImSmtpSettings;
       
    29 class CRepository;
       
    30 class CImapSyncDownloadRules;
       
    31 class CImapTransportBufferSizes;
       
    32 class CImSmtpMobilitySettings;
       
    33 
       
    34 /**
       
    35 Maximum size of email account name
       
    36 
       
    37 @publishedAll
       
    38 @released
       
    39 */
       
    40 const TInt KEmailAccountNameSize = 256;
       
    41 
       
    42 /**
       
    43 Maximum number of entries allowed in the IAP list for a SMTP mobility account
       
    44 
       
    45 @publishedPartner
       
    46 @released
       
    47 */
       
    48 const TInt KMaxSmtpMobilityAccountIAPListEntries = 32;
       
    49 
       
    50 /**
       
    51 Identifier number for a POP email account.
       
    52 
       
    53 @publishedAll
       
    54 @released
       
    55 @see TPopAccount
       
    56 */
       
    57 typedef TInt TPopAccountId;
       
    58 
       
    59 /**
       
    60 Identifier number for an IMAP email account.
       
    61 
       
    62 @publishedAll
       
    63 @released
       
    64 @see TImapAccount
       
    65 */
       
    66 typedef TInt TImapAccountId;
       
    67 
       
    68 /**
       
    69 Identifier number for an SMTP email account.
       
    70 
       
    71 @publishedAll
       
    72 @released
       
    73 @see TSmtpAccount
       
    74 */
       
    75 typedef TInt TSmtpAccountId;
       
    76 
       
    77 /**
       
    78 Identifier number for an SMTP moblity account.
       
    79 
       
    80 @publishedPartner
       
    81 @released
       
    82 */
       
    83 typedef TInt TSmtpMobilityAccountId;
       
    84 
       
    85 /**
       
    86 Array of IAP values
       
    87 
       
    88 @publishedPartner
       
    89 @released
       
    90 */
       
    91 typedef RArray<TUint32> RArrayIAP;
       
    92 
       
    93 /**
       
    94 Null or undefined SMTP account identifier
       
    95 
       
    96 @publishedPartner
       
    97 @released
       
    98 */
       
    99 const TSmtpAccountId KNullSmtpAccountId = 0;
       
   100 
       
   101 /**
       
   102 POP account ID.
       
   103 
       
   104 Objects of this type identify POP email accounts. 
       
   105 They are obtained when a POP account is created 
       
   106 (CEmailAccounts::CreatePopAccountL()), or by 
       
   107 querying for what POP accounts exist 
       
   108 (CEmailAccounts::GetPopAccountL() and CEmailAccounts::GetPopAccountsL()).
       
   109 
       
   110 The object is then used as a handle to the account when getting
       
   111 the account settings, using CEmailAccounts::LoadPopSettingsL() and 
       
   112 CEmailAccounts::LoadPopIapSettingsL().
       
   113 
       
   114 @publishedAll
       
   115 @released
       
   116 */
       
   117 class TPopAccount
       
   118 	{
       
   119 public:
       
   120 	/** POP account identifier number. 
       
   121 	
       
   122 	Each POP account stored on the phone has a different
       
   123 	identifier number to distinguish it from other accounts.
       
   124 	*/
       
   125 	TPopAccountId iPopAccountId;
       
   126 
       
   127 	/** POP account name. */
       
   128 	TBuf<KEmailAccountNameSize> iPopAccountName;
       
   129 
       
   130 	/** Entry ID of the POP service for this account. */
       
   131 	TMsvId iPopService;
       
   132 
       
   133 	/** Entry ID of the related SMTP service for this account. 
       
   134 		
       
   135 	This is set if an SMTP service has been created, using 
       
   136 	CEmailAccounts::CreateSmtpAccountL(), that specifies that 
       
   137 	it is related to this account. An SMTP service (which provides
       
   138 	email sending functionality) is used in conjunction with 
       
   139 	a POP or IMAP service (which provide email retrieval).
       
   140 	*/
       
   141 	TMsvId iSmtpService;
       
   142 	};
       
   143 
       
   144 /**
       
   145 IMAP account ID.
       
   146 
       
   147 Objects of this type identify IMAP email accounts. 
       
   148 They are obtained when a IMAP account is created 
       
   149 (CEmailAccounts::CreateImapAccountL()), or by 
       
   150 querying for what IMAP accounts exist 
       
   151 (CEmailAccounts::GetImapAccountL() and CEmailAccounts::GetImapAccountsL()).
       
   152 
       
   153 The object is then used as a handle to the account when getting
       
   154 the account settings, using CEmailAccounts::LoadImapSettingsL() and 
       
   155 CEmailAccounts::LoadImapIapSettingsL().
       
   156 
       
   157 @publishedAll
       
   158 @released
       
   159 */
       
   160 class TImapAccount
       
   161 	{
       
   162 public:
       
   163 	/** IMAP account identifier number.
       
   164 	
       
   165 	Each IMAP account stored on the phone has a different
       
   166 	identifier number to distinguish it from other accounts.
       
   167 	*/
       
   168 	TImapAccountId iImapAccountId;
       
   169 
       
   170 	/** IMAP account name */
       
   171 	TBuf<KEmailAccountNameSize> iImapAccountName;
       
   172 
       
   173 	/** Entry ID of the IMAP service for this account. */
       
   174 	TMsvId iImapService;
       
   175 
       
   176 	/** Entry ID of the related SMTP service for this account. 
       
   177 		
       
   178 	This is set if an SMTP service has been created, using 
       
   179 	CEmailAccounts::CreateSmtpAccountL(), that specifies that 
       
   180 	it is related to this account. An SMTP service (which provides
       
   181 	email sending functionality) is used in conjunction with 
       
   182 	a POP or IMAP service (which provide email retrieval).
       
   183 	*/
       
   184 	TMsvId iSmtpService;
       
   185 	};
       
   186 
       
   187 /**
       
   188 SMTP account ID.
       
   189 
       
   190 Objects of this type identify SMTP email accounts. 
       
   191 They are obtained when a SMTP account is created 
       
   192 (CEmailAccounts::CreateSmtpAccountL()), or by 
       
   193 querying for what SMTP accounts exist 
       
   194 (CEmailAccounts::GetSmtpAccountL() and CEmailAccounts::GetISmtpAccountsL()).
       
   195 
       
   196 The object is then used as a handle to the account when getting
       
   197 the account settings, using CEmailAccounts::LoadSmtpSettingsL() and 
       
   198 CEmailAccounts::LoadSmtpIapSettingsL().
       
   199 
       
   200 @publishedAll
       
   201 @released
       
   202 */
       
   203 class TSmtpAccount
       
   204 	{
       
   205 public:
       
   206 	/** SMTP account identifier number. */
       
   207 	TSmtpAccountId iSmtpAccountId;
       
   208 
       
   209 	/** SMTP account name */
       
   210 	TBuf<KEmailAccountNameSize> iSmtpAccountName;
       
   211 
       
   212 	/** Entry ID of the SMTP service for this account. */
       
   213 	TMsvId iSmtpService;
       
   214 
       
   215 	/** Entry ID of the related POP or IMAP service for this account. 
       
   216 		
       
   217 	An SMTP service (which provides	email sending functionality) is 
       
   218 	used in conjunction with a POP or IMAP service (which provide email retrieval).
       
   219 	*/
       
   220 	TMsvId iRelatedService;
       
   221 	};
       
   222 
       
   223 /**
       
   224 @publishedPartner
       
   225 @released
       
   226 */
       
   227 class TSmtpMobilityAccount
       
   228 	{
       
   229 public:
       
   230 	/** SMTP mobility account identifier */
       
   231 	TSmtpMobilityAccountId iAccountId;
       
   232 
       
   233 	/** SMTP mobility account name */
       
   234 	TBuf<KEmailAccountNameSize> iName;
       
   235 
       
   236 	/** Parent SMTP account identifier */
       
   237 	TSmtpAccountId iParentSmtpAccountId;
       
   238 
       
   239 	/** Linked SMTP account identifier. Identifies the SMTP account whose
       
   240 	    settings will be used by this mobility account. If the mobility account
       
   241 	    is using its own settings, this will be set to KNullSmtpAccountId. */
       
   242 	TSmtpAccountId iLinkedSmtpAccountId;
       
   243 	};
       
   244 
       
   245 /**
       
   246 Creates, loads, saves and deletes email (IMAP, POP, and SMTP) accounts. 
       
   247 
       
   248 An account encapsulates:
       
   249 
       
   250 - Settings for a messaging service. There is a different type of 
       
   251   settings class for each of the email protocols (CImPop3Settings, 
       
   252   CImImap4Settings, CImSmtpSettings).
       
   253 - IAP (Internet account) settings for accessing the service.
       
   254 
       
   255 The class has a family of functions for each protocol to create, get,
       
   256 and delete accounts:
       
   257 
       
   258 - Create\<protocol\>AccountL 
       
   259 - Get\<protocol\>AccountL 
       
   260 - Get\<protocol\>AccountsL 
       
   261 - Delete\<protocol\>AccountL 
       
   262 
       
   263 where \<protocol\> is either POP, IMAP, or SMTP. 
       
   264 The Create and Get functions don't directly return settings 
       
   265 objects, but only account identifiers. 
       
   266 
       
   267 Account identifiers are passed to the following functions 
       
   268 to save and load the service and IAP settings for that account:
       
   269 
       
   270 - Load\<protocol\>SettingsL
       
   271 - Save\<protocol\>SettingsL 
       
   272 - Load\<protocol\>IapSettingsL 
       
   273 - Save\<protocol\>IapSettingsL 
       
   274 
       
   275 For SMTP only, there is a concept of a default account (as a client
       
   276 program may want to send an email, and not care which account is used.)
       
   277 SetDefaultSmtpAccountL(), DefaultSmtpAccountL() and DeleteDefaultSmtpAccountL() 
       
   278 are used to handle this.
       
   279 
       
   280 Note that an account is associated with a service entry in the message store,
       
   281 but account information itself is stored in the central repository.
       
   282 
       
   283 @publishedAll
       
   284 @released
       
   285 */
       
   286 class CEmailAccounts : public CBase, public MMsvSessionObserver
       
   287 	{
       
   288 public:
       
   289 
       
   290 	IMPORT_C static CEmailAccounts* NewL();
       
   291 	IMPORT_C static CEmailAccounts* NewLC();
       
   292 	IMPORT_C virtual ~CEmailAccounts();
       
   293 
       
   294 	IMPORT_C TPopAccount CreatePopAccountL(const TDesC& aAccountName, const CImPop3Settings& aPopSettings,
       
   295 		const CImIAPPreferences& aPopIAP, TBool aReadOnly);
       
   296 
       
   297 	IMPORT_C TImapAccount CreateImapAccountL(const TDesC& aAccountName, const CImImap4Settings& aImapSettings,
       
   298 		const CImIAPPreferences& aImapIAP, TBool aReadOnly);
       
   299 
       
   300 	IMPORT_C TSmtpAccount CreateSmtpAccountL(TPopAccount& aPopAccount, const CImSmtpSettings& aSmtpSettings,
       
   301 		const CImIAPPreferences& aSmtpIAP, TBool aReadOnly);
       
   302 
       
   303 	IMPORT_C TSmtpAccount CreateSmtpAccountL(TImapAccount& aImapAccount, const CImSmtpSettings& aSmtpSettings,
       
   304 		const CImIAPPreferences& aSmtpIAP, TBool aReadOnly);
       
   305 
       
   306 	IMPORT_C TSmtpAccount CreateSmtpAccountL(const TDesC& aAccountName, const CImSmtpSettings& aSmtpSettings, 
       
   307 		const CImIAPPreferences& aSmtpIAP, TBool aReadOnly);
       
   308 
       
   309 	IMPORT_C void GetPopAccountsL(RArray<TPopAccount>& aAccounts);
       
   310 	IMPORT_C void GetPopAccountL(TMsvId aServiceId, TPopAccount& aAccount); 
       
   311 	IMPORT_C void DeletePopAccountL(const TPopAccount& aAccount);
       
   312 
       
   313 	IMPORT_C void GetImapAccountsL(RArray<TImapAccount>& aAccounts);
       
   314 	IMPORT_C void GetImapAccountL(TMsvId aServiceId, TImapAccount& aAccount); 
       
   315 	IMPORT_C void DeleteImapAccountL(const TImapAccount& aAccount);
       
   316 
       
   317 	IMPORT_C void GetSmtpAccountsL(RArray<TSmtpAccount>& aAccounts);
       
   318 	IMPORT_C void GetSmtpAccountL(TMsvId aServiceId, TSmtpAccount& aAccount); 
       
   319 	IMPORT_C void DeleteSmtpAccountL(const TSmtpAccount& aAccount);
       
   320 	IMPORT_C void DeleteDefaultSmtpAccountL();
       
   321 
       
   322 	IMPORT_C void PopulateDefaultPopSettingsL(CImPop3Settings& aPopSettings,
       
   323 	CImIAPPreferences& aPopIap);
       
   324 
       
   325 	IMPORT_C void PopulateDefaultImapSettingsL(CImImap4Settings& aImapSettings,
       
   326 	CImIAPPreferences& aImapIap);
       
   327 
       
   328 	IMPORT_C void PopulateDefaultSmtpSettingsL(CImSmtpSettings& aSmtpSettings,
       
   329 	CImIAPPreferences& aSmtpIap);
       
   330 
       
   331 	IMPORT_C TInt DefaultSmtpAccountL(TSmtpAccount& aAccount);
       
   332 	IMPORT_C void SetDefaultSmtpAccountL(const TSmtpAccount& aAccount);
       
   333 
       
   334 	IMPORT_C void LoadPopSettingsL(const TPopAccount& aAccount, CImPop3Settings& aPopSettings);
       
   335 	IMPORT_C void LoadPopIapSettingsL(const TPopAccount& aAccount, CImIAPPreferences& aIAP);
       
   336 
       
   337 	IMPORT_C void LoadImapSettingsL(const TImapAccount& aAccount, CImImap4Settings& aImapSettings);
       
   338 	IMPORT_C void LoadImapIapSettingsL(const TImapAccount& aAccount, CImIAPPreferences& aIAP);
       
   339 
       
   340 	IMPORT_C void LoadSmtpSettingsL(const TSmtpAccount& aAccount, CImSmtpSettings& aSmtpSettings);
       
   341 	IMPORT_C void LoadSmtpIapSettingsL(const TSmtpAccount& aAccount, CImIAPPreferences& aIAP);
       
   342 
       
   343 	IMPORT_C void SavePopSettingsL(const TPopAccount& aAccount, const CImPop3Settings& aPopSettings);
       
   344 	IMPORT_C void SavePopIapSettingsL(const TPopAccount& aAccount, const CImIAPPreferences& aIAP);
       
   345 
       
   346 	IMPORT_C void SaveImapSettingsL(const TImapAccount& aAccount, const CImImap4Settings& aImapSettings);
       
   347 
       
   348 	IMPORT_C void SaveImapIapSettingsL(const TImapAccount& aAccount, const CImIAPPreferences& aIAP);
       
   349 
       
   350 	IMPORT_C void SaveSmtpSettingsL(const TSmtpAccount& aAccount, const CImSmtpSettings& aSmtpSettings);
       
   351 	IMPORT_C void SaveSmtpIapSettingsL(const TSmtpAccount& aAccount, const CImIAPPreferences& aIAP);
       
   352 
       
   353 	IMPORT_C TBool IsAccountReadOnlyL(const TPopAccount& aAccount);
       
   354 	IMPORT_C TBool IsAccountReadOnlyL(const TImapAccount& aAccount);
       
   355 	IMPORT_C TBool IsAccountReadOnlyL(const TSmtpAccount& aAccount);
       
   356 
       
   357 	// Published partner routines
       
   358 	IMPORT_C TImapAccount CreateImapAccountL(const TDesC& aAccountName,
       
   359 		const CImImap4Settings& aImapSettings, const CImIAPPreferences& aImapIAP,
       
   360 		const CImapSyncDownloadRules& aSyncDownloadRules, TBool aReadOnly);
       
   361 	IMPORT_C void LoadImapSyncDownloadRulesL(const TImapAccount& aAccount, CImapSyncDownloadRules& aRules);
       
   362 	IMPORT_C void LoadImapTransportBufferSizesL(CImapTransportBufferSizes& aBufferSizes);
       
   363 	IMPORT_C void SaveImapSyncDownloadRulesL(const TImapAccount& aAccount, const CImapSyncDownloadRules& aRules);
       
   364 	IMPORT_C void SaveImapTransportBufferSizesL(const CImapTransportBufferSizes& aBufferSizes);
       
   365 	IMPORT_C void DeleteImapTransportBufferSizesL();
       
   366 
       
   367 	IMPORT_C void GetSmtpAccountL(TSmtpAccountId aAccountId, TSmtpAccount& aAccount);
       
   368 
       
   369 	IMPORT_C TSmtpMobilityAccount CreateSmtpMobilityAccountL(const TDesC& aAccountName, const RArrayIAP& aIapList, const TSmtpAccount& aSmtpAccount, const CImSmtpMobilitySettings& aSettings, TBool aReadOnly);
       
   370 	IMPORT_C TSmtpMobilityAccount CreateSmtpMobilityAccountL(const TDesC& aAccountName, const RArrayIAP& aIapList, const TSmtpAccount& aSmtpAccount, const TSmtpAccount& aLinkedSmtpAccount, TBool aReadOnly);
       
   371 	IMPORT_C void GetSmtpMobilityAccountsL(const TSmtpAccount& aSmtpAccount, RArray<TSmtpMobilityAccount>& aAccounts);
       
   372 	IMPORT_C void DeleteSmtpMobilityAccountL(const TSmtpMobilityAccount& aAccount);
       
   373 
       
   374 	IMPORT_C void PopulateDefaultSmtpMobilitySettingsL(CImSmtpMobilitySettings& aSettings);
       
   375 	IMPORT_C void LoadSmtpMobilitySettingsL(const TSmtpMobilityAccount& aAccount, CImSmtpMobilitySettings& aSettings);
       
   376 	IMPORT_C void SaveSmtpMobilitySettingsL(const TSmtpMobilityAccount& aAccount, const CImSmtpMobilitySettings& aSettings);
       
   377 
       
   378 	IMPORT_C void LoadSmtpMobilityAccountIapListL(const TSmtpMobilityAccount& aAccount, RArrayIAP& aIapList);
       
   379 	IMPORT_C void SaveSmtpMobilityAccountIapListL(const TSmtpMobilityAccount& aAccount, const RArrayIAP& aIapList);
       
   380 
       
   381 	IMPORT_C TBool IsAccountReadOnlyL(const TSmtpMobilityAccount& aAccount);
       
   382 
       
   383 	// Internal routines
       
   384 	IMPORT_C void GetSmtpMobilityAccountsL(RArray<TSmtpMobilityAccount>& aAccounts);
       
   385 	IMPORT_C TBool LoadSmtpMobilitySettingsL(TSmtpAccountId& aSmtpAccountId, TUint32 aIap, CImSmtpMobilitySettings& aSettings);
       
   386 
       
   387 private:
       
   388 	CEmailAccounts();
       
   389 	void HandleSessionEventL(TMsvSessionEvent , TAny* , TAny* , TAny* );
       
   390 	CMsvSession& SessionL();
       
   391 	CRepository& PopRepositoryL();
       
   392 	CRepository& ImapRepositoryL();
       
   393 	CRepository& SmtpRepositoryL();
       
   394 
       
   395 	TMsvId CreateEmailServiceL(CMsvEntry& aMsvEntry, const TDesC& aAccountName, TUid aMTMType, TBool aVisible);
       
   396 	void SetRelatedIdL(CMsvEntry& aMsvEntry, TMsvId aId, TMsvId aRelatedId);
       
   397 	void SetEntryDetailsL(TMsvId aId, const TDesC& aAccountName);
       
   398 	void UnSetInPreparationFlagsL(CMsvEntry& aMsvEntry, TMsvId aId, TInt aAccountId);
       
   399 	void DeleteServiceEntryL(CMsvEntry& aMsvEntry, TMsvId aId);
       
   400 
       
   401 	TUint GetNextEmptyAccountSlotL(CRepository& aRepository);
       
   402 	TUint32 FindEmailAccountL(TMsvId aService, CRepository& aRepository);
       
   403 
       
   404 	void LoadIAPPrefSettingsL(TUint32 aAccountId, CImIAPPreferences& aIAP, CRepository& aRepository);
       
   405 	void DoLoadPopSettingsL(TUint32 aAccountId, CImPop3Settings& aPopSettings);
       
   406 	void DoLoadImapSettingsL(TUint32 aAccountId, CImImap4Settings& aImapSettings);
       
   407 	void DoLoadSmtpSettingsL(TUint32 aAccountId, CImSmtpSettings& aSmtpSettings);
       
   408 
       
   409 	void SaveIAPPrefSettingsL(TUint32 aAccountId, const CImIAPPreferences& aIAP, CRepository& aRepository);
       
   410 	void DoSavePopSettingsL(TUint32 aAccountId, const CImPop3Settings& aPopSettings);
       
   411 	void DoSaveSmtpSettingsL(TUint32 aAccountId, const CImSmtpSettings& aSmtpSettings);
       
   412 	void DoSaveImapSettingsL(TUint32 aAccountId, const CImImap4Settings& aImapSettings);	
       
   413 	void DoSaveImapSyncDownloadRulesL(TUint32 aAccountId, const CImapSyncDownloadRules& aRules, CRepository& aRepository);
       
   414 
       
   415 	TImapAccount CreateImapAccountL(const TDesC& aAccountName, const CImImap4Settings& aImapSettings,
       
   416 		const CImIAPPreferences& aImapIAP, const CImapSyncDownloadRules* aSyncDownloadRules, TBool aReadOnly);
       
   417 
       
   418 	TUint32 DoCreatePopAccountL(const TDesC& aAccountName, const CImPop3Settings& aPopSettings, 
       
   419 		const CImIAPPreferences& aPopIAP, TMsvId aPopService, TMsvId aRelatedService, TBool aReadOnly);
       
   420 	TUint32 DoCreateImapAccountL(const TDesC& aAccountName, const CImImap4Settings& aImapSettings,
       
   421 		const CImIAPPreferences& aImapIAP, const CImapSyncDownloadRules* aSyncDownloadRules, TMsvId aImapService,
       
   422 		TMsvId aRelatedService, TBool aReadOnly);
       
   423 	TUint32 DoCreateSmtpAccountL(TPopAccount& aPopAccount, const CImSmtpSettings& aSmtpSettings, 
       
   424 		const CImIAPPreferences& aSmtpIAP, TMsvId aSmtpService, CMsvEntry& aMsvEntry, TUint32& aPopAccountId, TBool aReadOnly);
       
   425 	TUint32 DoCreateSmtpAccountL(TImapAccount& aImapAccount, const CImSmtpSettings& aSmtpSettings, 
       
   426 		const CImIAPPreferences& aSmtpIAP, TMsvId aSmtpService, CMsvEntry& aMsvEntry, TUint32& aImapAccountId, TBool aReadOnly);
       
   427 	TUint32 DoCreateSmtpAccountL(const TDesC& aAccountName, const CImSmtpSettings& aSmtpSettings, 
       
   428 		const CImIAPPreferences& aSmtpIAP, TMsvId aSmtpService, TMsvId aRelatedService, TBool aReadOnly);	
       
   429 
       
   430 	void DeleteIAPPrefSettingsL(TUint32 aAccountId, CRepository& aRepository);
       
   431 	void DeletePopSettings(TUint32 aAccountId, CRepository& aRepository);
       
   432 	void DeleteSmtpSettings(TUint32 aAccountId, CRepository& aRepository);
       
   433 	void DeleteImapSettings(TUint32 aAccountId, CRepository& aRepository);
       
   434 	void DeleteImapSyncDownloadRulesL(TUint32 aAccountId, CRepository& aRepository);
       
   435 
       
   436 	void GetEmailServicesL(CMsvEntrySelection& aServices, TUid aMTMType, CMsvEntry& aMsvEntry);
       
   437 
       
   438 	TBool IsAsciiPrintable(const TDesC16& aText);
       
   439 	TBool IsAsciiPrintable(const TDesC8& aText);
       
   440 	TBool IsUnicodePrintable(const TDesC16& aText);
       
   441 
       
   442 	TSmtpMobilityAccount DoCreateSmtpMobilityAccountL(const TDesC& aAccountName, const RArrayIAP& aIapList, const CImSmtpMobilitySettings& aSettings, const TSmtpAccount& aSmtpAccount, TSmtpAccountId aLinkedSmtpAccountId, TBool aReadOnly);
       
   443 	void AddMobilityAccountToSmtpAccountL(const TSmtpAccount& aSmtpAccount, const RArrayIAP& aIapList, TUint32 aMobAccRepId, CRepository& aRepository);
       
   444 	void AddLinkToMobilityAccountL(TSmtpAccountId aLinkedSmtpAccountId, TUint32 aMobAccRepId, CRepository& aRepository);
       
   445 	TInt FindIapListEntryInSmtpMobilityAccountListL(const RArrayIAP& aIapList, CRepository& aRepository, TUint32 aSmtpAccRepId, TInt aNumEntries, TInt aIgnorePos);
       
   446 	TInt FindAccountIdInSmtpMobilityAccountListL(TUint32 aMobAccRepId, CRepository& aRepository, TUint32 aSmtpAccRepId, TInt aNumEntries);
       
   447 	void GetSmtpAccountInfoForMobilityAccountL(TUint32 aMobAccRepId, CRepository& aRepository, TUint32& aSmtpAccRepId, TInt& aPos);
       
   448 	void DeleteAllOwnedMobilityAccountsL(TUint32 aSmtpAccRepId, CRepository& aRepository);
       
   449 	void DeleteAllLinkedMobilityAccountsL(TUint32 aLinkedSmtpAccRepId, CRepository& aRepository);
       
   450 	void DeleteSmtpMobilityAccountListEntryL(TUint32 aMobAccRepId, CRepository& aRepository, TUint32 aSmtpAccRepId);
       
   451 	void DeleteSmtpMobilityAccountFromLinkedSmtpAccountL(TUint32 aMobAccRepId, CRepository& aRepository);
       
   452 	TBool IsSmtpTypeAccountReadOnlyL(TUint32 aAccRepId);
       
   453 	TBool IsSmtpMobilityAccount(CRepository& aRepository, TUint32 aAccRepId);
       
   454 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   455 	void CreateHeaderStoreL(TUid aMTMid);
       
   456 #endif
       
   457 private:
       
   458 	enum TEmailSettingTypes
       
   459 		{
       
   460 		// Partial CenRep Id for service settings
       
   461 		EServiceSettingType 			= 0x00000000,
       
   462 		// Partial CenRep Id for IAP Prefs
       
   463 		EIAPPrefSettingType				= 0x00010000,
       
   464 		// CenRep mask for email accounts
       
   465 		EAccountMask 					= 0x800FFFFF			
       
   466 		};
       
   467 	
       
   468 	enum TPOPServiceSettingsCenRepId
       
   469 		{
       
   470 		EPOPServiceId					= 0x00000000,
       
   471 		EPOPAccountNameId				= 0x00000001,
       
   472 		EPOPRelatedSMTPServiceId		= 0x00000002,
       
   473 		EPOPSettingsVersionId			= 0x00000003, 
       
   474 		EPOPServerAddressId				= 0x00000004,
       
   475 		EPOPPortNumberId			   	= 0x00000005,     	
       
   476 		EPOPFlagsId						= 0x00000006,
       
   477 		EPOPLoginNameId					= 0x00000007,
       
   478 		EPOPPasswordId					= 0x00000008,
       
   479 		EPOPMaxEmailSizeId				= 0x00000009,
       
   480 		EPOPGetEmailOptionsId			= 0x0000000A,
       
   481 		EPOPInboxSynchronisationLimitId	= 0x0000000B,
       
   482 		EPOPPopulationLimitId			= 0x0000000C,
       
   483 		EPOPReadOnlyAccountId			= 0x0000000D,
       
   484 		EPOPTlsSslDomainId				= 0x0000000F
       
   485 		};
       
   486 
       
   487 	enum TIMAPServiceSettingsCenRepId
       
   488 		{
       
   489 		EIMAPServiceId					= 0x00000000,
       
   490 		EIMAPAccountNameId				= 0x00000001,
       
   491 		EIMAPRelatedSMTPServiceId		= 0x00000002,
       
   492 		EIMAPSettingsVersionId			= 0x00000003, 
       
   493 		EIMAPServerAddressId			= 0x00000004,
       
   494 		EIMAPPortNumberId			   	= 0x00000005,     	
       
   495 		EIMAPFlagsId					= 0x00000006,
       
   496 		EIMAPLoginNameId				= 0x00000007,
       
   497 		EIMAPPasswordId					= 0x00000008,
       
   498 		EIMAPFolderPathId				= 0x00000009,
       
   499 		EIMAPPathSeparatorId			= 0x0000000A,
       
   500 		EIMAPSynchronisationStrategyId	= 0x0000000B,
       
   501 		EIMAPSubscriptionStrategyId		= 0x0000000C,
       
   502 		EIMAPMaxEmailSizeId				= 0x0000000D,
       
   503 		EIMAPGetMailOptionsId			= 0x0000000E,
       
   504 		EIMAPInboxSynchronisationLimitId= 0x0000000F,
       
   505 		EIMAPMailboxSynchronisationLimitId= 0x00000010,
       
   506 		EIMAPTlsSslDomainId				= 0x00000012,		
       
   507 		EIMAPSyncRateId					= 0x00000020,
       
   508 		EIMAPFetchSizeId				= 0x00000030,
       
   509 		EIMAPIdleTimeoutId				= 0x00000040,
       
   510 		EPartialMailOptionsId			= 0x00000050,
       
   511 		EBodyTextSizeLimitId			= 0x00000060,		
       
   512 		EAttachmentSizeLimitId			= 0x00000070,
       
   513 		EIMAPSearchStringId				= 0x00000080,
       
   514 		EIMAPReadOnlyAccountId			= 0x00000090,
       
   515 		// 0x00001000 - 0x00002FFF reserved for sync download rules
       
   516 		// 0x00010000 - 0x00014FFF reserved for IAP/SNAP preferences
       
   517 		};
       
   518 
       
   519 	enum TIMAPSyncDownloadRulesCenRepInfo
       
   520 		{
       
   521 		EIMAPSyncDownloadRulesVersionId = 0x00001000,
       
   522 		EIMAPNumInboxSyncDownloadRulesId = 0x00001001,
       
   523 		EIMAPNumFolderSyncDownloadRulesId = 0x00001002,
       
   524 
       
   525 		EIMAPInboxSyncDownloadRulesBearerTypesId = 0x00001010,
       
   526 		EIMAPInboxSyncDownloadRulesMailOptionsId = 0x00001011,
       
   527 		EIMAPInboxSyncDownloadRulesTotalSizeLimitId = 0x00001012,
       
   528 		EIMAPInboxSyncDownloadRulesBodyTextSizeLimitId = 0x00001013,
       
   529 		EIMAPInboxSyncDownloadRulesAttachmentSizeLimitId = 0x00001014,
       
   530 		EIMAPInboxSyncDownloadRulesGetMailBodyPartsId = 0x00001015,
       
   531 		EIMAPInboxSyncDownloadRulesMaxEmailSizeId = 0x00001016,
       
   532 
       
   533 		EIMAPFolderSyncDownloadRulesBearerTypesId = 0x00001030,
       
   534 		EIMAPFolderSyncDownloadRulesMailOptionsId = 0x00001031,
       
   535 		EIMAPFolderSyncDownloadRulesTotalSizeLimitId = 0x00001032,
       
   536 		EIMAPFolderSyncDownloadRulesBodyTextSizeLimitId = 0x00001033,
       
   537 		EIMAPFolderSyncDownloadRulesAttachmentSizeLimitId = 0x00001034,
       
   538 		EIMAPFolderSyncDownloadRulesGetMailBodyPartsId = 0x00001035,
       
   539 		EIMAPFolderSyncDownloadRulesMaxEmailSizeId = 0x00001036,
       
   540 
       
   541 		// Offset between sets of rules
       
   542 		EIMAPSyncDownloadRulesOffset = 0x40
       
   543 		};
       
   544 
       
   545 	enum TIAPPreferencesCenRepId
       
   546 		{
       
   547 		// single settings		
       
   548 		EIAPPrefVersion 				= 0x00010000,
       
   549 		EIAPChoicesCount 				= 0x00010001,
       
   550 		
       
   551 		// List of settings
       
   552 		EIAPListIDs						= 0x00011000,
       
   553 		EIAPListDialogPrefs				= 0x00012000,
       
   554 		// EIAPSnapId placed here is a deviation from Design doc. Remove comment after a decision is made
       
   555 		EIAPSnapId						= 0x00014000 // The same value is to be used in all account types
       
   556 		};
       
   557 
       
   558 	enum TIMAPTransportBufferSizesCenRepInfo
       
   559 		{
       
   560 		EIMAPTransportBufferSizesVersionId = 0x80000100,
       
   561 		EIMAPNumTransportBufferSizesId = 0x80000101,
       
   562 
       
   563 		EIMAPTransportBufferSizesBearerTypesId = 0x80000110,
       
   564 		EIMAPTransportBufferSizesFetchRequestSizeId = 0x80000111,
       
   565 		EIMAPTransportBufferSizesMaxOutstandingFetchResponsesId = 0x80000112,
       
   566 	
       
   567 		// Offset between entries
       
   568 		EIMAPTransportBufferSizesOffset = 0x20
       
   569 		};
       
   570 
       
   571 	enum TSMTPServiceSettingsCenRepId
       
   572 		{
       
   573 		ESMTPServiceId					= 0x00000000,
       
   574 		ESMTPAccountNameId				= 0x00000001,		
       
   575 		ESMTPSettingsVersionId			= 0x00000002,
       
   576 		ESMTPServerAddressId			= 0x00000003, 
       
   577 		ESMTPPortNumberId				= 0x00000004, 
       
   578 		ESMTPFlagsId				   	= 0x00000005,     	
       
   579 		ESMTPEmailAliasId				= 0x00000006, 
       
   580 		ESMTPEmailAddressId				= 0x00000007,
       
   581 		ESMTPReplyToAddressId			= 0x00000008,
       
   582 		ESMTPReceiptAddressId			= 0x00000009,
       
   583 		ESMTPBodyEncodingId				= 0x0000000A,
       
   584 		ESMTPDefaultMsgCharSetId		= 0x0000000B,
       
   585 		ESMTPSendCopyToSelfId			= 0x0000000C,
       
   586 		ESMTPSendMessageOptionId		= 0x0000000D,
       
   587 		ESMTPLoginNameId				= 0x0000000E,
       
   588 		ESMTPPasswordId					= 0x0000000F,
       
   589 		ESMTPRelatedServiceId			= 0x00000010,
       
   590 		ESMTPIncludeToCcId				= 0x00000011,
       
   591 		ESMTPReadOnlyAccountId			= 0x00000012,
       
   592 		ESMTPParentAccountId			= 0x00000013,
       
   593 		ESMTPTlsSslDomainId				= 0x00000014,
       
   594 		ESMTPLinkedAccountId			= 0x00000015
       
   595 		};
       
   596 
       
   597 	enum TSMTPLinkedMobilityAccountListCenRepInfo
       
   598 		{
       
   599 		ESMTPLinkedMobilityAccountListVersionId = 0x00015000,
       
   600 		ESMTPLinkedMobilityAccountListNumEntriesId = 0x00015001,
       
   601 		ESMTPLinkedMobilityAccountListEntryId = 0x00015010,
       
   602 
       
   603 		// Maximum number of list entries
       
   604 		ESMTPLinkedMobilityAccountListMaxEntries = 2048
       
   605 		};
       
   606 
       
   607 	enum TSMTPMobilityAccountListCenRepInfo
       
   608 		{
       
   609 		ESMTPMobilityAccountListVersionId = 0x00016000,
       
   610 		ESMTPMobilityAccountListNumEntriesId = 0x00016001,
       
   611 
       
   612 		ESMTPMobilityAccountListAccountId = 0x00016010,
       
   613 		ESMTPMobilityAccountListNumIapsId = 0x00016011,
       
   614 		ESMTPMobilityAccountListIapId = 0x00016020,
       
   615 
       
   616 		// Offset between entries
       
   617 		ESMTPMobilityAccountListOffset = 0x40,
       
   618 
       
   619 		// Maximum number of list entries
       
   620 		ESMTPMobilityAccountMaxEntries = 32
       
   621 		};
       
   622 
       
   623 private:
       
   624 	CMsvSession* iMsvSession;
       
   625 	CRepository* iPOPRepository;
       
   626 	CRepository* iSMTPRepository;
       
   627 	CRepository* iIMAPRepository;	
       
   628 	};
       
   629 
       
   630 #endif // __CEMAILACCOUNTS_H__