|
1 /* |
|
2 * Copyright (c) 2007 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: This file implements classes TIpsSetDataStorerParams, CIpsSetDataStorer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "emailtrace.h" |
|
21 #include <centralrepository.h> // CRepository |
|
22 #include <SendUiConsts.h> |
|
23 #include <smtpset.h> |
|
24 #include <imapset.h> |
|
25 #include <pop3set.h> |
|
26 #include <cemailaccounts.h> |
|
27 |
|
28 #include "ipssetutilsconsts.hrh" |
|
29 #include "ipssetdatastorer.h" |
|
30 #include "ipssetdataextension.h" |
|
31 #include "ipssetdatactrlcenrep.h" |
|
32 #include "ipssetutils.h" |
|
33 #include "ipssetutilsconsts.h" |
|
34 #include "ipssetdatactrlaccount.h" |
|
35 |
|
36 #include "ipsplgcommon.h" |
|
37 |
|
38 #ifdef _DEBUG |
|
39 _LIT( KIpsSetDataStorer, "settings - storer"); |
|
40 _LIT( KIpsSetDataCenRepKeyNotFound, "IpsSettings - cenrep key not found"); |
|
41 #endif |
|
42 |
|
43 const TUint KIpsSetStorerAtChar = '@'; |
|
44 |
|
45 // ============================ TIpsSetDataStorerParams ======================= |
|
46 |
|
47 // ---------------------------------------------------------------------------- |
|
48 // ---------------------------------------------------------------------------- |
|
49 // |
|
50 TIpsSetDataStorerParams::TIpsSetDataStorerParams( |
|
51 const TUint32& aAccountId, |
|
52 const TUid& aMtmId ) |
|
53 : |
|
54 iAccountId( aAccountId ), |
|
55 iMtmId( aMtmId ) |
|
56 { |
|
57 FUNC_LOG; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 TUint32 TIpsSetDataStorerParams::AccountId() const |
|
64 { |
|
65 FUNC_LOG; |
|
66 return iAccountId; |
|
67 } |
|
68 |
|
69 // ---------------------------------------------------------------------------- |
|
70 // ---------------------------------------------------------------------------- |
|
71 // |
|
72 TUid TIpsSetDataStorerParams::MtmId() const |
|
73 { |
|
74 FUNC_LOG; |
|
75 return iMtmId; |
|
76 } |
|
77 |
|
78 // ============================ CIpsSetDataStorer ============================= |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // ---------------------------------------------------------------------------- |
|
82 CIpsSetDataStorer::CIpsSetDataStorer() |
|
83 : |
|
84 iCenRepSmtp( NULL ), |
|
85 iCenRepExtMail( NULL ), |
|
86 iCenRepAlwaysOnline( NULL ), |
|
87 iCenRepDefaultData( NULL ), |
|
88 iAccounts( NULL ), |
|
89 iCenRepControl( NULL ) |
|
90 { |
|
91 FUNC_LOG; |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // ---------------------------------------------------------------------------- |
|
96 // |
|
97 void CIpsSetDataStorer::ConstructL() |
|
98 { |
|
99 FUNC_LOG; |
|
100 iCenRepControl = CIpsSetDataCtrlCenrep::NewL(); |
|
101 iCenRepExtMail = CRepository::NewL( KCRUidExtendedSettingsUid ); |
|
102 } |
|
103 |
|
104 // ---------------------------------------------------------------------------- |
|
105 // ---------------------------------------------------------------------------- |
|
106 // |
|
107 CIpsSetDataStorer::~CIpsSetDataStorer() |
|
108 { |
|
109 FUNC_LOG; |
|
110 delete iCenRepSmtp; |
|
111 delete iCenRepExtMail; |
|
112 delete iCenRepAlwaysOnline; |
|
113 delete iCenRepDefaultData; |
|
114 delete iAccounts; |
|
115 delete iCenRepControl; |
|
116 } |
|
117 |
|
118 // ---------------------------------------------------------------------------- |
|
119 // ---------------------------------------------------------------------------- |
|
120 // |
|
121 CIpsSetDataStorer* CIpsSetDataStorer::NewL() |
|
122 { |
|
123 FUNC_LOG; |
|
124 CIpsSetDataStorer* self = NewLC(); |
|
125 CleanupStack::Pop( self ); |
|
126 |
|
127 return self; |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // ---------------------------------------------------------------------------- |
|
132 // |
|
133 CIpsSetDataStorer* CIpsSetDataStorer::NewLC() |
|
134 { |
|
135 FUNC_LOG; |
|
136 CIpsSetDataStorer* self = |
|
137 new ( ELeave ) CIpsSetDataStorer(); |
|
138 CleanupStack::PushL( self ); |
|
139 self->ConstructL(); |
|
140 |
|
141 return self; |
|
142 } |
|
143 |
|
144 // ---------------------------------------------------------------------------- |
|
145 // ---------------------------------------------------------------------------- |
|
146 // |
|
147 TInt CIpsSetDataStorer::CreateExtendedSettings( |
|
148 const TMsvId aMailboxId, |
|
149 const TUint32 aAccountId, |
|
150 const TUid& aProtocol, |
|
151 CIpsSetDataExtension& aExtendedMailSettings, |
|
152 const TBool /*aPopulateDefaults*/ ) |
|
153 { |
|
154 FUNC_LOG; |
|
155 // Initialize the settings |
|
156 aExtendedMailSettings.SetMailboxId( aMailboxId ); |
|
157 aExtendedMailSettings.SetAccountId( aAccountId ); |
|
158 aExtendedMailSettings.SetProtocol( aProtocol ); |
|
159 aExtendedMailSettings.SetExtensionId( |
|
160 IpsSetDataCtrlAccount::AccountIdToExtendedAccountId( |
|
161 aAccountId, aProtocol ) ); |
|
162 |
|
163 TInt error = KErrNone; |
|
164 |
|
165 // If populating has not failed, continue with creating the settings |
|
166 if ( error == KErrNone ) |
|
167 { |
|
168 // Create the settings |
|
169 TRAP( error, CreateExtendedSettingsL( aExtendedMailSettings ) ); |
|
170 |
|
171 if ( error != KErrNone ) |
|
172 { |
|
173 __ASSERT_DEBUG(EFalse, User::Panic( |
|
174 KIpsSetDataStorer , KErrNotFound ) ); |
|
175 } |
|
176 |
|
177 } |
|
178 |
|
179 return error; |
|
180 } |
|
181 |
|
182 // ---------------------------------------------------------------------------- |
|
183 // ---------------------------------------------------------------------------- |
|
184 // |
|
185 TInt CIpsSetDataStorer::DeleteExtendedSettingsL( |
|
186 const TMsvEntry& aMailbox ) |
|
187 { |
|
188 FUNC_LOG; |
|
189 TMsvId accountId; |
|
190 |
|
191 if ( aMailbox.iMtm == KSenduiMtmPop3Uid ) |
|
192 { |
|
193 TPopAccount popAccount; |
|
194 AccountsL()->GetPopAccountL( aMailbox.iServiceId, popAccount ); |
|
195 accountId = popAccount.iPopAccountId; |
|
196 } |
|
197 else |
|
198 { |
|
199 TImapAccount imapAccount; |
|
200 AccountsL()->GetImapAccountL( aMailbox.iServiceId, imapAccount ); |
|
201 accountId = imapAccount.iImapAccountId; |
|
202 } |
|
203 |
|
204 TInt error = DeleteExtendedSettingsL( |
|
205 accountId, aMailbox.iMtm ); |
|
206 |
|
207 return error; |
|
208 } |
|
209 |
|
210 // ---------------------------------------------------------------------------- |
|
211 // ---------------------------------------------------------------------------- |
|
212 // |
|
213 TInt CIpsSetDataStorer::SaveExtendedSettings( |
|
214 const CIpsSetDataExtension& aExtendedMailSettings ) |
|
215 { |
|
216 FUNC_LOG; |
|
217 // Here it is good idea to make sure, that the settings are valid, so |
|
218 // no corrupted data is going in. |
|
219 if ( aExtendedMailSettings.IsSettingsValid() ) |
|
220 { |
|
221 TRAPD( error, SaveExtendedSettingsL( aExtendedMailSettings ) ); |
|
222 |
|
223 if ( error != KErrNone ) |
|
224 { |
|
225 __ASSERT_DEBUG(EFalse, User::Panic( |
|
226 KIpsSetDataCenRepKeyNotFound , KErrNotFound ) ); |
|
227 } |
|
228 |
|
229 return error; |
|
230 } |
|
231 else |
|
232 { |
|
233 return KErrNotReady; |
|
234 } |
|
235 } |
|
236 |
|
237 // ---------------------------------------------------------------------------- |
|
238 // ---------------------------------------------------------------------------- |
|
239 // |
|
240 TInt CIpsSetDataStorer::SaveImap4Settings( |
|
241 const TUint32 aAccountId, |
|
242 const CImImap4Settings& aImap4Settings ) |
|
243 { |
|
244 FUNC_LOG; |
|
245 TImapAccount imapAccountId; |
|
246 imapAccountId.iImapAccountId = aAccountId; |
|
247 |
|
248 TRAPD( error, |
|
249 AccountsL()->SaveImapSettingsL( imapAccountId, aImap4Settings ) ); |
|
250 |
|
251 if ( error != KErrNone ) |
|
252 { |
|
253 __ASSERT_DEBUG(EFalse, User::Panic( |
|
254 KIpsSetDataCenRepKeyNotFound , KErrNotFound ) ); |
|
255 } |
|
256 |
|
257 return error; |
|
258 } |
|
259 |
|
260 // ---------------------------------------------------------------------------- |
|
261 // ---------------------------------------------------------------------------- |
|
262 // |
|
263 TInt CIpsSetDataStorer::SavePop3Settings( |
|
264 const TUint32 aAccountId, |
|
265 const CImPop3Settings& aPop3Settings ) |
|
266 { |
|
267 FUNC_LOG; |
|
268 TPopAccount popAccountId; |
|
269 popAccountId.iPopAccountId = aAccountId; |
|
270 |
|
271 TRAPD( error, |
|
272 AccountsL()->SavePopSettingsL( popAccountId, aPop3Settings ) ); |
|
273 |
|
274 if ( error != KErrNone ) |
|
275 { |
|
276 __ASSERT_DEBUG(EFalse, User::Panic( |
|
277 KIpsSetDataCenRepKeyNotFound , KErrNotFound ) ); |
|
278 } |
|
279 |
|
280 return error; |
|
281 } |
|
282 |
|
283 // ---------------------------------------------------------------------------- |
|
284 // ---------------------------------------------------------------------------- |
|
285 // |
|
286 TInt CIpsSetDataStorer::SaveSmtpSettings( |
|
287 const TUint32 aAccountId, |
|
288 const CImSmtpSettings& aSmtpSettings ) |
|
289 { |
|
290 FUNC_LOG; |
|
291 TSmtpAccount smtpAccountId; |
|
292 smtpAccountId.iSmtpAccountId = aAccountId; |
|
293 |
|
294 TRAPD( error, |
|
295 AccountsL()->SaveSmtpSettingsL( smtpAccountId, aSmtpSettings ) ); |
|
296 |
|
297 if ( error != KErrNone ) |
|
298 { |
|
299 __ASSERT_DEBUG(EFalse, User::Panic( |
|
300 KIpsSetDataCenRepKeyNotFound , KErrNotFound ) ); |
|
301 } |
|
302 |
|
303 return error; |
|
304 } |
|
305 |
|
306 // ---------------------------------------------------------------------------- |
|
307 // ---------------------------------------------------------------------------- |
|
308 // |
|
309 TInt CIpsSetDataStorer::LoadExtendedSettings( |
|
310 const TIpsSetDataStorerParams& aParams, |
|
311 CIpsSetDataExtension& aExtendedMailSettings ) |
|
312 { |
|
313 FUNC_LOG; |
|
314 // Make sure the mtm is valid email mtm |
|
315 TBool ok = IpsSetUtils::IsMailMtm( aParams.MtmId() ); |
|
316 |
|
317 // Choose the right way to Load the settings |
|
318 if ( ok && aParams.AccountId() != KErrNone ) |
|
319 { |
|
320 TRAPD( error, LoadExtendedSettingsL( |
|
321 aParams.AccountId(), aParams.MtmId(), aExtendedMailSettings ) ); |
|
322 |
|
323 if ( error != KErrNone ) |
|
324 { |
|
325 // This happens in case when extended settings are not created. |
|
326 // If mailbox is created via "creator" or there was been failure |
|
327 // in mailbox creation... |
|
328 //__ASSERT_DEBUG(EFalse, User::Panic( |
|
329 // KIpsSetDataCenRepKeyNotFound , KErrNotFound ) ); |
|
330 } |
|
331 |
|
332 return error; |
|
333 } |
|
334 else |
|
335 { |
|
336 return KErrNotSupported; |
|
337 } |
|
338 } |
|
339 |
|
340 // ---------------------------------------------------------------------------- |
|
341 // ---------------------------------------------------------------------------- |
|
342 // |
|
343 TInt CIpsSetDataStorer::LoadImap4Settings( |
|
344 const TUint32 aAccountId, |
|
345 CImImap4Settings& aImap4Settings ) |
|
346 { |
|
347 FUNC_LOG; |
|
348 TImapAccount imapAccountId; |
|
349 imapAccountId.iImapAccountId = aAccountId; |
|
350 |
|
351 TRAPD( error, |
|
352 AccountsL()->LoadImapSettingsL( imapAccountId, aImap4Settings ) ); |
|
353 |
|
354 if ( error != KErrNone ) |
|
355 { |
|
356 __ASSERT_DEBUG(EFalse, User::Panic( |
|
357 KIpsSetDataCenRepKeyNotFound , KErrNotFound ) ); |
|
358 } |
|
359 |
|
360 |
|
361 return error; |
|
362 } |
|
363 |
|
364 // ---------------------------------------------------------------------------- |
|
365 // ---------------------------------------------------------------------------- |
|
366 // |
|
367 TInt CIpsSetDataStorer::LoadPop3Settings( |
|
368 const TUint32 aAccountId, |
|
369 CImPop3Settings& aPop3Settings ) |
|
370 { |
|
371 FUNC_LOG; |
|
372 TPopAccount popAccountId; |
|
373 popAccountId.iPopAccountId = aAccountId; |
|
374 |
|
375 TRAPD( error, |
|
376 AccountsL()->LoadPopSettingsL( popAccountId, aPop3Settings ) ); |
|
377 |
|
378 if ( error != KErrNone ) |
|
379 { |
|
380 __ASSERT_DEBUG(EFalse, User::Panic( |
|
381 KIpsSetDataCenRepKeyNotFound , KErrNotFound ) ); |
|
382 } |
|
383 |
|
384 return error; |
|
385 } |
|
386 |
|
387 // ---------------------------------------------------------------------------- |
|
388 // ---------------------------------------------------------------------------- |
|
389 // |
|
390 TInt CIpsSetDataStorer::LoadSmtpSettings( |
|
391 const TUint32 aAccountId, |
|
392 CImSmtpSettings& aSmtpSettings ) |
|
393 { |
|
394 FUNC_LOG; |
|
395 |
|
396 TSmtpAccount smtpAccountId; |
|
397 smtpAccountId.iSmtpAccountId = aAccountId; |
|
398 |
|
399 TRAPD( error, |
|
400 AccountsL()->LoadSmtpSettingsL( smtpAccountId, aSmtpSettings ) ); |
|
401 |
|
402 if ( error != KErrNone ) |
|
403 { |
|
404 __ASSERT_DEBUG(EFalse, User::Panic( |
|
405 KIpsSetDataCenRepKeyNotFound , KErrNotFound ) ); |
|
406 } |
|
407 |
|
408 return error; |
|
409 } |
|
410 |
|
411 // ---------------------------------------------------------------------------- |
|
412 // ---------------------------------------------------------------------------- |
|
413 // |
|
414 void CIpsSetDataStorer::CreateExtendedSettingsL( |
|
415 const CIpsSetDataExtension& aExtendedMailSettings ) |
|
416 { |
|
417 FUNC_LOG; |
|
418 // Prepare account control |
|
419 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
420 iCenRepControl->SetActiveBaseKey( aExtendedMailSettings.ExtensionId() ); |
|
421 |
|
422 iCenRepControl->CreateToAccountL( EIpsSetDataCommonSetStatusFlagsH, |
|
423 EIpsSetDataCommonSetStatusFlagsL, |
|
424 aExtendedMailSettings.StatusFlags() ); |
|
425 |
|
426 iCenRepControl->CreateToAccountL( EIpsSetDataCommonSetMailboxId, |
|
427 aExtendedMailSettings.MailboxId() ); |
|
428 iCenRepControl->CreateToAccountL( EIpsSetDataCommonSetAccountId, |
|
429 static_cast<TInt>( aExtendedMailSettings.AccountId() ) ); |
|
430 iCenRepControl->CreateToAccountL( EIpsSetDataCommonSetExtensionId, |
|
431 static_cast<TInt>( aExtendedMailSettings.ExtensionId() ) ); |
|
432 iCenRepControl->CreateToAccountL( EIpsSetDataCommonSetProtocol, |
|
433 aExtendedMailSettings.Protocol().iUid ); |
|
434 iCenRepControl->CreateToAccountL( EIpsSetDataCommonSetEmailAddress, |
|
435 aExtendedMailSettings.EmailAddress() ); |
|
436 |
|
437 // Extended mailbox settings |
|
438 iCenRepControl->CreateToAccountL( EIpsSetDataExtSetEmailNotif, |
|
439 static_cast<TInt>( aExtendedMailSettings.EmailNotificationState() ) ); |
|
440 iCenRepControl->CreateToAccountL( EIpsSetDataExtSetIndicators, |
|
441 static_cast<TBool>( aExtendedMailSettings.NewMailIndicators() ) ); |
|
442 iCenRepControl->CreateToAccountL( EIpsSetDataExtSetHideMsgs, |
|
443 static_cast<TInt>( aExtendedMailSettings.HideMsgs() ) ); |
|
444 iCenRepControl->CreateToAccountL( EIpsSetDataExtSetOpenHtmlMail, |
|
445 static_cast<TInt>( aExtendedMailSettings.OpenHtmlMail() ) ); |
|
446 |
|
447 // Always Online Settings |
|
448 iCenRepControl->CreateToAccountL( EIpsSetDataAoVersion, |
|
449 static_cast<TInt>( aExtendedMailSettings.Version() ) ); |
|
450 iCenRepControl->CreateToAccountL( EIpsSetDataAoOnlineState, |
|
451 aExtendedMailSettings.AlwaysOnlineState() ); |
|
452 iCenRepControl->CreateToAccountL( EIpsSetDataAoWeekDays, |
|
453 aExtendedMailSettings.SelectedWeekDays() ); |
|
454 iCenRepControl->CreateToAccountL( EIpsSetDataAoTimeStartH, EIpsSetDataAoTimeStartL, |
|
455 aExtendedMailSettings.SelectedTimeStart().Int64() ); |
|
456 iCenRepControl->CreateToAccountL( EIpsSetDataAoTimeStopH, EIpsSetDataAoTimeStopL, |
|
457 aExtendedMailSettings.SelectedTimeStop().Int64() ); |
|
458 iCenRepControl->CreateToAccountL( EIpsSetDataAoInboxRefreshTime, |
|
459 aExtendedMailSettings.InboxRefreshTime() ); |
|
460 iCenRepControl->CreateToAccountL( EIpsSetDataAoUpdateMode, |
|
461 aExtendedMailSettings.UpdateMode() ); |
|
462 // Create the last update AO info |
|
463 TAOInfo aoInfo = aExtendedMailSettings.LastUpdateInfo(); |
|
464 iCenRepControl->CreateToAccountL( |
|
465 EIpsSetDataAoLastSuccessfulUpdateH, EIpsSetDataAoLastSuccessfulUpdateL, |
|
466 aoInfo.iLastSuccessfulUpdate.Int64() ); |
|
467 iCenRepControl->CreateToAccountL( |
|
468 EIpsSetDataAoLastUpdateFailed, aoInfo.iLastUpdateFailed ); |
|
469 iCenRepControl->CreateToAccountL( EIpsSetDataAoUpdateSuccessfulWithCurSettings, |
|
470 aoInfo.iUpdateSuccessfulWithCurSettings ); |
|
471 |
|
472 // Extra items |
|
473 iCenRepControl->CreateToAccountL( EIpsSetDataFsOutgoingLogin, |
|
474 aExtendedMailSettings.OutgoingLogin() ); |
|
475 |
|
476 iCenRepControl->CreateToAccountL( |
|
477 EIpsSetDataLastModifiedH, EIpsSetDataLastModifiedL, |
|
478 aExtendedMailSettings.LastModified().Int64() ); |
|
479 |
|
480 iCenRepControl->CreateToAccountL( EIpsSetDataLastSyncStatus, |
|
481 aExtendedMailSettings.LastSyncStatus() ); |
|
482 |
|
483 //<cmail> |
|
484 iCenRepControl->CreateToAccountL( EIpsSetDataHideUserNameAndAddress, |
|
485 aExtendedMailSettings.DataHidden() ); |
|
486 //</cmail> |
|
487 iCenRepControl->CreateToAccountL( |
|
488 EIpsSetDateEmnReceivedButNotSyncedFlag, |
|
489 aExtendedMailSettings.EmailNotificationState() ); |
|
490 |
|
491 iCenRepControl->CreateToAccountL( |
|
492 EIpsSetDataFirstEMNReceivedFlag, |
|
493 aExtendedMailSettings.FirstEmnReceived() ); |
|
494 } |
|
495 |
|
496 // ---------------------------------------------------------------------------- |
|
497 // ---------------------------------------------------------------------------- |
|
498 // |
|
499 TInt CIpsSetDataStorer::DeleteExtendedSettingsL( |
|
500 const TUint32 aAccountId, |
|
501 const TUid& aMtmId ) |
|
502 { |
|
503 FUNC_LOG; |
|
504 TInt error = KErrNone; |
|
505 // Prepare account control |
|
506 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
507 iCenRepControl->SetActiveBaseKey( aAccountId, aMtmId ); |
|
508 |
|
509 // We don't care about errors in case of deletion |
|
510 // seems that KErrNotFound appears often |
|
511 iCenRepControl->DeleteFromAccount( EIpsSetDataCommonSetStatusFlagsH, |
|
512 EIpsSetDataCommonSetStatusFlagsL ); |
|
513 iCenRepControl->DeleteFromAccount( EIpsSetDataCommonSetMailboxId ); |
|
514 iCenRepControl->DeleteFromAccount( EIpsSetDataCommonSetAccountId ); |
|
515 iCenRepControl->DeleteFromAccount( EIpsSetDataCommonSetExtensionId ); |
|
516 iCenRepControl->DeleteFromAccount( EIpsSetDataCommonSetProtocol ); |
|
517 iCenRepControl->DeleteFromAccount( EIpsSetDataCommonSetEmailAddress ); |
|
518 |
|
519 // Extended mailbox settings |
|
520 iCenRepControl->DeleteFromAccount( EIpsSetDataExtSetEmailNotif ); |
|
521 iCenRepControl->DeleteFromAccount( EIpsSetDataExtSetIndicators ); |
|
522 iCenRepControl->DeleteFromAccount( EIpsSetDataExtSetHideMsgs ); |
|
523 iCenRepControl->DeleteFromAccount( EIpsSetDataExtSetOpenHtmlMail ); |
|
524 |
|
525 // Always Online Settings |
|
526 iCenRepControl->DeleteFromAccount( EIpsSetDataAoVersion ); |
|
527 iCenRepControl->DeleteFromAccount( EIpsSetDataAoOnlineState ); |
|
528 iCenRepControl->DeleteFromAccount( EIpsSetDataAoWeekDays ); |
|
529 iCenRepControl->DeleteFromAccount( EIpsSetDataAoTimeStartH, |
|
530 EIpsSetDataAoTimeStartL ); |
|
531 iCenRepControl->DeleteFromAccount( EIpsSetDataAoTimeStopH, |
|
532 EIpsSetDataAoTimeStopL ); |
|
533 iCenRepControl->DeleteFromAccount( EIpsSetDataAoInboxRefreshTime ); |
|
534 iCenRepControl->DeleteFromAccount( EIpsSetDataAoUpdateMode ); |
|
535 iCenRepControl->DeleteFromAccount( EIpsSetDataAoLastSuccessfulUpdateH, |
|
536 EIpsSetDataAoLastSuccessfulUpdateL ); |
|
537 iCenRepControl->DeleteFromAccount( EIpsSetDataAoLastUpdateFailed ); |
|
538 iCenRepControl->DeleteFromAccount( |
|
539 EIpsSetDataAoUpdateSuccessfulWithCurSettings ); |
|
540 |
|
541 // Extra items |
|
542 iCenRepControl->DeleteFromAccount( EIpsSetDataFsOutgoingLogin ); |
|
543 iCenRepControl->DeleteFromAccount( EIpsSetDataLastModifiedH, |
|
544 EIpsSetDataLastModifiedL ); |
|
545 iCenRepControl->DeleteFromAccount( EIpsSetDataLastSyncStatus ); |
|
546 iCenRepControl->DeleteFromAccount( |
|
547 EIpsSetDateEmnReceivedButNotSyncedFlag ); |
|
548 |
|
549 return error; |
|
550 } |
|
551 // ---------------------------------------------------------------------------- |
|
552 // ---------------------------------------------------------------------------- |
|
553 // |
|
554 void CIpsSetDataStorer::SaveExtendedSettingsL( |
|
555 const CIpsSetDataExtension& aExtendedMailSettings ) |
|
556 { |
|
557 FUNC_LOG; |
|
558 // Prepare account control |
|
559 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
560 iCenRepControl->SetActiveBaseKey( aExtendedMailSettings.ExtensionId() ); |
|
561 |
|
562 // Store the settings |
|
563 // Common Settings |
|
564 |
|
565 iCenRepControl->SetToAccountL( EIpsSetDataCommonSetStatusFlagsH, |
|
566 EIpsSetDataCommonSetStatusFlagsL, |
|
567 aExtendedMailSettings.StatusFlags() ); |
|
568 |
|
569 iCenRepControl->SetToAccountL( EIpsSetDataCommonSetMailboxId, |
|
570 aExtendedMailSettings.MailboxId() ); |
|
571 iCenRepControl->SetToAccountL( EIpsSetDataCommonSetAccountId, |
|
572 static_cast<TInt>( aExtendedMailSettings.AccountId() ) ); |
|
573 iCenRepControl->SetToAccountL( EIpsSetDataCommonSetExtensionId, |
|
574 static_cast<TInt>( aExtendedMailSettings.ExtensionId() ) ); |
|
575 iCenRepControl->SetToAccountL( EIpsSetDataCommonSetProtocol, |
|
576 aExtendedMailSettings.Protocol().iUid ); |
|
577 iCenRepControl->SetToAccountL( EIpsSetDataCommonSetEmailAddress, |
|
578 aExtendedMailSettings.EmailAddress() ); |
|
579 |
|
580 // Extended mailbox settings |
|
581 iCenRepControl->SetToAccountL( EIpsSetDataExtSetEmailNotif, |
|
582 static_cast<TInt>( aExtendedMailSettings.EmailNotificationState() ) ); |
|
583 iCenRepControl->SetToAccountL( EIpsSetDataExtSetIndicators, |
|
584 static_cast<TBool>( aExtendedMailSettings.NewMailIndicators() ) ); |
|
585 iCenRepControl->SetToAccountL( EIpsSetDataExtSetHideMsgs, |
|
586 static_cast<TInt>( aExtendedMailSettings.HideMsgs() ) ); |
|
587 iCenRepControl->SetToAccountL( EIpsSetDataExtSetOpenHtmlMail, |
|
588 static_cast<TBool>( aExtendedMailSettings.OpenHtmlMail() ) ); |
|
589 |
|
590 // Always Online Settings |
|
591 iCenRepControl->SetToAccountL( EIpsSetDataAoVersion, |
|
592 static_cast<TInt>( aExtendedMailSettings.Version() ) ); |
|
593 iCenRepControl->SetToAccountL( EIpsSetDataAoOnlineState, |
|
594 aExtendedMailSettings.AlwaysOnlineState() ); |
|
595 iCenRepControl->SetToAccountL( EIpsSetDataAoWeekDays, |
|
596 aExtendedMailSettings.SelectedWeekDays() ); |
|
597 iCenRepControl->SetToAccountL( EIpsSetDataAoTimeStartH, |
|
598 EIpsSetDataAoTimeStartL, |
|
599 aExtendedMailSettings.SelectedTimeStart().Int64() ); |
|
600 iCenRepControl->SetToAccountL( EIpsSetDataAoTimeStopH, |
|
601 EIpsSetDataAoTimeStopL, |
|
602 aExtendedMailSettings.SelectedTimeStop().Int64() ); |
|
603 iCenRepControl->SetToAccountL( EIpsSetDataAoInboxRefreshTime, |
|
604 aExtendedMailSettings.InboxRefreshTime() ); |
|
605 iCenRepControl->SetToAccountL( EIpsSetDataAoUpdateMode, |
|
606 aExtendedMailSettings.UpdateMode() ); |
|
607 |
|
608 TAOInfo aoInfo = aExtendedMailSettings.LastUpdateInfo(); |
|
609 iCenRepControl->SetToAccountL( |
|
610 EIpsSetDataAoLastSuccessfulUpdateH, |
|
611 EIpsSetDataAoLastSuccessfulUpdateL, |
|
612 aoInfo.iLastSuccessfulUpdate.Int64() ); |
|
613 iCenRepControl->SetToAccountL( |
|
614 EIpsSetDataAoLastUpdateFailed, aoInfo.iLastUpdateFailed ); |
|
615 iCenRepControl->SetToAccountL( |
|
616 EIpsSetDataAoUpdateSuccessfulWithCurSettings, |
|
617 aoInfo.iUpdateSuccessfulWithCurSettings ); |
|
618 |
|
619 iCenRepControl->SetToAccountL( EIpsSetDataFsOutgoingLogin, |
|
620 aExtendedMailSettings.OutgoingLogin() ); |
|
621 |
|
622 iCenRepControl->SetToAccountL( |
|
623 EIpsSetDataLastModifiedH, EIpsSetDataLastModifiedL, |
|
624 aExtendedMailSettings.LastModified().Int64() ); |
|
625 iCenRepControl->SetToAccountL( EIpsSetDataLastSyncStatus, |
|
626 aExtendedMailSettings.LastSyncStatus() ); |
|
627 |
|
628 iCenRepControl->SetToAccountL( |
|
629 EIpsSetDateEmnReceivedButNotSyncedFlag, |
|
630 aExtendedMailSettings.EmnReceivedButNotSyncedFlag() ); |
|
631 |
|
632 iCenRepControl->SetToAccountL( |
|
633 EIpsSetDataFirstEMNReceivedFlag, |
|
634 aExtendedMailSettings.FirstEmnReceived() ); |
|
635 } |
|
636 |
|
637 // ---------------------------------------------------------------------------- |
|
638 // ---------------------------------------------------------------------------- |
|
639 // |
|
640 void CIpsSetDataStorer::LoadExtendedSettingsL( |
|
641 const TUint32 aAccountId, |
|
642 const TUid& aMtmId, |
|
643 CIpsSetDataExtension& aExtendedMailSettings ) |
|
644 { |
|
645 FUNC_LOG; |
|
646 |
|
647 // Prepare account control |
|
648 iCenRepControl->SetActiveCentralRepository( *iCenRepExtMail ); |
|
649 iCenRepControl->SetActiveBaseKey( aAccountId, aMtmId ); |
|
650 |
|
651 // Load the settings |
|
652 // Common Settings |
|
653 TInt error = KErrNone; |
|
654 TInt value = 0; |
|
655 |
|
656 // EIpsSetDataCommonSetAccountId |
|
657 // |
|
658 error = iCenRepControl->GetFromAccount( |
|
659 EIpsSetDataCommonSetAccountId, value ); |
|
660 if ( error == KErrNone ) |
|
661 { |
|
662 aExtendedMailSettings.SetAccountId( value ); |
|
663 } |
|
664 else if ( error == KErrNotFound ) |
|
665 { |
|
666 // extended settings are not created at all |
|
667 // create now |
|
668 TMsvId service = 0; |
|
669 TMsvId smtpServ = 0; |
|
670 IpsSetUtils::GetServiceIdFromAccountIdL( |
|
671 aAccountId, aMtmId, service, smtpServ ); |
|
672 |
|
673 aExtendedMailSettings.PopulateDefaults(); |
|
674 CreateExtendedSettings( |
|
675 service, aAccountId, aMtmId, |
|
676 aExtendedMailSettings, EFalse ); |
|
677 } |
|
678 else |
|
679 { |
|
680 User::Leave( error ); |
|
681 } |
|
682 |
|
683 // EIpsSetDataCommonSetMailboxId |
|
684 // |
|
685 error = iCenRepControl->GetFromAccount( EIpsSetDataCommonSetMailboxId, value ); |
|
686 if ( error == KErrNone ) |
|
687 { |
|
688 aExtendedMailSettings.SetMailboxId( static_cast<TMsvId>( value ) ); |
|
689 } |
|
690 else if ( error == KErrNotFound ) |
|
691 { |
|
692 // creating mailbox id to account settings if not found |
|
693 TMsvId service = 0; |
|
694 TMsvId smtpServ = 0; |
|
695 IpsSetUtils::GetServiceIdFromAccountIdL( |
|
696 aAccountId, aMtmId, service, smtpServ ); |
|
697 aExtendedMailSettings.SetMailboxId( static_cast<TMsvId>( service ) ); |
|
698 |
|
699 TRAP_IGNORE( iCenRepControl->CreateToAccountL( |
|
700 EIpsSetDataCommonSetMailboxId, service ) ); |
|
701 } |
|
702 else |
|
703 { |
|
704 User::Leave( error ); |
|
705 } |
|
706 |
|
707 // EIpsSetDataCommonSetExtensionId |
|
708 // |
|
709 error = iCenRepControl->GetFromAccount( |
|
710 EIpsSetDataCommonSetExtensionId, value ); |
|
711 if ( error == KErrNone ) |
|
712 { |
|
713 aExtendedMailSettings.SetExtensionId( value ); |
|
714 } |
|
715 else if ( error == KErrNotFound ) |
|
716 { |
|
717 // create extension id |
|
718 TUint32 extId = IpsSetDataCtrlAccount::AccountIdToExtendedAccountId( |
|
719 aAccountId, aMtmId ); |
|
720 |
|
721 TRAP_IGNORE( iCenRepControl->CreateToAccountL( |
|
722 EIpsSetDataCommonSetExtensionId, extId ) ); |
|
723 } |
|
724 else |
|
725 { |
|
726 User::Leave( error ); |
|
727 } |
|
728 |
|
729 // EIpsSetDataCommonSetProtocol |
|
730 // |
|
731 error = iCenRepControl->GetFromAccount( EIpsSetDataCommonSetProtocol, value ); |
|
732 if ( error == KErrNone ) |
|
733 { |
|
734 aExtendedMailSettings.SetProtocol( TUid::Uid( value ) ); |
|
735 } |
|
736 else if ( error == KErrNotFound && |
|
737 ( aMtmId == KSenduiMtmPop3Uid || |
|
738 aMtmId == KSenduiMtmImap4Uid ) ) |
|
739 { |
|
740 TRAP_IGNORE( iCenRepControl->CreateToAccountL( |
|
741 EIpsSetDataCommonSetProtocol, aMtmId.iUid ) ); |
|
742 } |
|
743 else |
|
744 { |
|
745 aExtendedMailSettings.SetProtocol( aMtmId ); |
|
746 } |
|
747 |
|
748 // EIpsSetDataCommonSetStatusFlagsH, EIpsSetDataCommonSetStatusFlagsL |
|
749 // |
|
750 TInt64 flags = 0; |
|
751 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
752 EIpsSetDataCommonSetStatusFlagsH, EIpsSetDataCommonSetStatusFlagsL, |
|
753 KIpsSetExtDefaultStatusFlags, flags ); |
|
754 aExtendedMailSettings.SetStatusFlags( flags ); |
|
755 |
|
756 // EIpsSetDataCommonSetEmailAddress |
|
757 // |
|
758 TIpsSetUtilsTextPlain text; |
|
759 error = iCenRepControl->GetTextFromAccount( |
|
760 EIpsSetDataCommonSetEmailAddress, text ); |
|
761 TInt atPos = text.Locate( KIpsSetStorerAtChar ); |
|
762 if ( error == KErrNone && atPos > 0 ) |
|
763 { |
|
764 aExtendedMailSettings.SetEmailAddress( text ); |
|
765 } |
|
766 else |
|
767 { |
|
768 CImSmtpSettings* smtpSet = IpsSetUtils::GetSmtpSettingsFromAccountIdL( |
|
769 aAccountId, aMtmId ); |
|
770 text.Copy( smtpSet->EmailAddress() ); |
|
771 delete smtpSet; |
|
772 smtpSet = NULL; |
|
773 aExtendedMailSettings.SetEmailAddress( text ); |
|
774 |
|
775 if ( error == KErrNotFound ) |
|
776 { |
|
777 TRAP_IGNORE( iCenRepControl->CreateToAccountL( |
|
778 EIpsSetDataCommonSetEmailAddress, text ) ); |
|
779 } |
|
780 else if ( atPos == KErrNotFound ) |
|
781 { |
|
782 TRAP_IGNORE( iCenRepControl->SetToAccountL( |
|
783 EIpsSetDataCommonSetEmailAddress, text ) ); |
|
784 } |
|
785 } |
|
786 |
|
787 // EIpsSetDataExtSetEmailNotif |
|
788 // |
|
789 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
790 EIpsSetDataExtSetEmailNotif, |
|
791 KIpsSetExtDefaultEmailNotificationState, value ); |
|
792 aExtendedMailSettings.SetEmailNotificationState( |
|
793 static_cast<TIpsSetDataEmnStates>( value ) ); |
|
794 |
|
795 // EIpsSetDataExtSetIndicators |
|
796 // |
|
797 TBool result = ETrue; |
|
798 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
799 EIpsSetDataExtSetIndicators, KIpsSetExtDefaultNewMailIndicators, |
|
800 result ); |
|
801 aExtendedMailSettings.SetNewMailIndicators( result ); |
|
802 |
|
803 // EIpsSetDataExtSetHideMsgs |
|
804 // |
|
805 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
806 EIpsSetDataExtSetHideMsgs, KIpsSetExtDefaultHideMsgs, |
|
807 result ); |
|
808 aExtendedMailSettings.SetHideMsgs( result ); |
|
809 |
|
810 // EIpsSetDataExtSetOpenHtmlMail |
|
811 // |
|
812 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
813 EIpsSetDataExtSetOpenHtmlMail, |
|
814 KIpsSetExtDefaultOpenHtmlMail, value); |
|
815 aExtendedMailSettings.SetOpenHtmlMail( value ); |
|
816 |
|
817 // EIpsSetDataAoOnlineState |
|
818 // |
|
819 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
820 EIpsSetDataAoOnlineState, KIpsSetExtDefaultAlwaysOnlineState |
|
821 ,value ); |
|
822 aExtendedMailSettings.SetAlwaysOnlineState( |
|
823 static_cast<TIpsSetDataAoStates>( value ) ); |
|
824 |
|
825 // EIpsSetDataAoWeekDays |
|
826 // |
|
827 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
828 EIpsSetDataAoWeekDays, KIpsSetExtDefaultSelectedWeekDays |
|
829 ,value ); |
|
830 aExtendedMailSettings.SetSelectedWeekDays( value ); |
|
831 |
|
832 // EIpsSetDataAoTimeStartH, EIpsSetDataAoTimeStartL |
|
833 // |
|
834 TInt64 value64 = 0; |
|
835 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
836 EIpsSetDataAoTimeStartH, EIpsSetDataAoTimeStartL, |
|
837 KIpsSetExtDefaultSelectedTimeStart, value64 ); |
|
838 aExtendedMailSettings.SetSelectedTimeStart( value64 ); |
|
839 |
|
840 // EIpsSetDataAoTimeStopH, EIpsSetDataAoTimeStopL |
|
841 // |
|
842 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
843 EIpsSetDataAoTimeStopH, EIpsSetDataAoTimeStopL, |
|
844 KIpsSetExtDefaultSelectedTimeStop, value64 ); |
|
845 aExtendedMailSettings.SetSelectedTimeStop( value64 ); |
|
846 |
|
847 // EIpsSetDataAoInboxRefreshTime |
|
848 // |
|
849 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
850 EIpsSetDataAoInboxRefreshTime, |
|
851 KIpsSetExtDefaultInboxRefreshTime ,value ); |
|
852 aExtendedMailSettings.SetInboxRefreshTime( value ); |
|
853 |
|
854 // EIpsSetDataAoUpdateMode |
|
855 // |
|
856 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
857 EIpsSetDataAoUpdateMode, |
|
858 KIpsSetExtDefaultUpdateMode, value ); |
|
859 aExtendedMailSettings.SetUpdateMode( |
|
860 static_cast<TIpsSetDataAoUpdateModes>( value ) ); |
|
861 |
|
862 TAOInfo aoInfo; |
|
863 // Load the last update info |
|
864 |
|
865 // EIpsSetDataAoLastSuccessfulUpdateH, EIpsSetDataAoLastSuccessfulUpdateL |
|
866 // |
|
867 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
868 EIpsSetDataAoLastSuccessfulUpdateH, EIpsSetDataAoLastSuccessfulUpdateL, |
|
869 KIpsSetExtDefaultTAOInfoLastSuccessfulUpdate , value64 ); |
|
870 aoInfo.iLastSuccessfulUpdate = value64; |
|
871 |
|
872 // EIpsSetDataAoLastUpdateFailed |
|
873 // |
|
874 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
875 EIpsSetDataAoLastUpdateFailed, |
|
876 KIpsSetExtDefaultTAOInfoLastUpdateFailed, result ); |
|
877 aoInfo.iLastUpdateFailed = result; |
|
878 |
|
879 // EIpsSetDataAoUpdateSuccessfulWithCurSettings |
|
880 // |
|
881 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
882 EIpsSetDataAoUpdateSuccessfulWithCurSettings, |
|
883 KIpsSetExtDefaultTAOInfoUpdateSuccessfulWithCurSettings, result ); |
|
884 aoInfo.iUpdateSuccessfulWithCurSettings = result; |
|
885 |
|
886 aExtendedMailSettings.SetLastUpdateInfo( aoInfo ); |
|
887 |
|
888 // EIpsSetDataFsOutgoingLogin |
|
889 // |
|
890 value = KIpsSetExtDefaultOutgoingLogin; |
|
891 error = iCenRepControl->GetFromAccount( |
|
892 EIpsSetDataFsOutgoingLogin, value ); |
|
893 if ( error == KErrNotFound ) |
|
894 { |
|
895 TRAP_IGNORE( value = SolveOutgoingLoginMethodL( |
|
896 aAccountId, aMtmId ) ); |
|
897 TRAP_IGNORE( iCenRepControl->CreateToAccountL( |
|
898 EIpsSetDataFsOutgoingLogin, value ) ); |
|
899 } |
|
900 aExtendedMailSettings.SetOutgoingLogin( value ); |
|
901 |
|
902 // EIpsSetDataLastModifiedH, EIpsSetDataLastModifiedL |
|
903 // |
|
904 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
905 EIpsSetDataLastModifiedH, EIpsSetDataLastModifiedL, |
|
906 KIpsSetExtDefaultLastModified, value64 ); |
|
907 aExtendedMailSettings.SetLastModified( value64 ); |
|
908 |
|
909 // EIpsSetDataLastSyncStatus |
|
910 // |
|
911 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
912 EIpsSetDataLastSyncStatus, |
|
913 KIpsSetExtDefaultSyncStatus, value ); |
|
914 aExtendedMailSettings.SetSyncStatus( value ); |
|
915 |
|
916 //<cmail> |
|
917 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
918 EIpsSetDataHideUserNameAndAddress, |
|
919 KIpsSetExtDefaultHiddenData, result ); |
|
920 aExtendedMailSettings.SetDataHidden( result ); |
|
921 //</cmail> |
|
922 |
|
923 // EIpsSetDateEmnReceivedButNotSyncedFlag |
|
924 // |
|
925 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
926 EIpsSetDateEmnReceivedButNotSyncedFlag, |
|
927 KIpsSetExtDefaultEmnReceivedButNotSyncedFlag, value ); |
|
928 aExtendedMailSettings.SetEmnReceivedButNotSyncedFlag( value ); |
|
929 |
|
930 error = iCenRepControl->GetFromAccountAndCreateIfNotFound( |
|
931 EIpsSetDataFirstEMNReceivedFlag, |
|
932 KIpsSetExtDefaultFirstEMNReceived ,value ); |
|
933 aExtendedMailSettings.SetFirstEmnReceived( value ); |
|
934 } |
|
935 |
|
936 // ---------------------------------------------------------------------------- |
|
937 // ---------------------------------------------------------------------------- |
|
938 // |
|
939 CEmailAccounts* CIpsSetDataStorer::AccountsL() |
|
940 { |
|
941 FUNC_LOG; |
|
942 if ( !iAccounts ) |
|
943 { |
|
944 iAccounts = CEmailAccounts::NewL(); |
|
945 } |
|
946 |
|
947 return iAccounts; |
|
948 } |
|
949 |
|
950 // ---------------------------------------------------------------------------- |
|
951 // function sets EIpsSetDataFsOutgoingLogin setting to correct value if |
|
952 // it not set in cenrep (situation with old imum mailboxes) |
|
953 // ---------------------------------------------------------------------------- |
|
954 // |
|
955 TInt CIpsSetDataStorer::SolveOutgoingLoginMethodL( |
|
956 const TUint32 aAccountId, |
|
957 const TUid& aMtmId ) |
|
958 { |
|
959 FUNC_LOG; |
|
960 TInt ret = CIpsSetData::EOwnOutgoing; |
|
961 TMsvId serviceId = 0; |
|
962 TMsvId smtpId = 0; |
|
963 IpsSetUtils::GetServiceIdFromAccountIdL( |
|
964 aAccountId, aMtmId, serviceId, smtpId ); |
|
965 |
|
966 TBuf8<KIpsSetUiMaxPasswordLength> incPass; |
|
967 TBuf8<KIpsSetUiMaxPasswordLength> incUser; |
|
968 TBuf8<KIpsSetUiMaxPasswordLength> outPass; |
|
969 TBuf8<KIpsSetUiMaxPasswordLength> outUser; |
|
970 |
|
971 CEmailAccounts* accounts = CEmailAccounts::NewLC( ); |
|
972 if ( aMtmId == KSenduiMtmPop3Uid ) |
|
973 { |
|
974 TPopAccount popAccount; |
|
975 accounts->GetPopAccountL( serviceId, popAccount ); |
|
976 CImPop3Settings* popSettings = new ( ELeave ) CImPop3Settings; |
|
977 CleanupStack::PushL( popSettings ); |
|
978 accounts->LoadPopSettingsL( popAccount, *popSettings ); |
|
979 incUser.Copy( popSettings->LoginName() ); |
|
980 incPass.Copy( popSettings->Password() ); |
|
981 CleanupStack::PopAndDestroy( popSettings ); |
|
982 popSettings = NULL; |
|
983 } |
|
984 else if ( aMtmId == KSenduiMtmImap4Uid ) |
|
985 { |
|
986 TImapAccount imapAccount; |
|
987 accounts->GetImapAccountL( serviceId, imapAccount ); |
|
988 CImImap4Settings* imapSettings = new ( ELeave ) CImImap4Settings; |
|
989 CleanupStack::PushL( imapSettings ); |
|
990 accounts->LoadImapSettingsL( imapAccount, *imapSettings ); |
|
991 incUser.Copy( imapSettings->LoginName() ); |
|
992 incPass.Copy( imapSettings->Password() ); |
|
993 CleanupStack::PopAndDestroy( imapSettings ); |
|
994 imapSettings = NULL; |
|
995 } |
|
996 else |
|
997 { |
|
998 User::Leave( KErrArgument ); |
|
999 } |
|
1000 |
|
1001 TSmtpAccount smtpAccount; |
|
1002 accounts->GetSmtpAccountL( smtpId, smtpAccount ); |
|
1003 CImSmtpSettings* smtpSettings = new ( ELeave ) CImSmtpSettings; |
|
1004 CleanupStack::PushL( smtpSettings ); |
|
1005 accounts->LoadSmtpSettingsL( smtpAccount, *smtpSettings ); |
|
1006 outUser.Copy( smtpSettings->LoginName() ); |
|
1007 outPass.Copy( smtpSettings->Password() ); |
|
1008 CleanupStack::PopAndDestroy( 2, accounts ); |
|
1009 smtpSettings = NULL; |
|
1010 accounts = NULL; |
|
1011 |
|
1012 if ( outUser.Length() == 0 && outPass.Length() == 0 ) |
|
1013 { |
|
1014 // if outgoing pass and username missing, |
|
1015 // set value to CIpsSetData::ENoAuth |
|
1016 ret = CIpsSetData::ENoAuth; |
|
1017 } |
|
1018 else if ( outUser.Compare(incUser) == 0 && outPass.Compare(incPass) == 0 ) |
|
1019 { |
|
1020 // if outgoing loging are same as incoming |
|
1021 // from smtp settings, |
|
1022 // then use value CIpsSetData::EUseIncoming |
|
1023 ret = CIpsSetData::EUseIncoming; |
|
1024 } |
|
1025 else |
|
1026 { |
|
1027 // if outgoing pass and username are same as incoming, |
|
1028 // use value CIpsSetData::EOwnOutgoing |
|
1029 ret = CIpsSetData::EOwnOutgoing; |
|
1030 } |
|
1031 return ret; |
|
1032 } |
|
1033 |
|
1034 // End of File |
|
1035 |