|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ImumMboxSettingsCtrl.cpp |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <centralrepository.h> // CRepository |
|
23 #include <cemailaccounts.h> // CEmailAccounts |
|
24 #include <miutset.h> // KUidMsgTypeSMTP |
|
25 #include <smtpset.h> // CImSmtpSettings |
|
26 #include <pop3set.h> // CImPop3Settings |
|
27 #include <imapset.h> // CImImap4Settings |
|
28 #include <iapprefs.h> // CImIAPPreferences |
|
29 #include <messaginginternalcrkeys.h> // KCRUidAOSettings |
|
30 #include <commdb.h> // CCommsDatabase |
|
31 #include "MuiuDynamicSettingItemBase.h" // CMuiuDynamicSettingsItemBase |
|
32 #include <SendUiConsts.h> |
|
33 #include <featmgr.h> |
|
34 |
|
35 #include "ImumMboxSettingsCtrl.h" |
|
36 #include "ImumMboxDefaultData.h" |
|
37 #include "ImumMboxManager.h" |
|
38 #include "ImumPrivateCRKeys.h" // Predefined mailbox keys |
|
39 #include "ImumMboxDataExtension.h" |
|
40 #include "IMASCenRepControl.h" |
|
41 #include "ImumUtilsLogging.h" |
|
42 #include "EmailUtils.H" |
|
43 #include "ImumInternalApiImpl.h" |
|
44 #include "ImumInMailboxUtilitiesImpl.h" |
|
45 #include "ImumPanic.h" |
|
46 #include "ImumInSettingsKeys.h" |
|
47 #include "ImumConstants.h" |
|
48 |
|
49 // EXTERNAL DATA STRUCTURES |
|
50 // EXTERNAL FUNCTION PROTOTYPES |
|
51 // CONSTANTS |
|
52 const TUint64 KIMASLastFlag = 64; |
|
53 |
|
54 enum TISPErrors |
|
55 { |
|
56 EISPNoError = 0, |
|
57 EISPMailboxIdUnderflowFailure, |
|
58 EISPAccountIdUnderflowFailure, |
|
59 EISPAccountIdOverflowFailure, |
|
60 EISPMtmIdParameterFailure |
|
61 }; |
|
62 |
|
63 // MACROS |
|
64 // LOCAL CONSTANTS AND MACROS |
|
65 // MODULE DATA STRUCTURES |
|
66 // LOCAL FUNCTION PROTOTYPES |
|
67 // FORWARD DECLARATIONS |
|
68 |
|
69 // ============================ MEMBER FUNCTIONS =============================== |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // TIMAStorerParams::TIMAStorerParams() |
|
73 // ---------------------------------------------------------------------------- |
|
74 // |
|
75 TIMAStorerParams::TIMAStorerParams( |
|
76 const TUid& aMtmId, |
|
77 const TMsvId aMailboxId ) |
|
78 : |
|
79 iMailboxId( aMailboxId ), |
|
80 iAccountId( 0 ), |
|
81 iMtmId( aMtmId ) |
|
82 { |
|
83 __ASSERT_DEBUG( aMailboxId > 0, |
|
84 User::Panic( KIMSStorerParamsPanic, EISPMailboxIdUnderflowFailure ) ); |
|
85 __ASSERT_DEBUG( |
|
86 ( aMtmId == KSenduiMtmImap4Uid || |
|
87 aMtmId == KSenduiMtmPop3Uid ), |
|
88 User::Panic( KIMSStorerParamsPanic, EISPMtmIdParameterFailure ) ); |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------------------------------- |
|
92 // TIMAStorerParams::TIMAStorerParams() |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 TIMAStorerParams::TIMAStorerParams( |
|
96 const TUint32 aAccountId, |
|
97 const TUid& aMtmId ) |
|
98 : |
|
99 iMailboxId( 0 ), |
|
100 iAccountId( aAccountId ), |
|
101 iMtmId( aMtmId ) |
|
102 { |
|
103 __ASSERT_DEBUG( iAccountId <= KIMASMaxAccounts, |
|
104 User::Panic( KIMSStorerParamsPanic, EISPAccountIdOverflowFailure ) ); |
|
105 __ASSERT_DEBUG( |
|
106 ( aMtmId == KSenduiMtmImap4Uid || |
|
107 aMtmId == KSenduiMtmPop3Uid ), |
|
108 User::Panic( KIMSStorerParamsPanic, EISPMtmIdParameterFailure ) ); |
|
109 |
|
110 } |
|
111 |
|
112 // ---------------------------------------------------------------------------- |
|
113 // TIMAStorerParams::TIMAStorerParams() |
|
114 // ---------------------------------------------------------------------------- |
|
115 // |
|
116 TIMAStorerParams::TIMAStorerParams( |
|
117 const TMsvEntry& aEntry ) |
|
118 : |
|
119 iMailboxId( aEntry.Id() ), |
|
120 iAccountId( aEntry.iMtmData2 ), |
|
121 iMtmId( aEntry.iMtm ) |
|
122 { |
|
123 __ASSERT_DEBUG( iAccountId > 0, |
|
124 User::Panic( KIMSStorerParamsPanic, EISPAccountIdUnderflowFailure ) ); |
|
125 __ASSERT_DEBUG( iAccountId <= KIMASMaxAccounts, |
|
126 User::Panic( KIMSStorerParamsPanic, EISPAccountIdOverflowFailure ) ); |
|
127 __ASSERT_DEBUG( |
|
128 ( aEntry.iMtm == KSenduiMtmImap4Uid || |
|
129 aEntry.iMtm == KSenduiMtmPop3Uid ), |
|
130 User::Panic( KIMSStorerParamsPanic, EISPMtmIdParameterFailure ) ); |
|
131 |
|
132 } |
|
133 |
|
134 // ---------------------------------------------------------------------------- |
|
135 // TIMAStorerParams::MailboxId() |
|
136 // ---------------------------------------------------------------------------- |
|
137 // |
|
138 TMsvId TIMAStorerParams::MailboxId() const |
|
139 { |
|
140 return iMailboxId; |
|
141 } |
|
142 |
|
143 // ---------------------------------------------------------------------------- |
|
144 // TIMAStorerParams::AccountId() |
|
145 // ---------------------------------------------------------------------------- |
|
146 // |
|
147 TUint32 TIMAStorerParams::AccountId() const |
|
148 { |
|
149 return iAccountId; |
|
150 } |
|
151 |
|
152 // ---------------------------------------------------------------------------- |
|
153 // TIMAStorerParams::MtmId() |
|
154 // ---------------------------------------------------------------------------- |
|
155 // |
|
156 TUid TIMAStorerParams::MtmId() const |
|
157 { |
|
158 return iMtmId; |
|
159 } |
|
160 |
|
161 // ============================ MEMBER FUNCTIONS =============================== |
|
162 |
|
163 // ---------------------------------------------------------------------------- |
|
164 // CImumMboxSettingsCtrl::CImumMboxSettingsCtrl() |
|
165 // ---------------------------------------------------------------------------- |
|
166 CImumMboxSettingsCtrl::CImumMboxSettingsCtrl( |
|
167 CImumInternalApiImpl& aMailboxApi ) |
|
168 : |
|
169 iMailboxApi( aMailboxApi ), |
|
170 iUtils( NULL ), |
|
171 iCenRepSmtp( NULL ), |
|
172 iCenRepExtMail( NULL ), |
|
173 iCenRepAlwaysOnline( NULL ), |
|
174 iCenRepDefaultData( NULL ), |
|
175 iAccounts( NULL ), |
|
176 iCenRepControl( NULL ) |
|
177 { |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CImumMboxSettingsCtrl::ConstructL() |
|
182 // ---------------------------------------------------------------------------- |
|
183 // |
|
184 void CImumMboxSettingsCtrl::ConstructL() |
|
185 { |
|
186 IMUM_CONTEXT( CImumMboxSettingsCtrl::ConstructL, 0, KLogData ); |
|
187 IMUM_IN(); |
|
188 |
|
189 iCenRepControl = CIMASCenRepControl::NewL(); |
|
190 iUtils = const_cast<MImumInMailboxUtilities*>( |
|
191 &iMailboxApi.MailboxUtilitiesL() ); |
|
192 |
|
193 FeatureManager::InitializeLibL(); |
|
194 iFFEmailVariation = |
|
195 FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework ); |
|
196 FeatureManager::UnInitializeLib(); |
|
197 |
|
198 IMUM_OUT(); |
|
199 } |
|
200 |
|
201 // ---------------------------------------------------------------------------- |
|
202 // CImumMboxSettingsCtrl::~CImumMboxSettingsCtrl() |
|
203 // ---------------------------------------------------------------------------- |
|
204 // |
|
205 CImumMboxSettingsCtrl::~CImumMboxSettingsCtrl() |
|
206 { |
|
207 IMUM_CONTEXT( CImumMboxSettingsCtrl::~CImumMboxSettingsCtrl, 0, KLogData ); |
|
208 IMUM_IN(); |
|
209 |
|
210 delete iCenRepSmtp; |
|
211 iCenRepSmtp = NULL; |
|
212 delete iCenRepExtMail; |
|
213 iCenRepExtMail = NULL; |
|
214 delete iCenRepAlwaysOnline; |
|
215 iCenRepAlwaysOnline = NULL; |
|
216 delete iCenRepDefaultData; |
|
217 iCenRepDefaultData = NULL; |
|
218 delete iAccounts; |
|
219 iAccounts = NULL; |
|
220 delete iCenRepControl; |
|
221 iCenRepControl = NULL; |
|
222 iUtils = NULL; |
|
223 |
|
224 IMUM_OUT(); |
|
225 } |
|
226 |
|
227 // ---------------------------------------------------------------------------- |
|
228 // CImumMboxSettingsCtrl::NewL() |
|
229 // ---------------------------------------------------------------------------- |
|
230 // |
|
231 CImumMboxSettingsCtrl* CImumMboxSettingsCtrl::NewL( |
|
232 CImumInternalApiImpl& aMailboxApi ) |
|
233 { |
|
234 IMUM_STATIC_CONTEXT( CImumMboxSettingsCtrl::NewL, 0, utils, KLogData ); |
|
235 IMUM_IN(); |
|
236 |
|
237 CImumMboxSettingsCtrl* self = NewLC( aMailboxApi ); |
|
238 CleanupStack::Pop( self ); |
|
239 |
|
240 IMUM_OUT(); |
|
241 return self; |
|
242 } |
|
243 |
|
244 // ---------------------------------------------------------------------------- |
|
245 // CImumMboxSettingsCtrl::NewLC() |
|
246 // ---------------------------------------------------------------------------- |
|
247 // |
|
248 CImumMboxSettingsCtrl* CImumMboxSettingsCtrl::NewLC( |
|
249 CImumInternalApiImpl& aMailboxApi ) |
|
250 { |
|
251 IMUM_STATIC_CONTEXT( CImumMboxSettingsCtrl::NewLC, 0, utils, KLogData ); |
|
252 |
|
253 CImumMboxSettingsCtrl* self = |
|
254 new ( ELeave ) CImumMboxSettingsCtrl( aMailboxApi ); |
|
255 CleanupStack::PushL( self ); |
|
256 self->ConstructL(); |
|
257 |
|
258 IMUM_OUT(); |
|
259 return self; |
|
260 } |
|
261 |
|
262 /****************************************************************************** |
|
263 |
|
264 PUBLIC: CREATING NEW ACCOUNT |
|
265 |
|
266 ******************************************************************************/ |
|
267 |
|
268 // ---------------------------------------------------------------------------- |
|
269 // CImumMboxSettingsCtrl::CreateSettings() |
|
270 // ---------------------------------------------------------------------------- |
|
271 // |
|
272 TInt CImumMboxSettingsCtrl::CreateSettings( |
|
273 const TMsvId aMailboxId, |
|
274 const TUint32 aAccountId, |
|
275 const TUid& aProtocol, |
|
276 CImumMboxDataExtension& aExtendedMailSettings, |
|
277 const TBool aPopulateDefaults ) |
|
278 { |
|
279 IMUM_CONTEXT( CImumMboxSettingsCtrl::CreateSettings, 0, KLogData ); |
|
280 IMUM_IN(); |
|
281 |
|
282 // Initialize the settings |
|
283 PreInitializeExtendedSettings( |
|
284 aMailboxId, aAccountId, aProtocol, aExtendedMailSettings ); |
|
285 |
|
286 TInt error = KErrNone; |
|
287 |
|
288 // Populate defaults |
|
289 if ( aPopulateDefaults ) |
|
290 { |
|
291 error = PopulateDefaultExtSettings( aExtendedMailSettings ); |
|
292 } |
|
293 |
|
294 // If populating has not failed, continue with creating the settings |
|
295 if ( error == KErrNone ) |
|
296 { |
|
297 // Create the settings |
|
298 TRAP( error, CreateSettingsL( aExtendedMailSettings ) ); |
|
299 } |
|
300 |
|
301 IMUM_OUT(); |
|
302 return error; |
|
303 } |
|
304 |
|
305 // ---------------------------------------------------------------------------- |
|
306 // CImumMboxSettingsCtrl::CreateSettings() |
|
307 // ---------------------------------------------------------------------------- |
|
308 // |
|
309 TInt CImumMboxSettingsCtrl::CreateSettings( |
|
310 const CImumMboxDataExtension& aExtendedMailSettings ) |
|
311 { |
|
312 IMUM_CONTEXT( CImumMboxSettingsCtrl::CreateSettings, 0, KLogData ); |
|
313 IMUM_IN(); |
|
314 |
|
315 TInt error = KErrNotReady; |
|
316 |
|
317 if ( aExtendedMailSettings.IsSettingsValid() ) |
|
318 { |
|
319 TRAP( error, CreateSettingsL( aExtendedMailSettings ) ); |
|
320 } |
|
321 |
|
322 IMUM_OUT(); |
|
323 return error; |
|
324 } |
|
325 |
|
326 // ---------------------------------------------------------------------------- |
|
327 // CImumMboxSettingsCtrl::PreInitializeExtendedSettings() |
|
328 // ---------------------------------------------------------------------------- |
|
329 // |
|
330 void CImumMboxSettingsCtrl::PreInitializeExtendedSettings( |
|
331 const TMsvId aMailboxId, |
|
332 const TUint32 aAccountId, |
|
333 const TUid& aProtocol, |
|
334 CImumMboxDataExtension& aExtendedMailSettings ) const |
|
335 { |
|
336 IMUM_CONTEXT( CImumMboxSettingsCtrl::PreInitializeExtendedSettings, 0, KLogData ); |
|
337 IMUM_IN(); |
|
338 |
|
339 // Pre-initialize the extended settings |
|
340 aExtendedMailSettings.SetMailboxId( aMailboxId ); |
|
341 aExtendedMailSettings.SetAccountId( aAccountId ); |
|
342 aExtendedMailSettings.SetProtocol( aProtocol ); |
|
343 aExtendedMailSettings.SetExtensionId( |
|
344 IMASAccountControl::AccountIdToExtendedAccountId( |
|
345 aAccountId, aProtocol ) ); |
|
346 |
|
347 IMUM_OUT(); |
|
348 } |
|
349 |
|
350 // ---------------------------------------------------------------------------- |
|
351 // CImumMboxSettingsCtrl::PopulateDefaultExtSettings() |
|
352 // ---------------------------------------------------------------------------- |
|
353 // |
|
354 TInt CImumMboxSettingsCtrl::PopulateDefaultExtSettings( |
|
355 CImumMboxDataExtension& aExtendedMailSettings ) const |
|
356 { |
|
357 IMUM_CONTEXT( CImumMboxSettingsCtrl::PopulateDefaultExtSettings, 0, KLogData ); |
|
358 IMUM_IN(); |
|
359 |
|
360 // Before setting default settings, make sure the settings is properly |
|
361 // initialized |
|
362 if ( !aExtendedMailSettings.IsSettingsValid() ) |
|
363 { |
|
364 // The setting information is not stored properly, using |
|
365 // the settings cannot be continued safely |
|
366 // PreInitializeExtendedSettings should be called before this |
|
367 IMUM0( 0, " *** MAILBOX EXTENDED SETTINGS FAILURE *** " ); |
|
368 |
|
369 __ASSERT_DEBUG( EFalse, |
|
370 User::Panic( KImumMtmUiPanic, KErrNotReady ) ); |
|
371 return KErrNotReady; |
|
372 } |
|
373 |
|
374 //emailnotificationstate is not set to default since its already done |
|
375 aExtendedMailSettings.SetNewMailIndicators( ETrue ); |
|
376 aExtendedMailSettings.SetHideMsgs( EFalse ); |
|
377 aExtendedMailSettings.SetOpenHtmlMail( EFalse ); |
|
378 aExtendedMailSettings.SetAlwaysOnlineState( EMailAoHomeOnly ); |
|
379 aExtendedMailSettings.SetSelectedWeekDays( KImumMboxDefaultAutoRetrievalDays ); |
|
380 aExtendedMailSettings.SetSelectedTimeStart( 0 ); |
|
381 aExtendedMailSettings.SetSelectedTimeStop( 0 ); |
|
382 aExtendedMailSettings.SetInboxRefreshTime( KIMASAoInterval1Hour ); |
|
383 aExtendedMailSettings.SetUpdateMode( EMailAoHeadersOnly ); |
|
384 aExtendedMailSettings.SetMailDeletion( EIMASMailDeletionAlwaysAsk ); |
|
385 TAOInfo emptyInfo = { EFalse, Time::NullTTime(), EFalse }; |
|
386 aExtendedMailSettings.SetLastUpdateInfo( emptyInfo ); |
|
387 aExtendedMailSettings.SetIsPredefined( KImumMboxDefaultIsPredefinedMailbox ); |
|
388 |
|
389 IMUM_OUT(); |
|
390 return KErrNone; |
|
391 } |
|
392 |
|
393 /****************************************************************************** |
|
394 |
|
395 PUBLIC: DELETING EXISTING ACCOUNT |
|
396 |
|
397 ******************************************************************************/ |
|
398 |
|
399 // ---------------------------------------------------------------------------- |
|
400 // CImumMboxSettingsCtrl::DeleteExtendedSettings() |
|
401 // ---------------------------------------------------------------------------- |
|
402 // |
|
403 TInt CImumMboxSettingsCtrl::DeleteExtendedSettings( |
|
404 const TIMAStorerParams& aParams ) |
|
405 { |
|
406 IMUM_CONTEXT( CImumMboxSettingsCtrl::DeleteExtendedSettings, 0, KLogData ); |
|
407 IMUM_IN(); |
|
408 // Make sure the mtm is valid email mtm |
|
409 TBool ok = iUtils->IsMailMtm( aParams.MtmId(), ETrue ); |
|
410 TInt error = KErrNotSupported; |
|
411 |
|
412 // Choose the right way to Create the settings |
|
413 if ( ok && aParams.AccountId() != KErrNone ) |
|
414 { |
|
415 TRAP( error, DeleteExtendedSettingsL( |
|
416 aParams.AccountId(), aParams.MtmId() ) ); |
|
417 } |
|
418 else if ( ok && aParams.MailboxId() != KErrNone ) |
|
419 { |
|
420 TRAP( error, DeleteExtendedSettingsL( |
|
421 aParams.MailboxId(), aParams.MtmId() ) ); |
|
422 } |
|
423 |
|
424 IMUM_OUT(); |
|
425 return error; |
|
426 } |
|
427 |
|
428 |
|
429 /****************************************************************************** |
|
430 |
|
431 PUBLIC: SAVING CURRENT ACCOUNT |
|
432 |
|
433 ******************************************************************************/ |
|
434 |
|
435 // ---------------------------------------------------------------------------- |
|
436 // CImumMboxSettingsCtrl::SaveSettings() |
|
437 // ---------------------------------------------------------------------------- |
|
438 // |
|
439 TInt CImumMboxSettingsCtrl::SaveSettings( |
|
440 const CImumMboxDataExtension& aExtendedMailSettings ) |
|
441 { |
|
442 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettings, 0, KLogData ); |
|
443 IMUM_IN(); |
|
444 TInt error = KErrNotReady; |
|
445 |
|
446 // Here it is good idea to make sure, that the settings are valid, so |
|
447 // no corrupted data is going in. |
|
448 if ( aExtendedMailSettings.IsSettingsValid() ) |
|
449 { |
|
450 TRAP( error, SaveSettingsL( aExtendedMailSettings ) ); |
|
451 } |
|
452 else |
|
453 { |
|
454 __ASSERT_DEBUG( EFalse, |
|
455 User::Panic( KImumMtmUiPanic, KErrNotReady ) ); |
|
456 } |
|
457 |
|
458 IMUM_OUT(); |
|
459 return error; |
|
460 } |
|
461 |
|
462 // ---------------------------------------------------------------------------- |
|
463 // CImumMboxSettingsCtrl::SaveSettings() |
|
464 // ---------------------------------------------------------------------------- |
|
465 // |
|
466 TInt CImumMboxSettingsCtrl::SaveSettings( |
|
467 const TUint32 aAccountId, |
|
468 const CImImap4Settings& aImap4Settings ) |
|
469 { |
|
470 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettings, 0, KLogData ); |
|
471 IMUM_IN(); |
|
472 |
|
473 TRAPD( error, SaveSettingsL( aAccountId, aImap4Settings ) ); |
|
474 |
|
475 IMUM_OUT(); |
|
476 return error; |
|
477 } |
|
478 |
|
479 // ---------------------------------------------------------------------------- |
|
480 // CImumMboxSettingsCtrl::SaveSettings() |
|
481 // ---------------------------------------------------------------------------- |
|
482 // |
|
483 TInt CImumMboxSettingsCtrl::SaveSettings( |
|
484 const TUint32 aAccountId, |
|
485 const CImPop3Settings& aPop3Settings ) |
|
486 { |
|
487 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettings, 0, KLogData ); |
|
488 IMUM_IN(); |
|
489 |
|
490 TRAPD( error, SaveSettingsL( aAccountId, aPop3Settings ) ); |
|
491 |
|
492 IMUM_OUT(); |
|
493 return error; |
|
494 } |
|
495 |
|
496 // ---------------------------------------------------------------------------- |
|
497 // CImumMboxSettingsCtrl::SaveSettings() |
|
498 // ---------------------------------------------------------------------------- |
|
499 // |
|
500 TInt CImumMboxSettingsCtrl::SaveSettings( |
|
501 const TUint32 aAccountId, |
|
502 const CImSmtpSettings& aSmtpSettings ) |
|
503 { |
|
504 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettings, 0, KLogData ); |
|
505 IMUM_IN(); |
|
506 |
|
507 TRAPD( error, SaveSettingsL( aAccountId, aSmtpSettings ) ); |
|
508 |
|
509 IMUM_OUT(); |
|
510 return error; |
|
511 } |
|
512 |
|
513 // ---------------------------------------------------------------------------- |
|
514 // CImumMboxSettingsCtrl::SaveSettings() |
|
515 // ---------------------------------------------------------------------------- |
|
516 // |
|
517 TInt CImumMboxSettingsCtrl::SaveSettings( |
|
518 const TMsvId aMailboxId, |
|
519 const CImImap4Settings& aImap4Settings ) |
|
520 { |
|
521 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettings, 0, KLogData ); |
|
522 IMUM_IN(); |
|
523 |
|
524 TRAPD( error, SaveSettingsL( aMailboxId, aImap4Settings ) ); |
|
525 |
|
526 IMUM_OUT(); |
|
527 return error; |
|
528 } |
|
529 |
|
530 // ---------------------------------------------------------------------------- |
|
531 // CImumMboxSettingsCtrl::SaveSettings() |
|
532 // ---------------------------------------------------------------------------- |
|
533 // |
|
534 TInt CImumMboxSettingsCtrl::SaveSettings( |
|
535 const TMsvId aMailboxId, |
|
536 const CImPop3Settings& aPop3Settings ) |
|
537 { |
|
538 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettings, 0, KLogData ); |
|
539 IMUM_IN(); |
|
540 |
|
541 TRAPD( error, SaveSettingsL( aMailboxId, aPop3Settings ) ); |
|
542 |
|
543 IMUM_OUT(); |
|
544 return error; |
|
545 } |
|
546 |
|
547 // ---------------------------------------------------------------------------- |
|
548 // CImumMboxSettingsCtrl::SaveSettings() |
|
549 // ---------------------------------------------------------------------------- |
|
550 // |
|
551 TInt CImumMboxSettingsCtrl::SaveSettings( |
|
552 const TMsvId aMailboxId, |
|
553 const CImSmtpSettings& aSmtpSettings ) |
|
554 { |
|
555 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettings, 0, KLogData ); |
|
556 IMUM_IN(); |
|
557 |
|
558 TRAPD( error, SaveSettingsL( aMailboxId, aSmtpSettings ) ); |
|
559 |
|
560 IMUM_OUT(); |
|
561 return error; |
|
562 } |
|
563 |
|
564 // ---------------------------------------------------------------------------- |
|
565 // CImumMboxSettingsCtrl::SaveSettings() |
|
566 // ---------------------------------------------------------------------------- |
|
567 // |
|
568 TInt CImumMboxSettingsCtrl::SaveSettings( |
|
569 const TMsvEntry& aEntry, |
|
570 CImBaseEmailSettings& aBaseSettings ) |
|
571 { |
|
572 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettings, 0, KLogData ); |
|
573 IMUM_IN(); |
|
574 |
|
575 TRAPD( error, SaveSettingsL( aEntry, aBaseSettings ) ); |
|
576 |
|
577 IMUM_OUT(); |
|
578 return error; |
|
579 } |
|
580 |
|
581 /****************************************************************************** |
|
582 |
|
583 PUBLIC: LOADING EXISTING ACCOUNT |
|
584 |
|
585 ******************************************************************************/ |
|
586 |
|
587 // ---------------------------------------------------------------------------- |
|
588 // CImumMboxSettingsCtrl::LoadSettings() |
|
589 // ---------------------------------------------------------------------------- |
|
590 // |
|
591 TInt CImumMboxSettingsCtrl::LoadSettings( |
|
592 const TIMAStorerParams& aParams, |
|
593 CImumMboxDataExtension& aExtendedMailSettings ) |
|
594 { |
|
595 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettings, 0, KLogData ); |
|
596 IMUM3_IN( "aParams.iMtmId = 0x%x, aParams.iAccountId = 0x%x, aParams.iMailboxId = 0x%x", |
|
597 aParams.MtmId(), aParams.AccountId(), aParams.MailboxId() ); |
|
598 |
|
599 // Make sure the mtm is valid email mtm |
|
600 TBool ok = iUtils->IsMailMtm( aParams.MtmId(), ETrue ); |
|
601 |
|
602 // Choose the right way to Load the settings |
|
603 if ( ok && aParams.AccountId() != KErrNone ) |
|
604 { |
|
605 TRAPD( error, LoadSettingsL( |
|
606 aParams.AccountId(), aParams.MtmId(), aExtendedMailSettings ) ); |
|
607 IMUM_OUT(); |
|
608 return error; |
|
609 } |
|
610 else if ( ok && aParams.MailboxId() != KErrNone ) |
|
611 { |
|
612 TRAPD( error, LoadSettingsL( |
|
613 aParams.MailboxId(), aParams.MtmId(), aExtendedMailSettings ) ); |
|
614 IMUM_OUT(); |
|
615 return error; |
|
616 } |
|
617 else |
|
618 { |
|
619 IMUM_OUT(); |
|
620 return KErrNotSupported; |
|
621 } |
|
622 |
|
623 } |
|
624 |
|
625 // ---------------------------------------------------------------------------- |
|
626 // CImumMboxSettingsCtrl::LoadSettings() |
|
627 // ---------------------------------------------------------------------------- |
|
628 // |
|
629 TInt CImumMboxSettingsCtrl::LoadSettings( |
|
630 const TUint32 aAccountId, |
|
631 CImImap4Settings& aImap4Settings ) |
|
632 { |
|
633 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettings, 0, KLogData ); |
|
634 IMUM_IN(); |
|
635 |
|
636 TRAPD( error, LoadSettingsL( aAccountId, aImap4Settings ) ); |
|
637 |
|
638 IMUM_OUT(); |
|
639 return error; |
|
640 } |
|
641 |
|
642 // ---------------------------------------------------------------------------- |
|
643 // CImumMboxSettingsCtrl::LoadSettings() |
|
644 // ---------------------------------------------------------------------------- |
|
645 // |
|
646 TInt CImumMboxSettingsCtrl::LoadSettings( |
|
647 const TUint32 aAccountId, |
|
648 CImPop3Settings& aPop3Settings ) |
|
649 { |
|
650 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettings, 0, KLogData ); |
|
651 IMUM_IN(); |
|
652 |
|
653 TRAPD( error, LoadSettingsL( aAccountId, aPop3Settings ) ); |
|
654 |
|
655 IMUM_OUT(); |
|
656 return error; |
|
657 } |
|
658 |
|
659 // ---------------------------------------------------------------------------- |
|
660 // CImumMboxSettingsCtrl::LoadSettings() |
|
661 // ---------------------------------------------------------------------------- |
|
662 // |
|
663 TInt CImumMboxSettingsCtrl::LoadSettings( |
|
664 const TUint32 aAccountId, |
|
665 CImSmtpSettings& aSmtpSettings ) |
|
666 { |
|
667 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettings, 0, KLogData ); |
|
668 IMUM_IN(); |
|
669 |
|
670 TRAPD( error, LoadSettingsL( aAccountId, aSmtpSettings ) ); |
|
671 |
|
672 IMUM_OUT(); |
|
673 return error; |
|
674 } |
|
675 |
|
676 // ---------------------------------------------------------------------------- |
|
677 // CImumMboxSettingsCtrl::LoadSettings() |
|
678 // ---------------------------------------------------------------------------- |
|
679 // |
|
680 TInt CImumMboxSettingsCtrl::LoadSettings( |
|
681 const TMsvId aMailboxId, |
|
682 CImImap4Settings& aImap4Settings ) |
|
683 { |
|
684 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettings, 0, KLogData ); |
|
685 IMUM_IN(); |
|
686 |
|
687 TRAPD( error, LoadSettingsL( aMailboxId, aImap4Settings ) ); |
|
688 |
|
689 IMUM_OUT(); |
|
690 return error; |
|
691 } |
|
692 |
|
693 // ---------------------------------------------------------------------------- |
|
694 // CImumMboxSettingsCtrl::LoadSettings() |
|
695 // ---------------------------------------------------------------------------- |
|
696 // |
|
697 TInt CImumMboxSettingsCtrl::LoadSettings( |
|
698 const TMsvId aMailboxId, |
|
699 CImPop3Settings& aPop3Settings ) |
|
700 { |
|
701 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettings, 0, KLogData ); |
|
702 IMUM_IN(); |
|
703 |
|
704 TRAPD( error, LoadSettingsL( aMailboxId, aPop3Settings ) ); |
|
705 |
|
706 IMUM_OUT(); |
|
707 return error; |
|
708 } |
|
709 |
|
710 // ---------------------------------------------------------------------------- |
|
711 // CImumMboxSettingsCtrl::LoadSettings() |
|
712 // ---------------------------------------------------------------------------- |
|
713 // |
|
714 TInt CImumMboxSettingsCtrl::LoadSettings( |
|
715 const TMsvId aMailboxId, |
|
716 CImSmtpSettings& aSmtpSettings ) |
|
717 { |
|
718 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettings, 0, KLogData ); |
|
719 IMUM_IN(); |
|
720 |
|
721 TRAPD( error, LoadSettingsL( aMailboxId, aSmtpSettings ) ); |
|
722 |
|
723 IMUM_OUT(); |
|
724 return error; |
|
725 } |
|
726 |
|
727 // ---------------------------------------------------------------------------- |
|
728 // CImumMboxSettingsCtrl::LoadSettings() |
|
729 // ---------------------------------------------------------------------------- |
|
730 // |
|
731 TInt CImumMboxSettingsCtrl::LoadSettings( |
|
732 const TMsvEntry& aEntry, |
|
733 CImBaseEmailSettings& aBaseSettings ) |
|
734 { |
|
735 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettings, 0, KLogData ); |
|
736 IMUM_IN(); |
|
737 |
|
738 TRAPD( error, LoadSettingsL( aEntry, aBaseSettings ) ); |
|
739 |
|
740 IMUM_OUT(); |
|
741 return error; |
|
742 } |
|
743 // ---------------------------------------------------------------------------- |
|
744 // CImumMboxSettingsCtrl::AccountId2ExtensionId() |
|
745 // ---------------------------------------------------------------------------- |
|
746 // |
|
747 TUint32 CImumMboxSettingsCtrl::AccountId2ExtensionId( |
|
748 const TUint32 aAccountId, |
|
749 const TUid& aMtmId ) const |
|
750 { |
|
751 IMUM_CONTEXT( CImumMboxSettingsCtrl::AccountId2ExtensionId, 0, KLogData ); |
|
752 IMUM_IN(); |
|
753 |
|
754 IMUM_OUT(); |
|
755 return IMASAccountControl::AccountIdToExtendedAccountId( |
|
756 aAccountId, aMtmId ); |
|
757 } |
|
758 |
|
759 // ---------------------------------------------------------------------------- |
|
760 // CImumMboxSettingsCtrl::ExtensionId2AccountId() |
|
761 // ---------------------------------------------------------------------------- |
|
762 // |
|
763 TUint32 CImumMboxSettingsCtrl::ExtensionId2AccountId( |
|
764 const TUint32 aExtension, |
|
765 const TUid& aMtmId ) const |
|
766 { |
|
767 IMUM_CONTEXT( CImumMboxSettingsCtrl::ExtensionId2AccountId, 0, KLogData ); |
|
768 IMUM_IN(); |
|
769 |
|
770 IMUM_OUT(); |
|
771 return IMASAccountControl::ExtendedAccountIdToAccountId( |
|
772 aExtension, aMtmId ); |
|
773 } |
|
774 |
|
775 /****************************************************************************** |
|
776 |
|
777 PUBLIC: RESTORE DEFAULT DATA |
|
778 |
|
779 ******************************************************************************/ |
|
780 |
|
781 // ---------------------------------------------------------------------------- |
|
782 // CImumMboxSettingsCtrl::RestoreDefaultSettingsDataL() |
|
783 // ---------------------------------------------------------------------------- |
|
784 // |
|
785 void CImumMboxSettingsCtrl::RestoreDefaultSettingsDataL( |
|
786 CImumMboxDefaultData& aDefaultData ) |
|
787 { |
|
788 IMUM_CONTEXT( CImumMboxSettingsCtrl::RestoreDefaultSettingsDataL, 0, KLogData ); |
|
789 IMUM_IN(); |
|
790 |
|
791 // Make sure there is connection to repository |
|
792 MsvEmailMtmUiUtils::CreateCenRepConnectionL( |
|
793 iCenRepDefaultData, KCRUidImum ); |
|
794 |
|
795 // Prepare default data reading |
|
796 iCenRepControl->SetActiveCentralRepository( *iCenRepDefaultData ); |
|
797 iCenRepControl->SetActiveDefaultDataKey(); |
|
798 |
|
799 // Begin filling the value |
|
800 TInt value = iCenRepControl->GetFromAccountL( |
|
801 KImumDownloadBufferSizeOther ); |
|
802 aDefaultData.SetAttr( |
|
803 TImumInSettings::EKeyDownloadBufferGprs, value ); |
|
804 |
|
805 value = iCenRepControl->GetFromAccountL( |
|
806 KImumDownloadBufferSizeWlan ); |
|
807 aDefaultData.SetAttr( |
|
808 TImumInSettings::EKeyDownloadBufferWlan, value ); |
|
809 |
|
810 IMUM_OUT(); |
|
811 } |
|
812 |
|
813 /****************************************************************************** |
|
814 |
|
815 PRIVATE: CREATING NEW ACCOUNT |
|
816 |
|
817 ******************************************************************************/ |
|
818 |
|
819 // ---------------------------------------------------------------------------- |
|
820 // CImumMboxSettingsCtrl::CreateSettingsL() |
|
821 // ---------------------------------------------------------------------------- |
|
822 // |
|
823 void CImumMboxSettingsCtrl::CreateSettingsL( |
|
824 const CImumMboxDataExtension& aExtendedMailSettings ) |
|
825 { |
|
826 IMUM_CONTEXT( CImumMboxSettingsCtrl::CreateSettingsL, 0, KLogData ); |
|
827 IMUM_IN(); |
|
828 |
|
829 // Make sure there is connection to repository |
|
830 MsvEmailMtmUiUtils::CreateCenRepConnectionL( |
|
831 iCenRepExtMail, KCRUidImumSettings ); |
|
832 |
|
833 // Prepare account control |
|
834 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
835 iCenRepControl->SetActiveBaseKey( aExtendedMailSettings.ExtensionId() ); |
|
836 |
|
837 // Create the settings |
|
838 // Common Settings |
|
839 CreateExtendedSettingsStatusFlagsL( aExtendedMailSettings ); |
|
840 iCenRepControl->CreateToAccountL( EImaCommonSetMailboxId, |
|
841 aExtendedMailSettings.MailboxId() ); |
|
842 iCenRepControl->CreateToAccountL( EImaCommonSetAccountId, |
|
843 static_cast<TInt>( aExtendedMailSettings.AccountId() ) ); |
|
844 iCenRepControl->CreateToAccountL( EImaCommonSetExtensionId, |
|
845 static_cast<TInt>( aExtendedMailSettings.ExtensionId() ) ); |
|
846 iCenRepControl->CreateToAccountL( EImaCommonSetProtocol, |
|
847 aExtendedMailSettings.Protocol().iUid ); |
|
848 iCenRepControl->CreateToAccountL( EImaCommonSetEmailAddress, |
|
849 *aExtendedMailSettings.EmailAddress() ); |
|
850 |
|
851 // Extended mailbox settings |
|
852 iCenRepControl->CreateToAccountL( EImaExtSetEmailNotif, |
|
853 static_cast<TInt>( aExtendedMailSettings.EmailNotificationState() ) ); |
|
854 iCenRepControl->CreateToAccountL( EImaExtSetIndicators, |
|
855 static_cast<TBool>( aExtendedMailSettings.NewMailIndicators() ) ); |
|
856 iCenRepControl->CreateToAccountL( EImaExtSetHideMsgs, |
|
857 static_cast<TInt>( aExtendedMailSettings.HideMsgs() ) ); |
|
858 iCenRepControl->CreateToAccountL( EImaExtSetOpenHtmlMail, |
|
859 static_cast<TInt>( aExtendedMailSettings.OpenHtmlMail() ) ); |
|
860 iCenRepControl->CreateToAccountL( EImaExtSetMailDeletion, |
|
861 static_cast<TInt>( aExtendedMailSettings.MailDeletion() ) ); |
|
862 iCenRepControl->CreateToAccountL( EImaExtIsPredefined, |
|
863 static_cast<TInt>( aExtendedMailSettings.IsPredefined() ) ); |
|
864 |
|
865 // Always Online Settings |
|
866 iCenRepControl->CreateToAccountL( EImaAoVersion, |
|
867 aExtendedMailSettings.Version() ); |
|
868 iCenRepControl->CreateToAccountL( EImaAoOnlineState, |
|
869 aExtendedMailSettings.AlwaysOnlineState() ); |
|
870 iCenRepControl->CreateToAccountL( EImaAoWeekDays, |
|
871 aExtendedMailSettings.SelectedWeekDays() ); |
|
872 iCenRepControl->CreateToAccountL( EImaAoTimeStartH, EImaAoTimeStartL, |
|
873 aExtendedMailSettings.SelectedTimeStart().Int64() ); |
|
874 iCenRepControl->CreateToAccountL( EImaAoTimeStopH, EImaAoTimeStopL, |
|
875 aExtendedMailSettings.SelectedTimeStop().Int64() ); |
|
876 iCenRepControl->CreateToAccountL( EImaAoInboxRefreshTime, |
|
877 aExtendedMailSettings.InboxRefreshTime() ); |
|
878 iCenRepControl->CreateToAccountL( EImaAoUpdateMode, |
|
879 aExtendedMailSettings.UpdateMode() ); |
|
880 |
|
881 CreateLastUpdateInfoL( aExtendedMailSettings.LastUpdateInfo() ); |
|
882 |
|
883 IMUM_OUT(); |
|
884 } |
|
885 |
|
886 /****************************************************************************** |
|
887 |
|
888 PRIVATE: DELETING EXISTING ACCOUNT |
|
889 |
|
890 ******************************************************************************/ |
|
891 |
|
892 // ---------------------------------------------------------------------------- |
|
893 // CImumMboxSettingsCtrl::DeleteExtendedSettingsL() |
|
894 // ---------------------------------------------------------------------------- |
|
895 // |
|
896 void CImumMboxSettingsCtrl::DeleteExtendedSettingsL( |
|
897 const TMsvId aMailboxId, |
|
898 const TUid& aMtmId ) |
|
899 { |
|
900 IMUM_CONTEXT( CImumMboxSettingsCtrl::DeleteExtendedSettingsL, 0, KLogData ); |
|
901 IMUM_IN(); |
|
902 |
|
903 // Get the correct accountId and continue opening the settings |
|
904 TUint32 accountId = |
|
905 IMASAccountControl::MailboxIdToAccountIdL( aMailboxId, aMtmId ); |
|
906 DeleteExtendedSettingsL( accountId, aMtmId ); |
|
907 IMUM_OUT(); |
|
908 } |
|
909 |
|
910 // ---------------------------------------------------------------------------- |
|
911 // CImumMboxSettingsCtrl::DeleteExtendedSettingsL() |
|
912 // ---------------------------------------------------------------------------- |
|
913 // |
|
914 void CImumMboxSettingsCtrl::DeleteExtendedSettingsL( |
|
915 const TUint32 aAccountId, |
|
916 const TUid& aMtmId ) |
|
917 { |
|
918 IMUM_CONTEXT( CImumMboxSettingsCtrl::DeleteExtendedSettingsL, 0, KLogData ); |
|
919 IMUM_IN(); |
|
920 |
|
921 // Make sure there is connection to repository |
|
922 MsvEmailMtmUiUtils::CreateCenRepConnectionL( |
|
923 iCenRepExtMail, KCRUidImumSettings ); |
|
924 |
|
925 // Prepare account control |
|
926 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
927 iCenRepControl->SetActiveBaseKey( aAccountId, aMtmId ); |
|
928 |
|
929 // Create the settings |
|
930 // Common Settings |
|
931 iCenRepControl->DeleteFromAccountL( |
|
932 EImaCommonSetStatusFlagsH, EImaCommonSetStatusFlagsL ); |
|
933 iCenRepControl->DeleteFromAccountL( EImaCommonSetMailboxId ); |
|
934 iCenRepControl->DeleteFromAccountL( EImaCommonSetAccountId ); |
|
935 iCenRepControl->DeleteFromAccountL( EImaCommonSetExtensionId ); |
|
936 iCenRepControl->DeleteFromAccountL( EImaCommonSetProtocol ); |
|
937 iCenRepControl->DeleteFromAccountL( EImaCommonSetEmailAddress ); |
|
938 |
|
939 // Extended mailbox settings |
|
940 iCenRepControl->DeleteFromAccountL( EImaExtSetEmailNotif ); |
|
941 iCenRepControl->DeleteFromAccountL( EImaExtSetIndicators ); |
|
942 iCenRepControl->DeleteFromAccountL( EImaExtSetHideMsgs ); |
|
943 iCenRepControl->DeleteFromAccountL( EImaExtSetOpenHtmlMail ); |
|
944 iCenRepControl->DeleteFromAccountL( EImaExtSetMailDeletion ); |
|
945 iCenRepControl->DeleteFromAccountL( EImaExtIsPredefined ); |
|
946 |
|
947 // Always Online Settings |
|
948 iCenRepControl->DeleteFromAccountL( EImaAoVersion ); |
|
949 iCenRepControl->DeleteFromAccountL( EImaAoOnlineState ); |
|
950 iCenRepControl->DeleteFromAccountL( EImaAoWeekDays ); |
|
951 iCenRepControl->DeleteFromAccountL( EImaAoTimeStartH, EImaAoTimeStartL ); |
|
952 iCenRepControl->DeleteFromAccountL( EImaAoTimeStopH, EImaAoTimeStopL ); |
|
953 iCenRepControl->DeleteFromAccountL( EImaAoInboxRefreshTime ); |
|
954 iCenRepControl->DeleteFromAccountL( EImaAoUpdateMode ); |
|
955 DeleteLastUpdateInfo(); |
|
956 |
|
957 IMUM_OUT(); |
|
958 } |
|
959 |
|
960 /****************************************************************************** |
|
961 |
|
962 PRIVATE: SAVING CURRENT ACCOUNT |
|
963 |
|
964 ******************************************************************************/ |
|
965 |
|
966 // ---------------------------------------------------------------------------- |
|
967 // CImumMboxSettingsCtrl::SaveSettingsL() |
|
968 // ---------------------------------------------------------------------------- |
|
969 // |
|
970 void CImumMboxSettingsCtrl::SaveSettingsL( |
|
971 const CImumMboxDataExtension& aExtendedMailSettings ) |
|
972 { |
|
973 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettingsL, 0, KLogData ); |
|
974 IMUM_IN(); |
|
975 |
|
976 // Make sure there is connection to repository |
|
977 MsvEmailMtmUiUtils::CreateCenRepConnectionL( |
|
978 iCenRepExtMail, KCRUidImumSettings ); |
|
979 |
|
980 // Prepare account control |
|
981 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
982 iCenRepControl->SetActiveBaseKey( aExtendedMailSettings.ExtensionId() ); |
|
983 |
|
984 // Store the settings |
|
985 // Common Settings |
|
986 SaveExtendedSettingsStatusFlagsL( aExtendedMailSettings ); |
|
987 iCenRepControl->SetToAccountL( EImaCommonSetMailboxId, |
|
988 aExtendedMailSettings.MailboxId() ); |
|
989 iCenRepControl->SetToAccountL( EImaCommonSetAccountId, |
|
990 static_cast<TInt>( aExtendedMailSettings.AccountId() ) ); |
|
991 iCenRepControl->SetToAccountL( EImaCommonSetExtensionId, |
|
992 static_cast<TInt>( aExtendedMailSettings.ExtensionId() ) ); |
|
993 iCenRepControl->SetToAccountL( EImaCommonSetProtocol, |
|
994 aExtendedMailSettings.Protocol().iUid ); |
|
995 iCenRepControl->SetToAccountL( EImaCommonSetEmailAddress, |
|
996 *aExtendedMailSettings.EmailAddress() ); |
|
997 |
|
998 // Extended mailbox settings |
|
999 iCenRepControl->SetToAccountL( EImaExtSetEmailNotif, |
|
1000 static_cast<TInt>( aExtendedMailSettings.EmailNotificationState() ) ); |
|
1001 iCenRepControl->SetToAccountL( EImaExtSetIndicators, |
|
1002 static_cast<TBool>( aExtendedMailSettings.NewMailIndicators() ) ); |
|
1003 iCenRepControl->SetToAccountL( EImaExtSetHideMsgs, |
|
1004 static_cast<TInt>( aExtendedMailSettings.HideMsgs() ) ); |
|
1005 iCenRepControl->SetToAccountL( EImaExtSetOpenHtmlMail, |
|
1006 static_cast<TBool>( aExtendedMailSettings.OpenHtmlMail() ) ); |
|
1007 iCenRepControl->SetToAccountL( EImaExtSetMailDeletion, |
|
1008 static_cast<TInt>( aExtendedMailSettings.MailDeletion() ) ); |
|
1009 iCenRepControl->SetToAccountL( EImaExtIsPredefined, |
|
1010 static_cast<TInt>( aExtendedMailSettings.IsPredefined() ) ); |
|
1011 |
|
1012 // Always Online Settings |
|
1013 iCenRepControl->SetToAccountL( EImaAoVersion, |
|
1014 aExtendedMailSettings.Version() ); |
|
1015 iCenRepControl->SetToAccountL( EImaAoOnlineState, |
|
1016 aExtendedMailSettings.AlwaysOnlineState() ); |
|
1017 iCenRepControl->SetToAccountL( EImaAoWeekDays, |
|
1018 aExtendedMailSettings.SelectedWeekDays() ); |
|
1019 iCenRepControl->SetToAccountL( EImaAoTimeStartH, EImaAoTimeStartL, |
|
1020 aExtendedMailSettings.SelectedTimeStart().Int64() ); |
|
1021 iCenRepControl->SetToAccountL( EImaAoTimeStopH, EImaAoTimeStopL, |
|
1022 aExtendedMailSettings.SelectedTimeStop().Int64() ); |
|
1023 iCenRepControl->SetToAccountL( EImaAoInboxRefreshTime, |
|
1024 aExtendedMailSettings.InboxRefreshTime() ); |
|
1025 iCenRepControl->SetToAccountL( EImaAoUpdateMode, |
|
1026 aExtendedMailSettings.UpdateMode() ); |
|
1027 |
|
1028 SaveLastUpdateInfo( aExtendedMailSettings.LastUpdateInfo() ); |
|
1029 |
|
1030 IMUM_OUT(); |
|
1031 } |
|
1032 |
|
1033 // ---------------------------------------------------------------------------- |
|
1034 // CImumMboxSettingsCtrl::SaveSettingsL() |
|
1035 // ---------------------------------------------------------------------------- |
|
1036 // |
|
1037 void CImumMboxSettingsCtrl::SaveSettingsL( |
|
1038 const TUint32 aAccountId, |
|
1039 const CImImap4Settings& aImap4Settings ) |
|
1040 { |
|
1041 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettingsL, 0, KLogData ); |
|
1042 IMUM_IN(); |
|
1043 |
|
1044 TImapAccount imapAccountId; |
|
1045 imapAccountId.iImapAccountId = aAccountId; |
|
1046 |
|
1047 AccountsL()->SaveImapSettingsL( imapAccountId, aImap4Settings ); |
|
1048 |
|
1049 IMUM_OUT(); |
|
1050 } |
|
1051 |
|
1052 // ---------------------------------------------------------------------------- |
|
1053 // CImumMboxSettingsCtrl::SaveSettingsL() |
|
1054 // ---------------------------------------------------------------------------- |
|
1055 // |
|
1056 void CImumMboxSettingsCtrl::SaveSettingsL( |
|
1057 const TUint32 aAccountId, |
|
1058 const CImPop3Settings& aPop3Settings ) |
|
1059 { |
|
1060 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettingsL, 0, KLogData ); |
|
1061 IMUM_IN(); |
|
1062 |
|
1063 TPopAccount popAccountId; |
|
1064 popAccountId.iPopAccountId = aAccountId; |
|
1065 |
|
1066 AccountsL()->SavePopSettingsL( popAccountId, aPop3Settings ); |
|
1067 |
|
1068 IMUM_OUT(); |
|
1069 } |
|
1070 |
|
1071 // ---------------------------------------------------------------------------- |
|
1072 // CImumMboxSettingsCtrl::SaveSettingsL() |
|
1073 // ---------------------------------------------------------------------------- |
|
1074 // |
|
1075 void CImumMboxSettingsCtrl::SaveSettingsL( |
|
1076 const TUint32 aAccountId, |
|
1077 const CImSmtpSettings& aSmtpSettings ) |
|
1078 { |
|
1079 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettingsL, 0, KLogData ); |
|
1080 IMUM_IN(); |
|
1081 |
|
1082 TSmtpAccount smtpAccountId; |
|
1083 smtpAccountId.iSmtpAccountId = aAccountId; |
|
1084 |
|
1085 AccountsL()->SaveSmtpSettingsL( smtpAccountId, aSmtpSettings ); |
|
1086 |
|
1087 IMUM_OUT(); |
|
1088 } |
|
1089 |
|
1090 // ---------------------------------------------------------------------------- |
|
1091 // CImumMboxSettingsCtrl::SaveSettingsL() |
|
1092 // ---------------------------------------------------------------------------- |
|
1093 // |
|
1094 void CImumMboxSettingsCtrl::SaveSettingsL( |
|
1095 const TMsvId aMailboxId, |
|
1096 const CImImap4Settings& aImap4Settings ) |
|
1097 { |
|
1098 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettingsL, 0, KLogData ); |
|
1099 IMUM_IN(); |
|
1100 |
|
1101 TImapAccount imapAccountId; |
|
1102 AccountsL()->GetImapAccountL( aMailboxId, imapAccountId ); |
|
1103 iAccounts->SaveImapSettingsL( imapAccountId, aImap4Settings ); |
|
1104 |
|
1105 IMUM_OUT(); |
|
1106 } |
|
1107 |
|
1108 // ---------------------------------------------------------------------------- |
|
1109 // CImumMboxSettingsCtrl::SaveSettingsL() |
|
1110 // ---------------------------------------------------------------------------- |
|
1111 // |
|
1112 void CImumMboxSettingsCtrl::SaveSettingsL( |
|
1113 const TMsvId aMailboxId, |
|
1114 const CImPop3Settings& aPop3Settings ) |
|
1115 { |
|
1116 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettingsL, 0, KLogData ); |
|
1117 IMUM_IN(); |
|
1118 |
|
1119 TPopAccount popAccountId; |
|
1120 AccountsL()->GetPopAccountL( aMailboxId, popAccountId ); |
|
1121 iAccounts->SavePopSettingsL( popAccountId, aPop3Settings ); |
|
1122 |
|
1123 IMUM_OUT(); |
|
1124 } |
|
1125 |
|
1126 // ---------------------------------------------------------------------------- |
|
1127 // CImumMboxSettingsCtrl::SaveSettingsL() |
|
1128 // ---------------------------------------------------------------------------- |
|
1129 // |
|
1130 void CImumMboxSettingsCtrl::SaveSettingsL( |
|
1131 const TMsvId aMailboxId, |
|
1132 const CImSmtpSettings& aSmtpSettings ) |
|
1133 { |
|
1134 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettingsL, 0, KLogData ); |
|
1135 IMUM_IN(); |
|
1136 |
|
1137 TSmtpAccount smtpAccountId; |
|
1138 AccountsL()->GetSmtpAccountL( aMailboxId, smtpAccountId ); |
|
1139 iAccounts->SaveSmtpSettingsL( smtpAccountId, aSmtpSettings ); |
|
1140 |
|
1141 IMUM_OUT(); |
|
1142 } |
|
1143 |
|
1144 // ---------------------------------------------------------------------------- |
|
1145 // CImumMboxSettingsCtrl::SaveSettingsL() |
|
1146 // ---------------------------------------------------------------------------- |
|
1147 // |
|
1148 void CImumMboxSettingsCtrl::SaveSettingsL( |
|
1149 const TMsvEntry& aEntry, |
|
1150 CImBaseEmailSettings& aBaseSettings ) |
|
1151 { |
|
1152 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveSettingsL, 0, KLogData ); |
|
1153 IMUM_IN(); |
|
1154 |
|
1155 // Save the correct settings based on the MTM uid |
|
1156 switch( aEntry.iMtm.iUid ) |
|
1157 { |
|
1158 // SMTP |
|
1159 case KSenduiMtmSmtpUidValue: |
|
1160 SaveSettingsL( aEntry.Id(), |
|
1161 *static_cast<CImSmtpSettings*>( &aBaseSettings ) ); |
|
1162 break; |
|
1163 |
|
1164 // POP3 |
|
1165 case KSenduiMtmPop3UidValue: |
|
1166 SaveSettingsL( aEntry.Id(), |
|
1167 *static_cast<CImPop3Settings*>( &aBaseSettings ) ); |
|
1168 break; |
|
1169 |
|
1170 // IMAP4 |
|
1171 case KSenduiMtmImap4UidValue: |
|
1172 SaveSettingsL( aEntry.Id(), |
|
1173 *static_cast<CImImap4Settings*>( &aBaseSettings ) ); |
|
1174 break; |
|
1175 |
|
1176 default: |
|
1177 User::Leave( KErrUnknown ); |
|
1178 break; |
|
1179 } |
|
1180 IMUM_OUT(); |
|
1181 } |
|
1182 |
|
1183 /****************************************************************************** |
|
1184 |
|
1185 PRIVATE: LOADING EXISTING ACCOUNT |
|
1186 |
|
1187 ******************************************************************************/ |
|
1188 |
|
1189 // ---------------------------------------------------------------------------- |
|
1190 // CImumMboxSettingsCtrl::LoadSettings() |
|
1191 // ---------------------------------------------------------------------------- |
|
1192 // |
|
1193 void CImumMboxSettingsCtrl::LoadSettingsL( |
|
1194 const TUint32 aAccountId, |
|
1195 const TUid& aMtmId, |
|
1196 CImumMboxDataExtension& aExtendedMailSettings ) |
|
1197 { |
|
1198 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettingsL, 0, KLogData ); |
|
1199 IMUM_IN(); |
|
1200 |
|
1201 // Try to open the settings |
|
1202 TRAPD( error, OpenExtendedSettingsL( |
|
1203 TIMAStorerParams( aAccountId, aMtmId ), aExtendedMailSettings ) ); |
|
1204 |
|
1205 // It's possible to create the email settings without defining the |
|
1206 // extended settings. If that is the case, create the extended mailsettings |
|
1207 // for the mailbox. CMail will handle initialization of extended settings |
|
1208 // if it's installed. |
|
1209 if ( !iFFEmailVariation && error == KErrNotFound ) |
|
1210 { |
|
1211 TMsvId mailboxId = IMASAccountControl::AccountIdToMailboxId( |
|
1212 *AccountsL(), aAccountId, aMtmId ); |
|
1213 error = CreateSettings( |
|
1214 mailboxId, aAccountId, aMtmId, aExtendedMailSettings ); |
|
1215 //If AlwaysOnline or EmailNotification is switched on we need to activate it |
|
1216 if ( error == KErrNone && ( |
|
1217 EMailAoOff != aExtendedMailSettings.AlwaysOnlineState() || |
|
1218 EMailEmnOff != aExtendedMailSettings.EmailNotificationState() )) |
|
1219 { |
|
1220 MsvEmailMtmUiUtils::SendAOCommandL( EServerAPIEmailTurnOn, mailboxId ); |
|
1221 } |
|
1222 } |
|
1223 |
|
1224 User::LeaveIfError( error ); |
|
1225 IMUM_OUT(); |
|
1226 } |
|
1227 |
|
1228 // ---------------------------------------------------------------------------- |
|
1229 // CImumMboxSettingsCtrl::LoadSettings() |
|
1230 // ---------------------------------------------------------------------------- |
|
1231 // |
|
1232 void CImumMboxSettingsCtrl::LoadSettingsL( |
|
1233 const TMsvId aMailboxId, |
|
1234 const TUid& aMtmId, |
|
1235 CImumMboxDataExtension& aExtendedMailSettings ) |
|
1236 { |
|
1237 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettingsL, 0, KLogData ); |
|
1238 IMUM_IN(); |
|
1239 |
|
1240 // Get the account id and continue opening |
|
1241 TUint32 accountId = |
|
1242 IMASAccountControl::MailboxIdToAccountIdL( aMailboxId, aMtmId ); |
|
1243 LoadSettingsL( accountId, aMtmId, aExtendedMailSettings ); |
|
1244 IMUM_OUT(); |
|
1245 } |
|
1246 |
|
1247 // ---------------------------------------------------------------------------- |
|
1248 // CImumMboxSettingsCtrl::LoadSettingsL() |
|
1249 // ---------------------------------------------------------------------------- |
|
1250 // |
|
1251 void CImumMboxSettingsCtrl::LoadSettingsL( |
|
1252 const TUint32 aAccountId, |
|
1253 CImImap4Settings& aImap4Settings ) |
|
1254 { |
|
1255 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettingsL, 0, KLogData ); |
|
1256 IMUM_IN(); |
|
1257 |
|
1258 TImapAccount imapAccountId; |
|
1259 imapAccountId.iImapAccountId = aAccountId; |
|
1260 |
|
1261 AccountsL()->LoadImapSettingsL( imapAccountId, aImap4Settings ); |
|
1262 |
|
1263 IMUM_OUT(); |
|
1264 } |
|
1265 |
|
1266 // ---------------------------------------------------------------------------- |
|
1267 // CImumMboxSettingsCtrl::LoadSettingsL() |
|
1268 // ---------------------------------------------------------------------------- |
|
1269 // |
|
1270 void CImumMboxSettingsCtrl::LoadSettingsL( |
|
1271 const TUint32 aAccountId, |
|
1272 CImPop3Settings& aPop3Settings ) |
|
1273 { |
|
1274 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettingsL, 0, KLogData ); |
|
1275 IMUM_IN(); |
|
1276 |
|
1277 TPopAccount popAccountId; |
|
1278 popAccountId.iPopAccountId = aAccountId; |
|
1279 |
|
1280 AccountsL()->LoadPopSettingsL( popAccountId, aPop3Settings ); |
|
1281 |
|
1282 IMUM_OUT(); |
|
1283 } |
|
1284 |
|
1285 // ---------------------------------------------------------------------------- |
|
1286 // CImumMboxSettingsCtrl::LoadSettingsSmtpL() |
|
1287 // ---------------------------------------------------------------------------- |
|
1288 // |
|
1289 void CImumMboxSettingsCtrl::LoadSettingsL( |
|
1290 const TUint32 aAccountId, |
|
1291 CImSmtpSettings& aSmtpSettings ) |
|
1292 { |
|
1293 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettingsL, 0, KLogData ); |
|
1294 IMUM_IN(); |
|
1295 |
|
1296 TSmtpAccount smtpAccountId; |
|
1297 smtpAccountId.iSmtpAccountId = aAccountId; |
|
1298 |
|
1299 AccountsL()->LoadSmtpSettingsL( smtpAccountId, aSmtpSettings ); |
|
1300 |
|
1301 IMUM_OUT(); |
|
1302 } |
|
1303 |
|
1304 // ---------------------------------------------------------------------------- |
|
1305 // CImumMboxSettingsCtrl::LoadSettingsL() |
|
1306 // ---------------------------------------------------------------------------- |
|
1307 // |
|
1308 void CImumMboxSettingsCtrl::LoadSettingsL( |
|
1309 const TMsvId aServiceId, |
|
1310 CImImap4Settings& aImap4Settings ) |
|
1311 { |
|
1312 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettingsL, 0, KLogData ); |
|
1313 IMUM_IN(); |
|
1314 |
|
1315 TImapAccount imapAccountId; |
|
1316 AccountsL()->GetImapAccountL( aServiceId, imapAccountId ); |
|
1317 iAccounts->LoadImapSettingsL( imapAccountId, aImap4Settings ); |
|
1318 |
|
1319 IMUM_OUT(); |
|
1320 } |
|
1321 |
|
1322 // ---------------------------------------------------------------------------- |
|
1323 // CImumMboxSettingsCtrl::LoadSettingsL() |
|
1324 // ---------------------------------------------------------------------------- |
|
1325 // |
|
1326 void CImumMboxSettingsCtrl::LoadSettingsL( |
|
1327 const TMsvId aServiceId, |
|
1328 CImPop3Settings& aPop3Settings ) |
|
1329 { |
|
1330 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettingsL, 0, KLogData ); |
|
1331 IMUM_IN(); |
|
1332 |
|
1333 TPopAccount popAccountId; |
|
1334 AccountsL()->GetPopAccountL( aServiceId, popAccountId ); |
|
1335 iAccounts->LoadPopSettingsL( popAccountId, aPop3Settings ); |
|
1336 |
|
1337 IMUM_OUT(); |
|
1338 } |
|
1339 |
|
1340 // ---------------------------------------------------------------------------- |
|
1341 // CImumMboxSettingsCtrl::LoadSettingsL() |
|
1342 // ---------------------------------------------------------------------------- |
|
1343 // |
|
1344 void CImumMboxSettingsCtrl::LoadSettingsL( |
|
1345 const TMsvId aServiceId, |
|
1346 CImSmtpSettings& aSmtpSettings ) |
|
1347 { |
|
1348 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettingsL, 0, KLogData ); |
|
1349 IMUM_IN(); |
|
1350 |
|
1351 TSmtpAccount smtpAccountId; |
|
1352 AccountsL()->GetSmtpAccountL( aServiceId, smtpAccountId ); |
|
1353 iAccounts->LoadSmtpSettingsL( smtpAccountId, aSmtpSettings ); |
|
1354 |
|
1355 IMUM_OUT(); |
|
1356 } |
|
1357 |
|
1358 // ---------------------------------------------------------------------------- |
|
1359 // CImumMboxSettingsCtrl::LoadSettingsL() |
|
1360 // ---------------------------------------------------------------------------- |
|
1361 // |
|
1362 void CImumMboxSettingsCtrl::LoadSettingsL( |
|
1363 const TMsvEntry& aEntry, |
|
1364 CImBaseEmailSettings& aBaseSettings ) |
|
1365 { |
|
1366 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadSettingsL, 0, KLogData ); |
|
1367 IMUM_IN(); |
|
1368 |
|
1369 // Load the correct settings based on the MTM uid |
|
1370 switch( aEntry.iMtm.iUid ) |
|
1371 { |
|
1372 // SMTP |
|
1373 case KSenduiMtmSmtpUidValue: |
|
1374 LoadSettingsL( aEntry.Id(), |
|
1375 *static_cast<CImSmtpSettings*>( &aBaseSettings ) ); |
|
1376 break; |
|
1377 |
|
1378 // POP3 |
|
1379 case KSenduiMtmPop3UidValue: |
|
1380 LoadSettingsL( aEntry.Id(), |
|
1381 *static_cast<CImPop3Settings*>( &aBaseSettings ) ); |
|
1382 break; |
|
1383 |
|
1384 // IMAP4 |
|
1385 case KSenduiMtmImap4UidValue: |
|
1386 LoadSettingsL( aEntry.Id(), |
|
1387 *static_cast<CImImap4Settings*>( &aBaseSettings ) ); |
|
1388 break; |
|
1389 |
|
1390 default: |
|
1391 User::Leave( KErrUnknown ); |
|
1392 break; |
|
1393 } |
|
1394 IMUM_OUT(); |
|
1395 } |
|
1396 |
|
1397 /****************************************************************************** |
|
1398 |
|
1399 Special storers |
|
1400 |
|
1401 ******************************************************************************/ |
|
1402 |
|
1403 // ---------------------------------------------------------------------------- |
|
1404 // CImumMboxSettingsCtrl::CreateLastUpdateInfoL() |
|
1405 // ---------------------------------------------------------------------------- |
|
1406 // |
|
1407 void CImumMboxSettingsCtrl::CreateLastUpdateInfoL( |
|
1408 const TAOInfo& aAoInfo ) |
|
1409 { |
|
1410 IMUM_CONTEXT( CImumMboxSettingsCtrl::CreateLastUpdateInfoL, 0, KLogData ); |
|
1411 IMUM_IN(); |
|
1412 |
|
1413 // Create the last update info |
|
1414 iCenRepControl->CreateToAccountL( |
|
1415 EImaAoLastSuccessfulUpdateH, EImaAoLastSuccessfulUpdateL, |
|
1416 aAoInfo.iLastSuccessfulUpdate.Int64() ); |
|
1417 iCenRepControl->CreateToAccountL( |
|
1418 EImaAoLastUpdateFailed, aAoInfo.iLastUpdateFailed ); |
|
1419 iCenRepControl->CreateToAccountL( EImaAoUpdateSuccessfulWithCurSettings, |
|
1420 aAoInfo.iUpdateSuccessfulWithCurSettings ); |
|
1421 IMUM_OUT(); |
|
1422 } |
|
1423 |
|
1424 // ---------------------------------------------------------------------------- |
|
1425 // CImumMboxSettingsCtrl::DeleteLastUpdateInfo() |
|
1426 // ---------------------------------------------------------------------------- |
|
1427 // |
|
1428 TInt CImumMboxSettingsCtrl::DeleteLastUpdateInfo() |
|
1429 { |
|
1430 IMUM_CONTEXT( CImumMboxSettingsCtrl::DeleteLastUpdateInfo, 0, KLogData ); |
|
1431 IMUM_IN(); |
|
1432 |
|
1433 // Save the last update info |
|
1434 |
|
1435 TRAPD( error, |
|
1436 iCenRepControl->DeleteFromAccountL( |
|
1437 EImaAoLastSuccessfulUpdateH, EImaAoLastSuccessfulUpdateL ); |
|
1438 iCenRepControl->DeleteFromAccountL( EImaAoLastUpdateFailed ); |
|
1439 iCenRepControl->DeleteFromAccountL( |
|
1440 EImaAoUpdateSuccessfulWithCurSettings ); ); |
|
1441 |
|
1442 IMUM_OUT(); |
|
1443 return error; |
|
1444 } |
|
1445 |
|
1446 // ---------------------------------------------------------------------------- |
|
1447 // CImumMboxSettingsCtrl::SaveLastUpdateInfo() |
|
1448 // ---------------------------------------------------------------------------- |
|
1449 // |
|
1450 TInt CImumMboxSettingsCtrl::SaveLastUpdateInfo( |
|
1451 const TAOInfo& aAoInfo ) |
|
1452 { |
|
1453 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveLastUpdateInfo, 0, KLogData ); |
|
1454 IMUM_IN(); |
|
1455 |
|
1456 // Save the last update info and ignore any error. |
|
1457 TRAPD( error, |
|
1458 iCenRepControl->SetToAccountL( |
|
1459 EImaAoLastSuccessfulUpdateH, EImaAoLastSuccessfulUpdateL, |
|
1460 aAoInfo.iLastSuccessfulUpdate.Int64() ); |
|
1461 iCenRepControl->SetToAccountL( |
|
1462 EImaAoLastUpdateFailed, aAoInfo.iLastUpdateFailed ); |
|
1463 iCenRepControl->SetToAccountL( EImaAoUpdateSuccessfulWithCurSettings, |
|
1464 aAoInfo.iUpdateSuccessfulWithCurSettings ); ); |
|
1465 |
|
1466 |
|
1467 IMUM_OUT(); |
|
1468 return error; |
|
1469 } |
|
1470 |
|
1471 // ---------------------------------------------------------------------------- |
|
1472 // CImumMboxSettingsCtrl::LoadLastUpdateInfo() |
|
1473 // ---------------------------------------------------------------------------- |
|
1474 // |
|
1475 TAOInfo CImumMboxSettingsCtrl::LoadLastUpdateInfo() |
|
1476 { |
|
1477 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadLastUpdateInfo, 0, KLogData ); |
|
1478 IMUM_IN(); |
|
1479 |
|
1480 TAOInfo aoInfo; |
|
1481 |
|
1482 // Failing to load the info can be ignored |
|
1483 TRAP_IGNORE( |
|
1484 // Load the last update info |
|
1485 aoInfo.iLastSuccessfulUpdate = iCenRepControl->GetFromAccountL( |
|
1486 EImaAoLastSuccessfulUpdateH, EImaAoLastSuccessfulUpdateL ); |
|
1487 aoInfo.iLastUpdateFailed = iCenRepControl->GetFromAccountL( |
|
1488 EImaAoLastUpdateFailed ); |
|
1489 aoInfo.iUpdateSuccessfulWithCurSettings = iCenRepControl->GetFromAccountL( |
|
1490 EImaAoUpdateSuccessfulWithCurSettings ); ); |
|
1491 |
|
1492 IMUM_OUT(); |
|
1493 return aoInfo; |
|
1494 } |
|
1495 |
|
1496 // ---------------------------------------------------------------------------- |
|
1497 // CImumMboxSettingsCtrl::OpenExtendedSettingsL() |
|
1498 // ---------------------------------------------------------------------------- |
|
1499 // |
|
1500 void CImumMboxSettingsCtrl::OpenExtendedSettingsL( |
|
1501 const TIMAStorerParams& aParams, |
|
1502 CImumMboxDataExtension& aExtendedMailSettings ) |
|
1503 { |
|
1504 IMUM_CONTEXT( CImumMboxSettingsCtrl::OpenExtendedSettingsL, 0, KLogData ); |
|
1505 IMUM3_IN( "aParams.iMtmId = 0x%x, aParams.iAccountId = 0x%x, aParams.iMailboxId = 0x%x", |
|
1506 aParams.MtmId(), aParams.AccountId(), aParams.MailboxId() ); |
|
1507 |
|
1508 // Make sure there is connection to repository |
|
1509 MsvEmailMtmUiUtils::CreateCenRepConnectionL( |
|
1510 iCenRepExtMail, KCRUidImumSettings ); |
|
1511 |
|
1512 // Prepare account control |
|
1513 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
1514 iCenRepControl->SetActiveBaseKey( aParams.AccountId(), aParams.MtmId() ); |
|
1515 |
|
1516 // Load the settings |
|
1517 // Common Settings |
|
1518 LoadExtendedSettingsStatusFlagsL( aExtendedMailSettings ); |
|
1519 TInt value = iCenRepControl->GetFromAccountL( EImaCommonSetMailboxId ); |
|
1520 aExtendedMailSettings.SetMailboxId( static_cast<TMsvId>( value ) ); |
|
1521 value = iCenRepControl->GetFromAccountL( EImaCommonSetAccountId ); |
|
1522 aExtendedMailSettings.SetAccountId( value ); |
|
1523 value = iCenRepControl->GetFromAccountL( EImaCommonSetExtensionId ); |
|
1524 aExtendedMailSettings.SetExtensionId( value ); |
|
1525 value = iCenRepControl->GetFromAccountL( EImaCommonSetProtocol ); |
|
1526 aExtendedMailSettings.SetProtocol( TUid::Uid( value ) ); |
|
1527 TMuiuSettingsText text; |
|
1528 iCenRepControl->GetTextFromAccountL( text, EImaCommonSetEmailAddress ); |
|
1529 aExtendedMailSettings.SetEmailAddress( text ); |
|
1530 |
|
1531 // Common settings are now loaded. If the following settings are found to be |
|
1532 // missing, they are populated with the default values during the load |
|
1533 // process. |
|
1534 PopulateDefaultExtSettings( aExtendedMailSettings ); |
|
1535 |
|
1536 // Extended mailbox settings |
|
1537 // |
|
1538 value = iCenRepControl->GetFromAccountOrCreateL( |
|
1539 EImaExtSetEmailNotif, aExtendedMailSettings.EmailNotificationState() ); |
|
1540 aExtendedMailSettings.SetEmailNotificationState( |
|
1541 static_cast<TMailEmnStates>( value ) ); |
|
1542 |
|
1543 TBool result = iCenRepControl->GetFromAccountOrCreateL( |
|
1544 EImaExtSetIndicators, aExtendedMailSettings.NewMailIndicators() ); |
|
1545 aExtendedMailSettings.SetNewMailIndicators( result ); |
|
1546 |
|
1547 result = iCenRepControl->GetFromAccountOrCreateL( |
|
1548 EImaExtSetHideMsgs, aExtendedMailSettings.HideMsgs() ); |
|
1549 aExtendedMailSettings.SetHideMsgs( result ); |
|
1550 |
|
1551 value = iCenRepControl->GetFromAccountOrCreateL( |
|
1552 EImaExtSetOpenHtmlMail, aExtendedMailSettings.OpenHtmlMail() ); |
|
1553 aExtendedMailSettings.SetOpenHtmlMail( value ); |
|
1554 |
|
1555 value = iCenRepControl->GetFromAccountOrCreateL( |
|
1556 EImaExtSetMailDeletion, aExtendedMailSettings.MailDeletion() ); |
|
1557 aExtendedMailSettings.SetMailDeletion( |
|
1558 static_cast<TIMASMailDeletionMode>( value ) ); |
|
1559 |
|
1560 result = iCenRepControl->GetFromAccountOrCreateL( |
|
1561 EImaExtIsPredefined, aExtendedMailSettings.IsPredefined() ); |
|
1562 aExtendedMailSettings.SetIsPredefined( result ); |
|
1563 |
|
1564 // Always Online Settings |
|
1565 // |
|
1566 value = iCenRepControl->GetFromAccountOrCreateL( |
|
1567 EImaAoOnlineState, aExtendedMailSettings.AlwaysOnlineState() ); |
|
1568 aExtendedMailSettings.SetAlwaysOnlineState( |
|
1569 static_cast<TMailAoStates>( value ) ); |
|
1570 |
|
1571 value = iCenRepControl->GetFromAccountOrCreateL( |
|
1572 EImaAoWeekDays, aExtendedMailSettings.SelectedWeekDays() ); |
|
1573 aExtendedMailSettings.SetSelectedWeekDays( value ); |
|
1574 |
|
1575 TInt64 value64 = iCenRepControl->GetFromAccountOrCreateL( |
|
1576 EImaAoTimeStartH, EImaAoTimeStartL, |
|
1577 aExtendedMailSettings.SelectedTimeStart().Int64() ); |
|
1578 aExtendedMailSettings.SetSelectedTimeStart( value64 ); |
|
1579 |
|
1580 value64 = iCenRepControl->GetFromAccountOrCreateL( |
|
1581 EImaAoTimeStopH, EImaAoTimeStopL, |
|
1582 aExtendedMailSettings.SelectedTimeStop().Int64() ); |
|
1583 aExtendedMailSettings.SetSelectedTimeStop( value64 ); |
|
1584 |
|
1585 value = iCenRepControl->GetFromAccountOrCreateL( |
|
1586 EImaAoInboxRefreshTime, aExtendedMailSettings.InboxRefreshTime() ); |
|
1587 aExtendedMailSettings.SetInboxRefreshTime( value ); |
|
1588 |
|
1589 value = iCenRepControl->GetFromAccountOrCreateL( |
|
1590 EImaAoUpdateMode, aExtendedMailSettings.UpdateMode() ); |
|
1591 aExtendedMailSettings.SetUpdateMode( |
|
1592 static_cast<TMailAoUpdateModes>( value ) ); |
|
1593 |
|
1594 aExtendedMailSettings.SetLastUpdateInfo( LoadLastUpdateInfo() ); |
|
1595 |
|
1596 IMUM_OUT(); |
|
1597 } |
|
1598 |
|
1599 // ---------------------------------------------------------------------------- |
|
1600 // CImumMboxSettingsCtrl::AccountsL() |
|
1601 // ---------------------------------------------------------------------------- |
|
1602 // |
|
1603 CEmailAccounts* CImumMboxSettingsCtrl::AccountsL() |
|
1604 { |
|
1605 IMUM_CONTEXT( CImumMboxSettingsCtrl::AccountsL, 0, KLogData ); |
|
1606 IMUM_IN(); |
|
1607 |
|
1608 if ( !iAccounts ) |
|
1609 { |
|
1610 iAccounts = CEmailAccounts::NewL(); |
|
1611 } |
|
1612 |
|
1613 IMUM_OUT(); |
|
1614 return iAccounts; |
|
1615 } |
|
1616 |
|
1617 |
|
1618 // ---------------------------------------------------------------------------- |
|
1619 // CImumMboxSettingsCtrl::LoadExtendedSettingsStatusFlagsL() |
|
1620 // ---------------------------------------------------------------------------- |
|
1621 // |
|
1622 void CImumMboxSettingsCtrl::LoadExtendedSettingsStatusFlagsL( |
|
1623 CImumMboxDataExtension& aExtendedSettings ) |
|
1624 { |
|
1625 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadExtendedSettingsStatusFlagsL, 0, KLogData ); |
|
1626 IMUM_IN(); |
|
1627 |
|
1628 TMuiuFlags flags; |
|
1629 flags = iCenRepControl->GetFromAccountL( |
|
1630 EImaCommonSetStatusFlagsH, EImaCommonSetStatusFlagsL ); |
|
1631 aExtendedSettings.SetStatusFlags( flags ); |
|
1632 IMUM_OUT(); |
|
1633 } |
|
1634 |
|
1635 // ---------------------------------------------------------------------------- |
|
1636 // CImumMboxSettingsCtrl::SaveExtendedSettingsStatusFlagsL() |
|
1637 // ---------------------------------------------------------------------------- |
|
1638 // |
|
1639 void CImumMboxSettingsCtrl::SaveExtendedSettingsStatusFlagsL( |
|
1640 const CImumMboxDataExtension& aExtendedSettings ) |
|
1641 { |
|
1642 IMUM_CONTEXT( CImumMboxSettingsCtrl::SaveExtendedSettingsStatusFlagsL, 0, KLogData ); |
|
1643 IMUM_IN(); |
|
1644 |
|
1645 // Get the flags in correct order from flag class and store to settings |
|
1646 TInt64 flags = 0; |
|
1647 const TMuiuFlags muiuFlags = aExtendedSettings.StatusFlags(); |
|
1648 |
|
1649 for ( TInt flag = KIMASLastFlag; --flag >= 0; ) |
|
1650 { |
|
1651 flags |= muiuFlags.Flag( flag ) << flag; |
|
1652 } |
|
1653 |
|
1654 iCenRepControl->SetToAccountL( EImaCommonSetStatusFlagsH, |
|
1655 EImaCommonSetStatusFlagsL, flags ); |
|
1656 IMUM_OUT(); |
|
1657 } |
|
1658 |
|
1659 // ---------------------------------------------------------------------------- |
|
1660 // CImumMboxSettingsCtrl::CreateExtendedSettingsStatusFlagsL() |
|
1661 // ---------------------------------------------------------------------------- |
|
1662 // |
|
1663 void CImumMboxSettingsCtrl::CreateExtendedSettingsStatusFlagsL( |
|
1664 const CImumMboxDataExtension& aExtendedSettings ) |
|
1665 { |
|
1666 IMUM_CONTEXT( CImumMboxSettingsCtrl::CreateExtendedSettingsStatusFlagsL, 0, KLogData ); |
|
1667 IMUM_IN(); |
|
1668 |
|
1669 // Get the flags in correct order from flag class and store to settings |
|
1670 TInt64 flags = 0; |
|
1671 const TMuiuFlags muiuFlags = aExtendedSettings.StatusFlags(); |
|
1672 |
|
1673 for ( TInt flag = KIMASLastFlag; --flag >= 0; ) |
|
1674 { |
|
1675 flags |= muiuFlags.Flag( flag ) << flag; |
|
1676 } |
|
1677 |
|
1678 iCenRepControl->CreateToAccountL( EImaCommonSetStatusFlagsH, |
|
1679 EImaCommonSetStatusFlagsL, flags ); |
|
1680 IMUM_OUT(); |
|
1681 } |
|
1682 |
|
1683 // --------------------------------------------------------------------------- |
|
1684 // CImumMboxSettingsCtrl::LoadAlwaysOnlineSettingsL() |
|
1685 // --------------------------------------------------------------------------- |
|
1686 // |
|
1687 void CImumMboxSettingsCtrl::LoadAlwaysOnlineSettingsL( |
|
1688 const TUint32 aAccountId, |
|
1689 const TUid& aMtmId, |
|
1690 TInt64& aDays, |
|
1691 TInt64& aStartTime, |
|
1692 TInt64& aStopTime, |
|
1693 TInt& aActive ) |
|
1694 { |
|
1695 IMUM_CONTEXT( CImumMboxSettingsCtrl::LoadAlwaysOnlineSettingsL, 0, KLogData ); |
|
1696 IMUM_IN(); |
|
1697 |
|
1698 // Always Online Settings |
|
1699 |
|
1700 // Make sure there is connection to repository |
|
1701 MsvEmailMtmUiUtils::CreateCenRepConnectionL( |
|
1702 iCenRepExtMail, KCRUidImumSettings ); |
|
1703 |
|
1704 // Prepare account control |
|
1705 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
1706 iCenRepControl->SetActiveBaseKey( aAccountId, aMtmId ); |
|
1707 |
|
1708 aActive = iCenRepControl->GetFromAccountL( EImaAoOnlineState ); |
|
1709 aDays = iCenRepControl->GetFromAccountL( EImaAoWeekDays ); |
|
1710 aStartTime = iCenRepControl->GetFromAccountL( |
|
1711 EImaAoTimeStartH, EImaAoTimeStartL ); |
|
1712 aStopTime = iCenRepControl->GetFromAccountL( |
|
1713 EImaAoTimeStopH, EImaAoTimeStopL ); |
|
1714 IMUM_OUT(); |
|
1715 } |
|
1716 |
|
1717 // --------------------------------------------------------------------------- |
|
1718 // CImumMboxSettingsCtrl::CheckMailboxNameImap() |
|
1719 // --------------------------------------------------------------------------- |
|
1720 // |
|
1721 TIMDErrors CImumMboxSettingsCtrl::CheckMailboxNameImap( |
|
1722 TMsvEntry& aMailboxEntry ) const |
|
1723 { |
|
1724 IMUM_CONTEXT( CImumMboxSettingsCtrl::CheckMailboxNameImap, 0, KLogData ); |
|
1725 IMUM_IN(); |
|
1726 |
|
1727 //Mailboxname is located in the iDetails variable and can't be over 30 |
|
1728 //This method checks the length of mailboxname, if it is over 30 |
|
1729 //we cut off the mailboxname |
|
1730 TIMDErrors result = EIMDNoError; |
|
1731 if( aMailboxEntry.iDetails.Length() > KIMASMaxMailboxNameLength ) |
|
1732 { |
|
1733 TRAPD( error, FixMailboxNameImapL( aMailboxEntry ) ); |
|
1734 if( error ) |
|
1735 { |
|
1736 // all errors cause account failure |
|
1737 result = EIMDImap4AccountFailure; |
|
1738 } |
|
1739 } |
|
1740 |
|
1741 IMUM_OUT(); |
|
1742 return result; |
|
1743 } |
|
1744 |
|
1745 // --------------------------------------------------------------------------- |
|
1746 // CImumMboxSettingsCtrl::CheckMailboxNamePop() |
|
1747 // --------------------------------------------------------------------------- |
|
1748 // |
|
1749 TIMDErrors CImumMboxSettingsCtrl::CheckMailboxNamePop( |
|
1750 TMsvEntry& aMailboxEntry ) const |
|
1751 { |
|
1752 IMUM_CONTEXT( CImumMboxSettingsCtrl::CheckMailboxNamePop, 0, KLogData ); |
|
1753 IMUM_IN(); |
|
1754 |
|
1755 //Mailboxname is located in the iDetails variable and can't be over 30 |
|
1756 //This method checks the length of mailboxname, if it is over 30 |
|
1757 //we cut off the mailboxname |
|
1758 TIMDErrors result = EIMDNoError; |
|
1759 if( aMailboxEntry.iDetails.Length() > KIMASMaxMailboxNameLength ) |
|
1760 { |
|
1761 TRAPD( error, FixMailboxNamePopL( aMailboxEntry )); |
|
1762 if( error ) |
|
1763 { |
|
1764 // all errors cause account failure |
|
1765 result = EIMDPop3AccountFailure; |
|
1766 } |
|
1767 } |
|
1768 IMUM_OUT(); |
|
1769 return result; |
|
1770 } |
|
1771 |
|
1772 // --------------------------------------------------------------------------- |
|
1773 // CImumMboxSettingsCtrl::CheckMailboxNameSmtp() |
|
1774 // --------------------------------------------------------------------------- |
|
1775 // |
|
1776 TIMDErrors CImumMboxSettingsCtrl::CheckMailboxNameSmtp( |
|
1777 TMsvEntry& aMailboxEntry ) const |
|
1778 { |
|
1779 IMUM_CONTEXT( CImumMboxSettingsCtrl::CheckMailboxNameSmtp, 0, KLogData ); |
|
1780 IMUM_IN(); |
|
1781 |
|
1782 //Mailboxname is located in the iDetails variable and can't be over 30 |
|
1783 //This method checks the length of mailboxname, if it is over 30 |
|
1784 //we cut off the mailboxname |
|
1785 TIMDErrors result = EIMDNoError; |
|
1786 if ( aMailboxEntry.iDetails.Length() > KIMASMaxMailboxNameLength ) |
|
1787 { |
|
1788 TRAPD( error, FixMailboxNameSmtpL( aMailboxEntry ) ) |
|
1789 if( error ) |
|
1790 { |
|
1791 // all errors cause account failure |
|
1792 result = EIMDSmtpAccountFailure; |
|
1793 } |
|
1794 } |
|
1795 |
|
1796 IMUM_OUT(); |
|
1797 return result; |
|
1798 } |
|
1799 |
|
1800 // --------------------------------------------------------------------------- |
|
1801 // CImumMboxSettingsCtrl::SetLastUpdateInfoL() |
|
1802 // --------------------------------------------------------------------------- |
|
1803 // |
|
1804 void CImumMboxSettingsCtrl::SetLastUpdateInfoL( TUint32 aAccountId, |
|
1805 const TUid& aMtmId, TBool aSuccess, const TTime& aTime ) |
|
1806 { |
|
1807 // This function is performance optimization as settings are |
|
1808 // not converted to CImumInSettingsData format. |
|
1809 IMUM_CONTEXT( CImumMboxSettingsCtrl::SetLastUpdateInfoL, 0, KLogData ); |
|
1810 |
|
1811 // Make sure there is connection to repository |
|
1812 MsvEmailMtmUiUtils::CreateCenRepConnectionL( |
|
1813 iCenRepExtMail, KCRUidImumSettings ); |
|
1814 |
|
1815 // Prepare account control |
|
1816 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
1817 iCenRepControl->SetActiveBaseKey( aAccountId, aMtmId ); |
|
1818 |
|
1819 TAOInfo taoInfo; |
|
1820 taoInfo.iLastUpdateFailed = aSuccess; |
|
1821 taoInfo.iLastSuccessfulUpdate = aTime; |
|
1822 taoInfo.iUpdateSuccessfulWithCurSettings = aSuccess; |
|
1823 SaveLastUpdateInfo( taoInfo ); |
|
1824 |
|
1825 IMUM_OUT(); |
|
1826 } |
|
1827 |
|
1828 // --------------------------------------------------------------------------- |
|
1829 // CImumMboxSettingsCtrl::FixMailboxNameSmtpL() |
|
1830 // --------------------------------------------------------------------------- |
|
1831 // |
|
1832 void CImumMboxSettingsCtrl::FixMailboxNameSmtpL( |
|
1833 TMsvEntry& aMailboxEntry ) const |
|
1834 { |
|
1835 IMUM_CONTEXT( CImumMboxSettingsCtrl::FixMailboxNameStmpL, 0, KLogData ); |
|
1836 |
|
1837 // get settings |
|
1838 TSmtpAccount smtpAccount; |
|
1839 iMailboxApi.EmailAccountsL().GetSmtpAccountL( |
|
1840 aMailboxEntry.Id(), smtpAccount ); |
|
1841 CImSmtpSettings *smtpSet = new (ELeave) CImSmtpSettings; |
|
1842 CleanupStack::PushL( smtpSet ); |
|
1843 iMailboxApi.EmailAccountsL().LoadSmtpSettingsL( smtpAccount, *smtpSet ); |
|
1844 |
|
1845 // shorten mailbox name |
|
1846 TPtrC16 ptrSmtp = smtpAccount.iSmtpAccountName.Left( |
|
1847 KIMASMaxMailboxNameLength ); |
|
1848 smtpAccount.iSmtpAccountName.Copy( ptrSmtp ); |
|
1849 |
|
1850 // save settings |
|
1851 iMailboxApi.EmailAccountsL().SaveSmtpSettingsL( smtpAccount, *smtpSet ); |
|
1852 CleanupStack::PopAndDestroy( smtpSet ); |
|
1853 |
|
1854 IMUM_OUT(); |
|
1855 } |
|
1856 |
|
1857 // --------------------------------------------------------------------------- |
|
1858 // CImumMboxSettingsCtrl::FixMailboxNameImapL() |
|
1859 // --------------------------------------------------------------------------- |
|
1860 // |
|
1861 void CImumMboxSettingsCtrl::FixMailboxNameImapL( |
|
1862 TMsvEntry& aMailboxEntry ) const |
|
1863 { |
|
1864 IMUM_CONTEXT( CImumMboxSettingsCtrl::FixMailboxNameImapL, 0, KLogData ); |
|
1865 |
|
1866 // get settings |
|
1867 TImapAccount imapAccount; |
|
1868 iMailboxApi.EmailAccountsL().GetImapAccountL( |
|
1869 aMailboxEntry.Id(), imapAccount ); |
|
1870 CImImap4Settings *imap4Set = new (ELeave) CImImap4Settings; |
|
1871 CleanupStack::PushL( imap4Set ); |
|
1872 iMailboxApi.EmailAccountsL().LoadImapSettingsL( imapAccount, *imap4Set ); |
|
1873 |
|
1874 // shorten mailbox name |
|
1875 TPtrC16 ptrImap = imapAccount.iImapAccountName.Left( |
|
1876 KIMASMaxMailboxNameLength); |
|
1877 imapAccount.iImapAccountName.Copy( ptrImap ); |
|
1878 |
|
1879 // store changes |
|
1880 iMailboxApi.EmailAccountsL().SaveImapSettingsL( imapAccount, *imap4Set ); |
|
1881 CleanupStack::PopAndDestroy(imap4Set); |
|
1882 |
|
1883 IMUM_OUT(); |
|
1884 } |
|
1885 |
|
1886 // --------------------------------------------------------------------------- |
|
1887 // CImumMboxSettingsCtrl::FixMailboxNamePopL() |
|
1888 // --------------------------------------------------------------------------- |
|
1889 // |
|
1890 void CImumMboxSettingsCtrl::FixMailboxNamePopL( |
|
1891 TMsvEntry& aMailboxEntry ) const |
|
1892 { |
|
1893 IMUM_CONTEXT( CImumMboxSettingsCtrl::FixMailboxNamePopL, 0, KLogData ); |
|
1894 |
|
1895 // get settings |
|
1896 TPopAccount popAccount; |
|
1897 iMailboxApi.EmailAccountsL().GetPopAccountL( |
|
1898 aMailboxEntry.Id(), popAccount ); |
|
1899 CImPop3Settings *popSet = new (ELeave) CImPop3Settings; |
|
1900 CleanupStack::PushL( popSet ); |
|
1901 iMailboxApi.EmailAccountsL().LoadPopSettingsL( popAccount, *popSet ); |
|
1902 |
|
1903 // shorten mailbox name |
|
1904 TPtrC16 ptrPop = popAccount.iPopAccountName.Left( |
|
1905 KIMASMaxMailboxNameLength); |
|
1906 popAccount.iPopAccountName.Copy( ptrPop ); |
|
1907 |
|
1908 // store changes |
|
1909 iMailboxApi.EmailAccountsL().SavePopSettingsL( popAccount, *popSet ); |
|
1910 CleanupStack::PopAndDestroy( popSet ); |
|
1911 |
|
1912 IMUM_OUT(); |
|
1913 } |
|
1914 |
|
1915 // End of File |
|
1916 |