|
1 /* |
|
2 * Copyright (c) 2002 - 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: |
|
15 * Message centre's mail/smail dialog. |
|
16 * Includes "remote mailboxes" and "Mailbox in use" setting items. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include <muiumsvuiserviceutilitiesinternal.h> //MsvUiServiceUtilities |
|
25 #include <msvuids.h> |
|
26 #include <AknQueryDialog.h> // CAknQueryDialog |
|
27 #include <aknViewAppUi.h> |
|
28 #include <aknradiobuttonsettingpage.h> |
|
29 #include <StringLoader.h> // StringLoader |
|
30 #include <e32base.h> |
|
31 |
|
32 #include <msvids.h> // KMsvUnknownServiceIndexEntryId |
|
33 #include "MceSettingsMultipleServicesDialog.h" |
|
34 #include "MceSettingsAccountManager.h" |
|
35 #include "MceSettingsIds.hrh" |
|
36 |
|
37 #include "MceSettingsArrays.h" |
|
38 #include "MceSettingsMtmServicesDialog.h" |
|
39 #include <MceSettings.rsg> |
|
40 |
|
41 #include <featmgr.h> |
|
42 #include <hlplch.h> // For HlpLauncher |
|
43 #include <csxhelp/mbxs.hlp.hrh> |
|
44 #include "mce.hlp.hrh" |
|
45 |
|
46 #include <bldvariant.hrh> |
|
47 #include <SenduiMtmUids.h> |
|
48 |
|
49 #include <ImumInternalApi.h> |
|
50 #include <ImumInHealthServices.h> |
|
51 #include <muiuflags.h> |
|
52 #include "MceSettingsUtils.h" |
|
53 #include <muiuemailtools.h> |
|
54 #include <mtudreg.h> |
|
55 |
|
56 #include <centralrepository.h> |
|
57 #include <miutset.h> |
|
58 #include <MessagingDomainCRKeys.h> |
|
59 #include <akninputblock.h> // CAknInputBlock |
|
60 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
61 #include <data_caging_path_literals.hrh> |
|
62 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
63 #include <imum.rsg> |
|
64 |
|
65 // CONSTANTS |
|
66 |
|
67 #define KMceApplicationUidValue 0x100058C5 |
|
68 const TUid KMceApplicationUid = {KMceApplicationUidValue}; |
|
69 |
|
70 const TInt KMceSettingsRemoteMailboxInUseSelectableEmailInUse = 0; |
|
71 const TInt KMceSettingsRemoteMailboxInUse = 1; |
|
72 const TInt KMceSettingsMailboxTextLength = 20; |
|
73 const TInt KMceSettingsArrayGranularity = 4; |
|
74 |
|
75 const TInt KMceSettingsMtmNameBufLength = KHumanReadableNameLength + 5; |
|
76 const TInt KMSKPosition = 3; |
|
77 |
|
78 _LIT(KMceMtmName1,"\t"); |
|
79 _LIT(KMceMtmName2,"\t\t"); |
|
80 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
81 _LIT( KMceDirAndFile,"MceSettings.rsc" ); |
|
82 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
83 |
|
84 // ================= MEMBER FUNCTIONS ======================= |
|
85 // --------------------------------------------------------------------------- |
|
86 // CMceSettingsMultipleServicesDialog::CreateAndExecuteL() |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 EXPORT_C TInt CMceSettingsMultipleServicesDialog::CreateAndExecuteL( |
|
90 MMceSettingsAccountManager& aManager, |
|
91 TUid aMessageType, |
|
92 CMsvSession* aSession ) |
|
93 { |
|
94 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
95 CMceSettingsMultipleServicesDialog* mailDlg =new( ELeave ) CMceSettingsMultipleServicesDialog(aManager, aMessageType, aSession ); |
|
96 CleanupStack::PushL( mailDlg ); |
|
97 FeatureManager::InitializeLibL(); |
|
98 TBool temp = FeatureManager::FeatureSupported( KFeatureIdSelectableEmail ); |
|
99 FeatureManager::UnInitializeLib(); |
|
100 if ( temp ) |
|
101 { |
|
102 mailDlg->ConstructL(R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG_MENUBAR_WITH_SELECTABLE_EMAIL ); |
|
103 CleanupStack::Pop( mailDlg ); |
|
104 return mailDlg->ExecuteLD( R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG_MENUBAR_WITH_SELECTABLE_EMAIL ); |
|
105 } |
|
106 else |
|
107 { |
|
108 mailDlg->ConstructL( R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG_MENUBAR ); |
|
109 CleanupStack::Pop( mailDlg ); |
|
110 return mailDlg->ExecuteLD( R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG ); |
|
111 |
|
112 } |
|
113 #else |
|
114 User::Leave( KErrNotSupported ); |
|
115 return KErrNotSupported; |
|
116 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------- |
|
120 // C++ default constructor can NOT contain any code that |
|
121 // might leave. |
|
122 // ---------------------------------------------------- |
|
123 CMceSettingsMultipleServicesDialog::CMceSettingsMultipleServicesDialog( |
|
124 MMceSettingsAccountManager& aManager, |
|
125 TUid aMessageType, |
|
126 CMsvSession* aSession ) |
|
127 : |
|
128 CMceSettingsTitlePaneHandlerDialog(), |
|
129 iManager( aManager ), |
|
130 iMessageType( aMessageType ), |
|
131 iSession( aSession ) |
|
132 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
133 ,iResources( *CCoeEnv::Static() ) |
|
134 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
135 ,iSubDialogOpen(EFalse) |
|
136 ,iS60WizLaunched( EFalse ) |
|
137 { |
|
138 } |
|
139 |
|
140 // ---------------------------------------------------- |
|
141 // CMceSettingsMultipleServicesDialog::Destructor |
|
142 // ---------------------------------------------------- |
|
143 CMceSettingsMultipleServicesDialog::~CMceSettingsMultipleServicesDialog() |
|
144 { |
|
145 if ( iMceIntegration ) |
|
146 { |
|
147 if ( iAiwServiceHandler ) |
|
148 { |
|
149 iAiwServiceHandler->Reset(); |
|
150 } |
|
151 delete iAiwServiceHandler; |
|
152 iAiwServiceHandler = NULL; |
|
153 } |
|
154 // do not delete iMtmAccountTypesDlg only used to notify msgs changes |
|
155 if ( iSessionObserverAdded ) |
|
156 { |
|
157 iManager.Session().RemoveObserver( *this ); |
|
158 } |
|
159 delete iEmailApi; |
|
160 iEmailApi = NULL; |
|
161 iMailboxArray.Reset(); |
|
162 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
163 iResources.Close(); |
|
164 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
165 if ( iProductIncludesSelectableEmail ) |
|
166 { |
|
167 if ( iAccountArray ) |
|
168 { |
|
169 delete iAccountArray; |
|
170 } |
|
171 } |
|
172 } |
|
173 |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // CMceSettingsMultipleServicesDialog::ConstructL() |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 void CMceSettingsMultipleServicesDialog::ConstructL(TInt aResource ) |
|
180 { |
|
181 CRepository* repository = NULL; |
|
182 TRAPD( ret, repository = CRepository::NewL( KCRUidSelectableDefaultEmailSettings ) ); |
|
183 |
|
184 if ( ret == KErrNone ) |
|
185 { |
|
186 // Check if there is other than platform email application registered |
|
187 // to handle S60 mailboxes |
|
188 TInt err = repository->Get( KIntegratedEmailAppMtmPluginId , iMtmPluginId ); |
|
189 if ( err != KErrNone ) |
|
190 { |
|
191 iMtmPluginId = 0; |
|
192 } |
|
193 } |
|
194 delete repository; |
|
195 |
|
196 FeatureManager::InitializeLibL(); |
|
197 if ( FeatureManager::FeatureSupported( KFeatureIdSelectableEmail ) ) |
|
198 { |
|
199 iProductIncludesSelectableEmail = ETrue; |
|
200 } |
|
201 else |
|
202 { |
|
203 iProductIncludesSelectableEmail = EFalse; |
|
204 } |
|
205 if( FeatureManager::FeatureSupported( KFeatureIdEmailMceIntegration ) ) |
|
206 { |
|
207 iMceIntegration = ETrue; |
|
208 } |
|
209 else |
|
210 { |
|
211 iMceIntegration = EFalse; |
|
212 } |
|
213 FeatureManager::UnInitializeLib(); |
|
214 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
215 TParse fp; |
|
216 fp.Set( KMceDirAndFile, &KDC_RESOURCE_FILES_DIR , NULL ); |
|
217 TFileName fileName = fp.FullName(); |
|
218 iResources.OpenL( fileName ); |
|
219 CMceSettingsTitlePaneHandlerDialog::ConstructL( aResource ); |
|
220 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
221 iEmailApi = CreateEmailApiL( iSession ); |
|
222 UpdateMailboxDataL(); |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // CMceSettingsMultipleServicesDialog::ConstructL() |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 void CMceSettingsMultipleServicesDialog::ConstructL() |
|
230 { |
|
231 CRepository* repository = NULL; |
|
232 TRAPD( ret, repository = CRepository::NewL( KCRUidSelectableDefaultEmailSettings ) ); |
|
233 |
|
234 if ( ret == KErrNone ) |
|
235 { |
|
236 // Check if there is other than platform email application registered |
|
237 // to handle S60 mailboxes |
|
238 TInt err = repository->Get( KIntegratedEmailAppMtmPluginId , iMtmPluginId ); |
|
239 if ( err != KErrNone ) |
|
240 { |
|
241 iMtmPluginId = 0; |
|
242 } |
|
243 } |
|
244 delete repository; |
|
245 |
|
246 FeatureManager::InitializeLibL(); |
|
247 if ( FeatureManager::FeatureSupported( KFeatureIdSelectableEmail ) ) |
|
248 { |
|
249 iProductIncludesSelectableEmail = ETrue; |
|
250 } |
|
251 else |
|
252 { |
|
253 iProductIncludesSelectableEmail = EFalse; |
|
254 } |
|
255 if ( FeatureManager::FeatureSupported( KFeatureIdEmailMceIntegration ) ) |
|
256 { |
|
257 iMceIntegration = ETrue; |
|
258 } |
|
259 else |
|
260 { |
|
261 iMceIntegration = EFalse; |
|
262 } |
|
263 FeatureManager::UnInitializeLib(); |
|
264 iEmailApi = CreateEmailApiL( iSession ); |
|
265 UpdateMailboxDataL(); |
|
266 } |
|
267 |
|
268 // ---------------------------------------------------- |
|
269 // CMceSettingsMultipleServicesDialog::OkToExitL |
|
270 // ---------------------------------------------------- |
|
271 TInt CMceSettingsMultipleServicesDialog::OkToExitL( TInt aButtonId ) |
|
272 { |
|
273 if ( iSubDialogOpen ) |
|
274 { |
|
275 // Subdialog open, don't close yet |
|
276 return EFalse; |
|
277 } |
|
278 TBool okToExit = CAknDialog::OkToExitL( aButtonId ); |
|
279 if ( ( aButtonId==EMceSettingsCmdSettingsDialogOpen ) || |
|
280 ( aButtonId==EMceSettingsCmdSettingsDialogChange ) ) |
|
281 { |
|
282 // Middle soft key pressed |
|
283 ProcessCommandL( aButtonId ); |
|
284 okToExit = EFalse; // Cannot exit, since MSK was pressed |
|
285 } |
|
286 else if ( aButtonId != EEikBidCancel && okToExit ) |
|
287 { |
|
288 RestoreTitleTextL(); |
|
289 } |
|
290 |
|
291 return okToExit; |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // CMceSettingsMultipleServicesDialog::UpdateMailboxDataL() |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 void CMceSettingsMultipleServicesDialog::UpdateMailboxDataL() |
|
299 { |
|
300 const MImumInHealthServices* healthApi = &iEmailApi->HealthServicesL(); |
|
301 |
|
302 // Get the array of the mailboxes for the current view |
|
303 MceSettingsUtils::GetHealthyMailboxListL( |
|
304 *healthApi, |
|
305 iMailboxArray, |
|
306 iMessageType != KSenduiMtmSyncMLEmailUid, |
|
307 iMessageType != KSenduiMtmSyncMLEmailUid, |
|
308 iMessageType == KSenduiMtmSyncMLEmailUid, |
|
309 EFalse ); |
|
310 iNumberOfMailboxes = iMailboxArray.Count(); |
|
311 } |
|
312 |
|
313 // ---------------------------------------------------- |
|
314 // CMceSettingsMultipleServicesDialog::ProcessCommandL |
|
315 // ---------------------------------------------------- |
|
316 void CMceSettingsMultipleServicesDialog::ProcessCommandL( TInt aCommandId ) |
|
317 { |
|
318 if ( aCommandId == EMceSettingsCmdSettingsDialogExit ) |
|
319 { |
|
320 CAknDialog::ProcessCommandL( aCommandId ); // hides menu |
|
321 if (iAvkonViewAppUi->ExitHidesInBackground()) |
|
322 { |
|
323 iAvkonViewAppUi->ProcessCommandL( EAknCmdHideInBackground ); |
|
324 } |
|
325 else |
|
326 { |
|
327 iAvkonViewAppUi->ProcessCommandL( EAknCmdExit ); |
|
328 } |
|
329 return; |
|
330 } |
|
331 |
|
332 CAknDialog::ProcessCommandL( aCommandId ); // hides menu |
|
333 |
|
334 if ( !iProductIncludesSelectableEmail ) |
|
335 { |
|
336 if ( !iEmailApi ) |
|
337 { |
|
338 iEmailApi = CreateEmailApiL( iSession ); |
|
339 } |
|
340 |
|
341 const MImumInHealthServices* healthApi = &iEmailApi->HealthServicesL(); |
|
342 |
|
343 TInt error = MceSettingsUtils::GetHealthyMailboxListL( *healthApi, |
|
344 iMailboxArray, |
|
345 ETrue, |
|
346 ETrue, |
|
347 ETrue,ETrue ); |
|
348 |
|
349 iNumberOfMailboxes = iMailboxArray.Count(); |
|
350 iMailboxArray.Reset(); |
|
351 error = MceSettingsUtils::GetHealthyMailboxListL( *healthApi, |
|
352 iMailboxArray, |
|
353 iMessageType != KSenduiMtmSyncMLEmailUid, |
|
354 iMessageType != KSenduiMtmSyncMLEmailUid, |
|
355 iMessageType == KSenduiMtmSyncMLEmailUid,ETrue ); |
|
356 } |
|
357 if ( iProductIncludesSelectableEmail ) |
|
358 { |
|
359 CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, |
|
360 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
361 TInt item = list->CurrentItemIndex(); |
|
362 |
|
363 // first item in listbox is not account and must not be used |
|
364 if ( item > 0 ) |
|
365 { |
|
366 item--; |
|
367 } |
|
368 |
|
369 TUid mtmType; |
|
370 |
|
371 if ( item >= 0 && iAccountArray->Count() && |
|
372 ( iAccountArray->Count() > item ) ) |
|
373 { |
|
374 TMsvEntry tentry; |
|
375 TMsvId dummyserviceid; |
|
376 if ( iSession->GetEntry( (*iAccountArray)[item].iUid.iUid, |
|
377 dummyserviceid, |
|
378 tentry ) == KErrNone ) |
|
379 { |
|
380 mtmType = tentry.iMtm; |
|
381 } |
|
382 else |
|
383 { |
|
384 mtmType.iUid = 0; |
|
385 } |
|
386 |
|
387 if ( ( mtmType == KSenduiMtmImap4Uid ) || |
|
388 ( mtmType == KSenduiMtmPop3Uid ) ) |
|
389 { |
|
390 mtmType = KSenduiMtmSmtpUid; |
|
391 } |
|
392 } |
|
393 |
|
394 if ( iActiveMenuBar == EMultipleServices ) |
|
395 { |
|
396 switch ( aCommandId ) |
|
397 { |
|
398 case EMceSettingsCmdSettingsDialogChange: |
|
399 { |
|
400 ShowListBoxSettingPageL(); |
|
401 } |
|
402 break; |
|
403 case EMceSettingsCmdSettingsDialogOpen: |
|
404 iManager.EditAccountL( (*iAccountArray)[item].iUid.iUid ); |
|
405 break; |
|
406 case EMceSettingsCmdSettingsDialogCreateNewEmpty: |
|
407 iManager.CreateNewAccountL( mtmType, KMsvNullIndexEntryId ); |
|
408 break; |
|
409 case EMceSettingsCmdSettingsDialogCreateNewEmptyImap: |
|
410 CreateNewImapPopL(); |
|
411 break; |
|
412 case EMceSettingsCmdSettingsDialogDelete: |
|
413 iManager.DeleteAccountL( (*iAccountArray)[item].iUid.iUid ); |
|
414 break; |
|
415 case EMceSettingsCmdSettingsDialogHelp: |
|
416 { |
|
417 LaunchHelpL(); |
|
418 } |
|
419 break; |
|
420 default : |
|
421 break; |
|
422 } |
|
423 } |
|
424 } |
|
425 else // iProductIncludesSelectableEmail |
|
426 { |
|
427 switch ( aCommandId ) |
|
428 { |
|
429 case EMceSettingsCmdSettingsDialogOpen: |
|
430 EditServicesL(); |
|
431 break; |
|
432 case EMceSettingsCmdSettingsDialogChange: |
|
433 ShowListBoxSettingPageL(); |
|
434 break; |
|
435 case EMceSettingsCmdSettingsDialogHelp: |
|
436 { |
|
437 LaunchHelpL(); |
|
438 } |
|
439 break; |
|
440 default : |
|
441 break; |
|
442 } |
|
443 } |
|
444 } |
|
445 |
|
446 // ---------------------------------------------------- |
|
447 // CMceSettingsMultipleServicesDialog::DynInitMenuPaneL |
|
448 // ---------------------------------------------------- |
|
449 void CMceSettingsMultipleServicesDialog::DynInitMenuPaneL( TInt aResourceId, |
|
450 CEikMenuPane* aMenuPane ) |
|
451 { |
|
452 if ( iProductIncludesSelectableEmail ) |
|
453 { |
|
454 CEikTextListBox* list = STATIC_CAST( CEikTextListBox*, |
|
455 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
456 TInt item = list->CurrentItemIndex(); |
|
457 |
|
458 if ( aResourceId == R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG_MENUPANE_WITH_SELECTABLE_EMAIL ) |
|
459 { |
|
460 TInt offset = 0; |
|
461 |
|
462 if ( item > offset ) |
|
463 { |
|
464 TUid mtmType; |
|
465 |
|
466 aMenuPane->DeleteMenuItem( |
|
467 EMceSettingsCmdSettingsDialogChange ); |
|
468 aMenuPane->DeleteMenuItem( |
|
469 EMceSettingsCmdSettingsDialogCreateNewEmpty ); |
|
470 |
|
471 aMenuPane->SetItemDimmed( EMceSettingsCmdSettingsDialogHelp, |
|
472 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
473 |
|
474 if ( iAccountArray->Count() && |
|
475 ( iAccountArray->Count() >= item ) ) |
|
476 { |
|
477 CMsvEntry* entry = iSession->GetEntryL( |
|
478 (*iAccountArray)[item-1].iUid.iUid ); |
|
479 |
|
480 TMsvEntry tentry = entry->Entry(); |
|
481 mtmType = tentry.iMtm; |
|
482 delete entry; |
|
483 |
|
484 if ( iAccountArray->Count() >= KMceMaxNumberOfMailboxes ) |
|
485 { |
|
486 if ( ( mtmType != KSenduiMtmImap4Uid ) && |
|
487 ( mtmType != KSenduiMtmPop3Uid ) ) |
|
488 { |
|
489 aMenuPane->DeleteMenuItem( |
|
490 EMceSettingsCmdSettingsDialogDelete ); |
|
491 } |
|
492 aMenuPane->DeleteMenuItem( |
|
493 EMceSettingsCmdSettingsDialogCreateNewEmptyImap ); |
|
494 } |
|
495 else if ( ( mtmType != KSenduiMtmImap4Uid ) && |
|
496 ( mtmType != KSenduiMtmPop3Uid ) && |
|
497 ( mtmType != KSenduiMtmSyncMLEmailUid ) ) |
|
498 { |
|
499 aMenuPane->DeleteMenuItem( |
|
500 EMceSettingsCmdSettingsDialogCreateNewEmptyImap ); |
|
501 aMenuPane->DeleteMenuItem( |
|
502 EMceSettingsCmdSettingsDialogDelete ); |
|
503 } |
|
504 } |
|
505 } |
|
506 |
|
507 else if ( item == KMceSettingsRemoteMailboxInUseSelectableEmailInUse ) |
|
508 { |
|
509 aMenuPane->DeleteMenuItem( |
|
510 EMceSettingsCmdSettingsDialogOpen ); |
|
511 aMenuPane->DeleteMenuItem( |
|
512 EMceSettingsCmdSettingsDialogDelete ); |
|
513 aMenuPane->DeleteMenuItem( |
|
514 EMceSettingsCmdSettingsDialogCreateNewEmpty ); |
|
515 |
|
516 aMenuPane->SetItemDimmed( EMceSettingsCmdSettingsDialogHelp, |
|
517 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
518 |
|
519 if ( iAccountArray->Count() >= KMceMaxNumberOfMailboxes ) |
|
520 { |
|
521 aMenuPane->DeleteMenuItem( |
|
522 EMceSettingsCmdSettingsDialogCreateNewEmptyImap ); |
|
523 } |
|
524 } |
|
525 else |
|
526 { |
|
527 aMenuPane->DeleteMenuItem( |
|
528 EMceSettingsCmdSettingsDialogChange ); |
|
529 aMenuPane->DeleteMenuItem( |
|
530 EMceSettingsCmdSettingsDialogCreateNewEmptyImap ); |
|
531 |
|
532 aMenuPane->SetItemDimmed( EMceSettingsCmdSettingsDialogHelp, |
|
533 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
534 |
|
535 if ( iAccountArray->Count() >= KMceMaxNumberOfMailboxes ) |
|
536 { |
|
537 TUid mtmType; |
|
538 |
|
539 CMsvEntry* entry = iSession->GetEntryL( |
|
540 (*iAccountArray)[item-1].iUid.iUid ); |
|
541 |
|
542 TMsvEntry tentry = entry->Entry(); |
|
543 mtmType = tentry.iMtm; |
|
544 delete entry; |
|
545 |
|
546 if ( ( mtmType != KSenduiMtmImap4Uid ) && |
|
547 ( mtmType != KSenduiMtmPop3Uid ) ) |
|
548 { |
|
549 aMenuPane->DeleteMenuItem( |
|
550 EMceSettingsCmdSettingsDialogDelete ); |
|
551 } |
|
552 aMenuPane->DeleteMenuItem( |
|
553 EMceSettingsCmdSettingsDialogCreateNewEmpty ); |
|
554 } |
|
555 } |
|
556 } |
|
557 } // iProductIncludesSelectableEmail |
|
558 else |
|
559 { |
|
560 if ( aResourceId == R_MCE_SETTINGS_MULTIPLE_SERVICES_DIALOG_MENUPANE ) |
|
561 { |
|
562 aMenuPane->SetItemDimmed( EMceSettingsCmdSettingsDialogHelp, |
|
563 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
564 |
|
565 CEikTextListBox* list = STATIC_CAST( CEikTextListBox*, |
|
566 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
567 if ( list->CurrentItemIndex() == 0 ) |
|
568 { |
|
569 aMenuPane->DeleteMenuItem( EMceSettingsCmdSettingsDialogChange ); |
|
570 } |
|
571 else |
|
572 { |
|
573 aMenuPane->DeleteMenuItem( EMceSettingsCmdSettingsDialogOpen ); |
|
574 } |
|
575 } |
|
576 } |
|
577 } |
|
578 // ---------------------------------------------------- |
|
579 // CMceSettingsMultipleServicesDialog::PreLayoutDynInitL |
|
580 // ---------------------------------------------------- |
|
581 void CMceSettingsMultipleServicesDialog::PreLayoutDynInitL( ) |
|
582 { |
|
583 CEikTextListBox* list = STATIC_CAST( CEikTextListBox*, |
|
584 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
585 |
|
586 THumanReadableName mtmName; |
|
587 |
|
588 iSettingsItemArray = new (ELeave) CDesCArrayFlat( |
|
589 KMceSettingsArrayGranularity ); |
|
590 if ( iProductIncludesSelectableEmail ) |
|
591 { |
|
592 if ( !iAccountArray ) |
|
593 { |
|
594 iAccountArray = new (ELeave) CUidNameArray( |
|
595 KMceSettingsArrayGranularity ); |
|
596 } |
|
597 |
|
598 SetAccountInUseL(); |
|
599 mtmName = iManager.MtmName( iMessageType ); |
|
600 UpdateServicesArrayL(); |
|
601 // Scrollbar |
|
602 list->CreateScrollBarFrameL( ETrue ); |
|
603 list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
604 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
605 } |
|
606 else // iProductIncludesSelectableEmail |
|
607 { |
|
608 mtmName = iManager.MtmName( iMessageType ); |
|
609 if ( iMessageType == KSenduiMtmSmtpUid ) |
|
610 { |
|
611 // email |
|
612 HBufC* text = StringLoader::LoadLC( |
|
613 R_MCE_SETTINGS_MAIL_REMOTE_MAILBOXES, iEikonEnv ); |
|
614 iSettingsItemArray->AppendL( *text ); |
|
615 CleanupStack::PopAndDestroy( text ); |
|
616 } |
|
617 else if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
618 { |
|
619 // syncML |
|
620 HBufC* text = StringLoader::LoadLC( |
|
621 R_MCE_SETTINGS_SYNCMAIL_MAILBOXES, iEikonEnv ); |
|
622 iSettingsItemArray->AppendL( *text ); |
|
623 CleanupStack::PopAndDestroy( text ); |
|
624 } |
|
625 else |
|
626 { |
|
627 // not email/syncML |
|
628 TBuf<KMceSettingsMtmNameBufLength> mtms; |
|
629 mtms.Copy( KMceMtmName1 ); |
|
630 mtms.Append( mtmName ); |
|
631 mtms.Append ( KMceMtmName2 ); |
|
632 iSettingsItemArray->AppendL( mtms ); |
|
633 } |
|
634 |
|
635 SetAccountInUseL(); |
|
636 } // iProductIncludesSelectableEmail |
|
637 |
|
638 CTextListBoxModel* model=list->Model(); |
|
639 model->SetItemTextArray( iSettingsItemArray ); |
|
640 list->SetListBoxObserver(this); |
|
641 |
|
642 if ( iMessageType == KSenduiMtmSmtpUid ) |
|
643 { |
|
644 // email |
|
645 HBufC* newText = StringLoader::LoadLC( |
|
646 R_MCE_EMAIL_SETTINGS_TITLE, iEikonEnv ); |
|
647 StoreTitleTextAndSetNewL( *newText ); |
|
648 CleanupStack::PopAndDestroy( newText ); |
|
649 } |
|
650 else if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
651 { |
|
652 // syncML |
|
653 HBufC* newText = StringLoader::LoadLC( |
|
654 R_MCE_TITLE_SETTINGS_SYNCMAIL, iEikonEnv ); |
|
655 StoreTitleTextAndSetNewL( *newText ); |
|
656 CleanupStack::PopAndDestroy( newText ); |
|
657 } |
|
658 else |
|
659 { |
|
660 // not email/syncML |
|
661 StoreTitleTextAndSetNewL( mtmName ); |
|
662 } |
|
663 |
|
664 iManager.Session().AddObserverL( *this ); |
|
665 iSessionObserverAdded = ETrue; |
|
666 SetMSKButtonL(); |
|
667 } |
|
668 |
|
669 // ---------------------------------------------------- |
|
670 // CMceSettingsMultipleServicesDialog::ShowListBoxSettingPageL |
|
671 // ---------------------------------------------------- |
|
672 void CMceSettingsMultipleServicesDialog::ShowListBoxSettingPageL() |
|
673 { |
|
674 TInt count = 0; |
|
675 TBool nbrOfMailboxesOk = ETrue; |
|
676 CUidNameArray* sel = NULL; // Used for iProductIncludesSelectableEmail |
|
677 |
|
678 //Produce radiobutton list of mailboxes for selecting the default mailbox |
|
679 if ( iProductIncludesSelectableEmail ) |
|
680 { |
|
681 sel = MtmEmailAccountsL(); |
|
682 CleanupStack::PushL( sel ); |
|
683 count = sel->Count(); |
|
684 } |
|
685 else |
|
686 { |
|
687 count = iMailboxArray.Count(); |
|
688 if ( iNumberOfMailboxes >= KMceMaxNumberOfMailboxes ) |
|
689 { |
|
690 nbrOfMailboxesOk = EFalse; |
|
691 } |
|
692 } |
|
693 if ( count == 0 && nbrOfMailboxesOk ) |
|
694 { |
|
695 if ( HandleNoMailboxesL() ) |
|
696 { |
|
697 if( iMceIntegration ) |
|
698 { |
|
699 if ( iS60WizLaunched ) |
|
700 { |
|
701 iS60WizLaunched = EFalse; |
|
702 EditServicesL(); |
|
703 } |
|
704 } |
|
705 else // iMceIntegration |
|
706 { |
|
707 EditServicesL(); |
|
708 } // iMceIntegration |
|
709 } |
|
710 if ( iProductIncludesSelectableEmail ) |
|
711 { |
|
712 CleanupStack::PopAndDestroy( sel ); |
|
713 } |
|
714 return; |
|
715 } |
|
716 UpdateMailboxDataL(); |
|
717 CDesCArrayFlat* items = new( ELeave )CDesCArrayFlat( |
|
718 KMceSettingsArrayGranularity ); |
|
719 CleanupStack::PushL( items ); |
|
720 |
|
721 TMsvId id = MsvUiServiceUtilitiesInternal::DefaultServiceForMTML( |
|
722 iManager.Session(), |
|
723 iMessageType, |
|
724 ETrue ); |
|
725 |
|
726 if ( iProductIncludesSelectableEmail && |
|
727 ( iMessageType != KSenduiMtmSyncMLEmailUid ) ) |
|
728 { |
|
729 CRepository* repository = NULL; |
|
730 TRAPD( ret, repository = CRepository::NewL( |
|
731 KCRUidSelectableDefaultEmailSettings ) ); |
|
732 CleanupStack::PushL( repository ); |
|
733 TInt val; |
|
734 |
|
735 if ( ret == KErrNone ) |
|
736 { |
|
737 if ( repository->Get( |
|
738 KSelectableDefaultMailAccount , val ) == KErrNone ) |
|
739 { |
|
740 id = val; |
|
741 } |
|
742 } |
|
743 CleanupStack::PopAndDestroy( repository ); |
|
744 } // iProductIncludesSelectableEmail |
|
745 TMsvEntry mailboxEntry; |
|
746 TMsvId serviceId; // not used but needed by GetEntry function |
|
747 TBool foundService = iManager.Session().GetEntry( id, serviceId, mailboxEntry ) == KErrNone; |
|
748 |
|
749 TInt currentItem = 0; |
|
750 for ( TInt loop = 0; loop < count; loop++ ) |
|
751 { |
|
752 TMsvId arrayItemId; |
|
753 if ( iProductIncludesSelectableEmail ) |
|
754 { |
|
755 items->AppendL( (*sel)[loop].iName ); |
|
756 arrayItemId = (*sel)[loop].iUid.iUid; |
|
757 } |
|
758 else |
|
759 { |
|
760 TMsvEntry tentry = |
|
761 iEmailApi->MailboxUtilitiesL().GetMailboxEntryL( |
|
762 iMailboxArray[loop], |
|
763 MImumInMailboxUtilities::ERequestSending ); |
|
764 items->AppendL( tentry.iDetails ); |
|
765 arrayItemId = iMailboxArray[loop]; |
|
766 } |
|
767 // iRelatedId is compared because array can include both smtp and |
|
768 // imap4/pop3 services |
|
769 if ( foundService && |
|
770 ( id == arrayItemId || mailboxEntry.iRelatedId == arrayItemId ) ) |
|
771 { |
|
772 currentItem = loop; |
|
773 } |
|
774 } // for |
|
775 |
|
776 CAknRadioButtonSettingPage* dlg = |
|
777 new ( ELeave )CAknRadioButtonSettingPage( |
|
778 R_MCE_GENERAL_SETTINGS_LISTBOX, |
|
779 currentItem, items); |
|
780 CleanupStack::PushL( dlg ); |
|
781 |
|
782 THumanReadableName mtmName = iManager.MtmName( iMessageType ); |
|
783 if ( iMessageType == KSenduiMtmSmtpUid ) |
|
784 { |
|
785 // email |
|
786 HBufC* titleText = StringLoader::LoadLC( |
|
787 R_MCE_SETTINGS_MAIL_TITLE_TITLEDEFAULT, |
|
788 iEikonEnv ); |
|
789 dlg->SetSettingTextL( *titleText ); |
|
790 CleanupStack::PopAndDestroy( titleText ); |
|
791 } |
|
792 else if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
793 { |
|
794 // syncML |
|
795 HBufC* titleText = StringLoader::LoadLC( |
|
796 R_MCE_SETTINGS_MAIL_TITLE_TITLEDEFAULT, |
|
797 iEikonEnv ); |
|
798 dlg->SetSettingTextL( *titleText ); |
|
799 CleanupStack::PopAndDestroy( titleText ); |
|
800 } |
|
801 else |
|
802 { |
|
803 // not email/syncML |
|
804 dlg->SetSettingTextL( mtmName ); |
|
805 } |
|
806 |
|
807 CleanupStack::Pop( dlg ); |
|
808 |
|
809 if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
810 { |
|
811 if ( iProductIncludesSelectableEmail ) |
|
812 { |
|
813 id = (*sel)[currentItem].iUid.iUid; |
|
814 } |
|
815 else |
|
816 { |
|
817 id = iMailboxArray[currentItem]; |
|
818 } |
|
819 CMsvSession& session = iManager.Session(); |
|
820 TMsvEntry entry; |
|
821 TMsvId serviceid; |
|
822 if ( session.GetEntry( id, serviceid, entry ) == KErrNone ) |
|
823 { |
|
824 // idTemp is used only if iProductIncludesSelectableEmail |
|
825 TInt idTemp = entry.Id(); |
|
826 MsvUiServiceUtilitiesInternal::SetDefaultServiceForMTML( |
|
827 session, entry.iMtm, id ); |
|
828 |
|
829 // set related service's default too... |
|
830 if ( session.GetEntry( |
|
831 entry.iRelatedId, serviceid, entry ) == KErrNone ) |
|
832 { |
|
833 MsvUiServiceUtilitiesInternal::SetDefaultServiceForMTML( |
|
834 session, entry.iMtm, entry.Id() ); |
|
835 } |
|
836 |
|
837 if( iProductIncludesSelectableEmail && |
|
838 ( ( entry.iMtm == KSenduiMtmImap4Uid ) || |
|
839 ( entry.iMtm == KSenduiMtmPop3Uid ) || |
|
840 ( entry.iMtm == KSenduiMtmSmtpUid ) ) ) |
|
841 { |
|
842 CRepository* repository = NULL; |
|
843 TRAPD( ret, repository = |
|
844 CRepository::NewL( KCRUidSelectableDefaultEmailSettings ) ); |
|
845 CleanupStack::PushL( repository ); |
|
846 |
|
847 if ( ret == KErrNone ) |
|
848 { |
|
849 TInt value = entry.Id(); |
|
850 repository->Set( KSelectableDefaultMailAccount , idTemp ); |
|
851 } |
|
852 CleanupStack::PopAndDestroy( repository ); |
|
853 } // iProductIncludesSelectableEmail |
|
854 } |
|
855 SetAccountInUseL(); |
|
856 |
|
857 CEikTextListBox* list = STATIC_CAST( CEikTextListBox*, |
|
858 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
859 list->DrawDeferred(); |
|
860 } |
|
861 |
|
862 CleanupStack::PopAndDestroy( items ); |
|
863 |
|
864 if ( iProductIncludesSelectableEmail ) |
|
865 { |
|
866 CleanupStack::PopAndDestroy( sel ); |
|
867 } |
|
868 } |
|
869 |
|
870 // --------------------------------------------------------------------------- |
|
871 // CMceSettingsMultipleServicesDialog::LaunchDialogL() |
|
872 // --------------------------------------------------------------------------- |
|
873 // |
|
874 void CMceSettingsMultipleServicesDialog::LaunchDialogL( |
|
875 MMceSettingsAccountManager& aManager, |
|
876 const TUid& aMessageType, |
|
877 CMsvSession& aSession, |
|
878 const TInt& aMenuResource, |
|
879 const TInt& aDialogResource ) |
|
880 { |
|
881 // if mtm supports account creation then open new dialog to |
|
882 // handle many accounts |
|
883 CMceSettingsMultipleServicesDialog* mailDlg = |
|
884 new( ELeave ) CMceSettingsMultipleServicesDialog( |
|
885 aManager, aMessageType, &aSession ); |
|
886 CleanupStack::PushL( mailDlg ); |
|
887 mailDlg->ConstructL(); |
|
888 static_cast<CAknDialog*>( mailDlg )->ConstructL( aMenuResource ); |
|
889 CleanupStack::Pop( mailDlg ); |
|
890 mailDlg->ExecuteLD( aDialogResource ); |
|
891 } |
|
892 |
|
893 // ---------------------------------------------------- |
|
894 // CMceSettingsMultipleServicesDialog::EditServicesL |
|
895 // ---------------------------------------------------- |
|
896 void CMceSettingsMultipleServicesDialog::EditServicesL() |
|
897 { |
|
898 CUidNameArray* sel = iManager.MtmAccountsL( iMessageType ); |
|
899 UpdateMailboxDataL(); |
|
900 iSubDialogForceClosed = ETrue; |
|
901 |
|
902 if ( ( iNumberOfMailboxes < KMceMaxNumberOfMailboxes ) && |
|
903 ( iMailboxArray.Count() == 0 ) ) |
|
904 { |
|
905 delete sel; |
|
906 if ( HandleNoMailboxesL() && ( iSubDialogForceClosed == TRUE ) ) |
|
907 { |
|
908 if( iMceIntegration ) |
|
909 { |
|
910 if ( iS60WizLaunched ) |
|
911 { |
|
912 iS60WizLaunched = EFalse; |
|
913 EditServicesL(); |
|
914 } |
|
915 } // iMceIntegration |
|
916 else |
|
917 { |
|
918 EditServicesL(); |
|
919 } |
|
920 } |
|
921 return; |
|
922 } |
|
923 delete sel; |
|
924 if ( iProductIncludesSelectableEmail ) |
|
925 { |
|
926 CEikTextListBox* list = STATIC_CAST( CEikTextListBox*, |
|
927 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
928 list->DrawDeferred(); |
|
929 |
|
930 SetAccountInUseL(); |
|
931 SetMSKButtonL(); |
|
932 } |
|
933 else // iProductIncludesSelectableEmail |
|
934 { |
|
935 CMceSettingsMtmServicesDialog* dlg = |
|
936 new( ELeave ) CMceSettingsMtmServicesDialog( iMessageType, |
|
937 iManager, |
|
938 iSession, |
|
939 *this ); |
|
940 CleanupStack::PushL( dlg ); |
|
941 dlg->ConstructL( R_MCE_SETTINGS_MTM_SERVICES_DIALOG_MENUBAR ); |
|
942 CleanupStack::Pop( dlg ); |
|
943 |
|
944 CleanupStack::PushL( TCleanupItem( ResetMtmServicesDialog, this ) ); |
|
945 iSubDialogOpen = ETrue; |
|
946 dlg->ExecuteLD( R_MCE_SETTINGS_MTM_SERVICES_DIALOG ); |
|
947 CleanupStack::Pop(); //ResetMtmServicesDialog |
|
948 iSubDialogOpen = EFalse; |
|
949 |
|
950 if ( iSubDialogForceClosed == TRUE ) |
|
951 { |
|
952 SetAccountInUseL(); |
|
953 |
|
954 CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, |
|
955 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
956 list->SetCurrentItemIndex( 0 ); |
|
957 list->DrawDeferred(); |
|
958 SetMSKButtonL(); |
|
959 } |
|
960 } |
|
961 } |
|
962 |
|
963 // ---------------------------------------------------- |
|
964 // CMceSettingsMultipleServicesDialog::HandleNoMailboxesL |
|
965 // ---------------------------------------------------- |
|
966 TBool CMceSettingsMultipleServicesDialog::HandleNoMailboxesL() |
|
967 { |
|
968 //Deny creating new mail account if TARM is active. |
|
969 if( !iEmailApi->IsEmailFeatureSupportedL( |
|
970 CImumInternalApi::EMailLockedSettings, R_QTN_SELEC_PROTECTED_SETTING ) ) |
|
971 { |
|
972 CAknQueryDialog* confDialog = CAknQueryDialog::NewL(); |
|
973 |
|
974 THumanReadableName mtmName = iManager.MtmName( iMessageType ); |
|
975 |
|
976 if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
977 { |
|
978 // syncML |
|
979 HBufC* text = StringLoader::LoadLC( |
|
980 R_MCE_SETTINGS_SMAIL_NEW, iEikonEnv ); |
|
981 confDialog->SetPromptL( *text ); |
|
982 CleanupStack::PopAndDestroy( text ); // text |
|
983 } |
|
984 else if ( iMessageType != KSenduiMtmSmtpUid ) |
|
985 { |
|
986 // not email/SyncML |
|
987 HBufC* text = StringLoader::LoadLC( |
|
988 R_MCE_MTM_CREATE_NEW, mtmName, iEikonEnv ); |
|
989 confDialog->SetPromptL( *text ); |
|
990 CleanupStack::PopAndDestroy( text ); // text |
|
991 } |
|
992 else |
|
993 { |
|
994 // if KSenduiMtmSmtpUid, the confDialog text has been set in |
|
995 // R_MCE_SETTINGS_CREATE_NEW_MBOX_CONFIRMATION |
|
996 } |
|
997 |
|
998 if ( confDialog->ExecuteLD( |
|
999 R_MCE_SETTINGS_CREATE_NEW_MBOX_CONFIRMATION ) ) |
|
1000 { |
|
1001 if( iMceIntegration ) |
|
1002 { |
|
1003 // In MCE wizard integration's case this return value |
|
1004 // is not used |
|
1005 return LaunchWizardL(); |
|
1006 } |
|
1007 else // iMceIntegration |
|
1008 { |
|
1009 return iManager.CreateNewAccountL( |
|
1010 iMessageType, KMsvNullIndexEntryId ); |
|
1011 } // iMceIntegration |
|
1012 } |
|
1013 } |
|
1014 return EFalse; |
|
1015 } |
|
1016 // ---------------------------------------------------- |
|
1017 // CMceSettingsMultipleServicesDialog::CreateNewImapPopL |
|
1018 // ---------------------------------------------------- |
|
1019 TBool CMceSettingsMultipleServicesDialog::CreateNewImapPopL() |
|
1020 { |
|
1021 TBool ret; |
|
1022 if( iMceIntegration ) |
|
1023 { |
|
1024 // In MCE wizard integration's case this return value is not used |
|
1025 // just resetting this boolean to its original value |
|
1026 ret = LaunchWizardL(); |
|
1027 iS60WizLaunched = EFalse; |
|
1028 } |
|
1029 else |
|
1030 { |
|
1031 ret = iManager.CreateNewAccountL( |
|
1032 iMessageType, KMsvNullIndexEntryId ); |
|
1033 } |
|
1034 return ret; |
|
1035 } |
|
1036 |
|
1037 |
|
1038 // ---------------------------------------------------- |
|
1039 // CMceSettingsMultipleServicesDialog::LaunchWizardL |
|
1040 // ---------------------------------------------------- |
|
1041 TBool CMceSettingsMultipleServicesDialog::LaunchWizardL() |
|
1042 { |
|
1043 TBool ret; |
|
1044 // launch S60 wizard |
|
1045 iS60WizLaunched = ETrue; |
|
1046 ret = iManager.CreateNewAccountL( |
|
1047 iMessageType, KMsvNullIndexEntryId ); |
|
1048 return ret; |
|
1049 } |
|
1050 |
|
1051 // ---------------------------------------------------- |
|
1052 // CMceSettingsMultipleServicesDialog::SetAccountInUseL |
|
1053 // ---------------------------------------------------- |
|
1054 void CMceSettingsMultipleServicesDialog::SetAccountInUseL() |
|
1055 { |
|
1056 TMsvId id = MsvUiServiceUtilitiesInternal::DefaultServiceForMTML( |
|
1057 iManager.Session(), |
|
1058 iMessageType, |
|
1059 ETrue ); |
|
1060 |
|
1061 if( iProductIncludesSelectableEmail ) |
|
1062 { |
|
1063 // Get all healthy mailbox array, especially necessary after a new |
|
1064 // account is created while there are invalid email accounts. |
|
1065 if ( !iEmailApi ) |
|
1066 { |
|
1067 iEmailApi = CreateEmailApiL( iSession ); |
|
1068 } |
|
1069 |
|
1070 const MImumInHealthServices* healthApi = |
|
1071 &iEmailApi->HealthServicesL(); |
|
1072 |
|
1073 iMailboxArray.Reset(); |
|
1074 if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
1075 { |
|
1076 MceSettingsUtils::GetHealthyMailboxListL( *healthApi, |
|
1077 iMailboxArray, |
|
1078 EFalse, |
|
1079 EFalse, |
|
1080 ETrue,EFalse ); |
|
1081 } |
|
1082 else |
|
1083 { |
|
1084 MceSettingsUtils::GetHealthyMailboxListL( *healthApi, |
|
1085 iMailboxArray, |
|
1086 ETrue, |
|
1087 ETrue, |
|
1088 EFalse,ETrue ); |
|
1089 } |
|
1090 |
|
1091 CRepository* repository = NULL; |
|
1092 TRAPD( ret, repository = CRepository::NewL( |
|
1093 KCRUidSelectableDefaultEmailSettings ) ); |
|
1094 CleanupStack::PushL( repository ); |
|
1095 TInt val; |
|
1096 THumanReadableName mtmName; |
|
1097 TMsvEntry entryMail; |
|
1098 TBool nameGet = EFalse; |
|
1099 TBool setDefault( EFalse ); |
|
1100 if ( ret == KErrNone && iMessageType != KSenduiMtmSyncMLEmailUid ) |
|
1101 { |
|
1102 if ( repository->Get( |
|
1103 KSelectableDefaultMailAccount , val ) == KErrNone ) |
|
1104 { |
|
1105 id = val; |
|
1106 TMsvId serviceId; |
|
1107 TInt err = iSession->GetEntry( id, serviceId, entryMail ); |
|
1108 CMtmUiDataRegistry* uiRegistry = |
|
1109 CMtmUiDataRegistry::NewL( *iSession ); |
|
1110 CleanupStack::PushL( uiRegistry ); |
|
1111 TUid mailMTMTechType = |
|
1112 uiRegistry->TechnologyTypeUid( KUidMsgTypePOP3 ); |
|
1113 |
|
1114 // Need check if the mailbox is healthy. |
|
1115 if ( ( healthApi->IsMailboxHealthy( entryMail.Id() ) || |
|
1116 ( ( entryMail.iType == KUidMsvServiceEntry) && |
|
1117 ( entryMail.Id() != KMsvLocalServiceIndexEntryId ) && |
|
1118 ( !MuiuEmailTools::IsMailMtm( |
|
1119 entryMail.iMtm, ETrue ) ) ) ) |
|
1120 && err == KErrNone |
|
1121 && ( entryMail.Visible() || |
|
1122 uiRegistry->TechnologyTypeUid( entryMail.iMtm ) |
|
1123 == mailMTMTechType ) ) |
|
1124 { |
|
1125 mtmName.Append( entryMail.iDetails ); |
|
1126 nameGet = ETrue; |
|
1127 } |
|
1128 else |
|
1129 { |
|
1130 err = iSession->GetEntry( |
|
1131 entryMail.iRelatedId, serviceId, entryMail ); |
|
1132 if ( ( healthApi->IsMailboxHealthy( entryMail.Id() ) || |
|
1133 ( ( entryMail.iType == KUidMsvServiceEntry) && |
|
1134 ( entryMail.Id() != KMsvLocalServiceIndexEntryId ) |
|
1135 && ( !MuiuEmailTools::IsMailMtm( |
|
1136 entryMail.iMtm, ETrue ) ) ) ) |
|
1137 && err == KErrNone |
|
1138 && ( entryMail.Visible() || |
|
1139 uiRegistry->TechnologyTypeUid( entryMail.iMtm ) |
|
1140 == mailMTMTechType ) ) |
|
1141 { |
|
1142 mtmName.Append( entryMail.iDetails ); |
|
1143 nameGet = ETrue; |
|
1144 } |
|
1145 } |
|
1146 CleanupStack::PopAndDestroy( uiRegistry ); |
|
1147 |
|
1148 // If it cannot get the default account and there is a |
|
1149 // healthy mailbox created by user, then the mailbox should |
|
1150 // be set as default. |
|
1151 if ( !nameGet && iMailboxArray.Count() != 0 ) |
|
1152 { |
|
1153 id = iMailboxArray[0]; |
|
1154 CMsvSession& session = iManager.Session(); |
|
1155 TMsvEntry entry; |
|
1156 TMsvId serviceid; |
|
1157 if ( session.GetEntry( id, serviceid, entry ) == KErrNone |
|
1158 && ( entry.iMtm == KSenduiMtmImap4Uid |
|
1159 || entry.iMtm == KSenduiMtmPop3Uid |
|
1160 || entry.iMtm == KSenduiMtmSmtpUid ) ) |
|
1161 { |
|
1162 setDefault = ETrue; |
|
1163 mtmName.Append( entry.iDetails ); |
|
1164 nameGet = ETrue; |
|
1165 |
|
1166 TInt idTemp = entry.Id(); |
|
1167 MsvUiServiceUtilitiesInternal:: |
|
1168 SetDefaultServiceForMTML( session, entry.iMtm, id ); |
|
1169 |
|
1170 // set related service's default too... |
|
1171 if ( session.GetEntry( |
|
1172 entry.iRelatedId, serviceid, entry ) == KErrNone ) |
|
1173 { |
|
1174 MsvUiServiceUtilitiesInternal:: |
|
1175 SetDefaultServiceForMTML( session, entry.iMtm, entry.Id() ); |
|
1176 } |
|
1177 |
|
1178 // Set default mailbox. |
|
1179 repository->Set( KSelectableDefaultMailAccount ,idTemp ); |
|
1180 } |
|
1181 } |
|
1182 } |
|
1183 } |
|
1184 CleanupStack::PopAndDestroy( repository ); |
|
1185 iMailboxArray.Reset(); |
|
1186 |
|
1187 HBufC* mailboxInUseListBoxText = NULL; |
|
1188 TMsvEntry mailboxEntry; |
|
1189 TMsvId serviceId; // not used but needed by GetEntry function |
|
1190 |
|
1191 if(!nameGet) |
|
1192 { |
|
1193 THumanReadableName mtmName = iManager.MtmName( iMessageType ); |
|
1194 } |
|
1195 |
|
1196 if ( id != KMsvUnknownServiceIndexEntryId |
|
1197 && iManager.Session().GetEntry( id, serviceId, mailboxEntry ) |
|
1198 == KErrNone |
|
1199 && ( healthApi->IsMailboxHealthy( mailboxEntry.Id() ) || |
|
1200 ( ( mailboxEntry.iType == KUidMsvServiceEntry ) && |
|
1201 ( mailboxEntry.Id() != KMsvLocalServiceIndexEntryId ) && |
|
1202 ( !MuiuEmailTools::IsMailMtm( mailboxEntry.iMtm, ETrue ) ) ) ) ) |
|
1203 { |
|
1204 TInt mailboxNameLength; |
|
1205 if(!nameGet) |
|
1206 { |
|
1207 mailboxNameLength = mailboxEntry.iDetails.Left( |
|
1208 KMceSettingsMailboxTextLength ).Length(); |
|
1209 } |
|
1210 else |
|
1211 { |
|
1212 mailboxNameLength = entryMail.iDetails.Left( |
|
1213 KMceSettingsMailboxTextLength ).Length(); |
|
1214 } |
|
1215 |
|
1216 HBufC* mailboxInUseDefaultText = NULL; |
|
1217 |
|
1218 if ( iMessageType == KSenduiMtmSmtpUid ) |
|
1219 { |
|
1220 //remote mailboxes |
|
1221 mailboxInUseDefaultText = StringLoader::LoadLC( |
|
1222 R_MCE_SETTINGS_MAIL_DEFAULT, iEikonEnv ); |
|
1223 } |
|
1224 else if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
1225 { |
|
1226 //syncML remote mailboxes |
|
1227 mailboxInUseDefaultText = StringLoader::LoadLC( |
|
1228 R_MCE_SETTINGS_SYNCMAIL_INUSE, iEikonEnv ); |
|
1229 } |
|
1230 else |
|
1231 { |
|
1232 mailboxInUseDefaultText = StringLoader::LoadLC( |
|
1233 R_MCE_MTM_IN_USE, mtmName, iEikonEnv ); |
|
1234 } |
|
1235 |
|
1236 mailboxInUseListBoxText = HBufC::NewLC( |
|
1237 mailboxInUseDefaultText->Length() + mailboxNameLength ); |
|
1238 |
|
1239 mailboxInUseListBoxText->Des().Copy( *mailboxInUseDefaultText ); |
|
1240 if ( !nameGet ) |
|
1241 { |
|
1242 mailboxInUseListBoxText->Des().Append( |
|
1243 mailboxEntry.iDetails.Left( mailboxNameLength ) ); |
|
1244 } |
|
1245 else |
|
1246 { |
|
1247 if ( setDefault ) |
|
1248 { |
|
1249 mailboxInUseListBoxText->Des().Append( |
|
1250 mtmName.Left( mailboxNameLength ) ); |
|
1251 } |
|
1252 else |
|
1253 { |
|
1254 mailboxInUseListBoxText->Des().Append( |
|
1255 entryMail.iDetails.Left( mailboxNameLength ) ); |
|
1256 } |
|
1257 } |
|
1258 |
|
1259 CleanupStack::Pop( mailboxInUseListBoxText ); |
|
1260 CleanupStack::PopAndDestroy( mailboxInUseDefaultText ); |
|
1261 } |
|
1262 else |
|
1263 { |
|
1264 if ( iMessageType == KSenduiMtmSmtpUid ) |
|
1265 { |
|
1266 //remote mailboxes |
|
1267 mailboxInUseListBoxText = StringLoader::LoadL( |
|
1268 R_MCE_SETTINGS_MAIL_DEFAULT_IN_USE_NONE, iEikonEnv ); |
|
1269 } |
|
1270 else if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
1271 { |
|
1272 //syncML remote mailboxes |
|
1273 mailboxInUseListBoxText = StringLoader::LoadL( |
|
1274 R_MCE_SETTINGS_SYNCMAIL_INUSE_NONE, iEikonEnv ); |
|
1275 } |
|
1276 else |
|
1277 { |
|
1278 mailboxInUseListBoxText = StringLoader::LoadL( |
|
1279 R_MCE_MTM_IN_USE_NONE, mtmName, iEikonEnv ); |
|
1280 } |
|
1281 } |
|
1282 |
|
1283 if ( iSettingsItemArray->Count() > 1 ) |
|
1284 { |
|
1285 // delete dummy item because we are adding 'real' item below |
|
1286 iSettingsItemArray->Delete( |
|
1287 KMceSettingsRemoteMailboxInUseSelectableEmailInUse ); |
|
1288 } |
|
1289 |
|
1290 CleanupStack::PushL( mailboxInUseListBoxText ); |
|
1291 iSettingsItemArray->InsertL( 0, *mailboxInUseListBoxText ); |
|
1292 CleanupStack::PopAndDestroy( mailboxInUseListBoxText ); |
|
1293 |
|
1294 } |
|
1295 else // iProductIncludesSelectableEmail |
|
1296 { |
|
1297 HBufC* mailboxInUseListBoxText = NULL; |
|
1298 TMsvEntry mailboxEntry; |
|
1299 TMsvId serviceId; // not used but needed by GetEntry function |
|
1300 |
|
1301 THumanReadableName mtmName = iManager.MtmName( iMessageType ); |
|
1302 |
|
1303 if ( id != KMsvUnknownServiceIndexEntryId && |
|
1304 iManager.Session().GetEntry( id, serviceId, mailboxEntry ) == KErrNone ) |
|
1305 { |
|
1306 const TInt mailboxNameLength = |
|
1307 mailboxEntry.iDetails.Left( KMceSettingsMailboxTextLength ).Length(); |
|
1308 |
|
1309 HBufC* mailboxInUseDefaultText = NULL; |
|
1310 |
|
1311 if ( iMessageType == KSenduiMtmSmtpUid ) |
|
1312 { |
|
1313 //remote mailboxes |
|
1314 mailboxInUseDefaultText = StringLoader::LoadLC( |
|
1315 R_MCE_SETTINGS_MAIL_RM_IN_USE, iEikonEnv ); |
|
1316 } |
|
1317 else if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
1318 { |
|
1319 //syncML remote mailboxes |
|
1320 mailboxInUseDefaultText = StringLoader::LoadLC( |
|
1321 R_MCE_SETTINGS_SYNCMAIL_INUSE, iEikonEnv ); |
|
1322 } |
|
1323 else |
|
1324 { |
|
1325 mailboxInUseDefaultText = StringLoader::LoadLC( |
|
1326 R_MCE_MTM_IN_USE, mtmName, iEikonEnv ); |
|
1327 } |
|
1328 |
|
1329 mailboxInUseListBoxText = HBufC::NewLC( |
|
1330 mailboxInUseDefaultText->Length() + mailboxNameLength ); |
|
1331 |
|
1332 mailboxInUseListBoxText->Des().Copy( *mailboxInUseDefaultText ); |
|
1333 mailboxInUseListBoxText->Des().Append( |
|
1334 mailboxEntry.iDetails.Left( mailboxNameLength ) ); |
|
1335 |
|
1336 CleanupStack::Pop( mailboxInUseListBoxText ); |
|
1337 CleanupStack::PopAndDestroy( mailboxInUseDefaultText ); |
|
1338 } |
|
1339 else |
|
1340 { |
|
1341 if ( iMessageType == KSenduiMtmSmtpUid ) |
|
1342 { |
|
1343 //remote mailboxes |
|
1344 mailboxInUseListBoxText = StringLoader::LoadL( |
|
1345 R_MCE_SETTINGS_MAIL_RM_IN_USE_NONE, |
|
1346 iEikonEnv ); |
|
1347 } |
|
1348 else if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
1349 { |
|
1350 //syncML remote mailboxes |
|
1351 mailboxInUseListBoxText = StringLoader::LoadL( |
|
1352 R_MCE_SETTINGS_SYNCMAIL_INUSE_NONE, |
|
1353 iEikonEnv ); |
|
1354 } |
|
1355 else |
|
1356 { |
|
1357 mailboxInUseListBoxText = StringLoader::LoadL( |
|
1358 R_MCE_MTM_IN_USE_NONE, mtmName, iEikonEnv ); |
|
1359 } |
|
1360 } |
|
1361 |
|
1362 if ( iSettingsItemArray->Count() > 1 ) |
|
1363 { |
|
1364 // delete dummy item because we are adding 'real' item below |
|
1365 iSettingsItemArray->Delete( KMceSettingsRemoteMailboxInUse ); |
|
1366 } |
|
1367 |
|
1368 CleanupStack::PushL( mailboxInUseListBoxText ); |
|
1369 iSettingsItemArray->AppendL( *mailboxInUseListBoxText ); |
|
1370 CleanupStack::PopAndDestroy( mailboxInUseListBoxText ); |
|
1371 } |
|
1372 } |
|
1373 |
|
1374 // ---------------------------------------------------- |
|
1375 // CMceSettingsMultipleServicesDialog::HandleSessionEventL |
|
1376 // ---------------------------------------------------- |
|
1377 void CMceSettingsMultipleServicesDialog::HandleSessionEventL( |
|
1378 TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/) |
|
1379 { |
|
1380 switch ( aEvent ) |
|
1381 { |
|
1382 case EMsvEntriesCreated: |
|
1383 if ( KMsvRootIndexEntryId == (*(TMsvId*) (aArg2)) ) |
|
1384 { |
|
1385 HandleEntriesCreatedL( (CMsvEntrySelection*) aArg1 ); |
|
1386 if( iProductIncludesSelectableEmail ) |
|
1387 { |
|
1388 UpdateServicesArrayL(); |
|
1389 } |
|
1390 } |
|
1391 break; |
|
1392 case EMsvEntriesChanged: |
|
1393 case EMsvEntriesDeleted: |
|
1394 case EMsvMediaAvailable: |
|
1395 UpdateMailboxDataL(); |
|
1396 default: |
|
1397 // just ignore |
|
1398 break; |
|
1399 } |
|
1400 } |
|
1401 |
|
1402 // ---------------------------------------------------- |
|
1403 // CMceSettingsMultipleServicesDialog::HandleEntriesCreatedL |
|
1404 // ---------------------------------------------------- |
|
1405 void CMceSettingsMultipleServicesDialog::HandleEntriesCreatedL( CMsvEntrySelection* aSelection ) |
|
1406 { |
|
1407 UpdateMailboxDataL(); |
|
1408 if ( aSelection->Count() ) |
|
1409 { |
|
1410 TMsvEntry currentEntry; |
|
1411 TMsvId serviceId; // not used here but needed by GetEntry function |
|
1412 if ( iManager.Session().GetEntry( aSelection->At( 0 ), serviceId, currentEntry ) == KErrNone |
|
1413 && currentEntry.iType == KUidMsvServiceEntry |
|
1414 && currentEntry.iMtm == iMessageType ) |
|
1415 { |
|
1416 SetAccountInUseL(); |
|
1417 } |
|
1418 CEikTextListBox* list = STATIC_CAST( CEikTextListBox*, |
|
1419 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
1420 list->DrawDeferred(); |
|
1421 } |
|
1422 } |
|
1423 |
|
1424 // ---------------------------------------------------- |
|
1425 // CMceSettingsMultipleServicesDialog::HandleListBoxEventL |
|
1426 // ---------------------------------------------------- |
|
1427 void CMceSettingsMultipleServicesDialog::HandleListBoxEventL( |
|
1428 CEikListBox* /*aListBox*/, |
|
1429 TListBoxEvent aEventType ) |
|
1430 { |
|
1431 CEikTextListBox* list = STATIC_CAST( CEikTextListBox*, |
|
1432 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
1433 switch( aEventType ) |
|
1434 { |
|
1435 case EEventEnterKeyPressed: |
|
1436 case EEventItemSingleClicked: |
|
1437 if ( iProductIncludesSelectableEmail ) |
|
1438 { |
|
1439 if ( list->CurrentItemIndex() == 0 ) |
|
1440 { |
|
1441 ProcessCommandL( EMceSettingsCmdSettingsDialogChange ); |
|
1442 } |
|
1443 else |
|
1444 { |
|
1445 ProcessCommandL( EMceSettingsCmdSettingsDialogOpen ); |
|
1446 } |
|
1447 } |
|
1448 else // iProductIncludesSelectableEmail |
|
1449 { |
|
1450 if ( list->CurrentItemIndex() == 0 ) |
|
1451 { |
|
1452 ProcessCommandL( EMceSettingsCmdSettingsDialogOpen ); |
|
1453 } |
|
1454 else |
|
1455 { |
|
1456 ProcessCommandL( EMceSettingsCmdSettingsDialogChange ); |
|
1457 } |
|
1458 } |
|
1459 break; |
|
1460 case EEventItemDraggingActioned: |
|
1461 SetMSKButtonL(); |
|
1462 break; |
|
1463 default: |
|
1464 break; |
|
1465 } |
|
1466 } |
|
1467 |
|
1468 // ---------------------------------------------------- |
|
1469 // CMceSettingsMultipleServicesDialog::GetHelpContext |
|
1470 // returns helpcontext as aContext |
|
1471 // |
|
1472 // ---------------------------------------------------- |
|
1473 void CMceSettingsMultipleServicesDialog::GetHelpContext |
|
1474 ( TCoeHelpContext& aContext ) const |
|
1475 { |
|
1476 aContext.iMajor = KMceApplicationUid; |
|
1477 if ( iProductIncludesSelectableEmail ) |
|
1478 { |
|
1479 CEikTextListBox* list = STATIC_CAST( |
|
1480 CEikTextListBox*, |
|
1481 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
1482 |
|
1483 if ( list->CurrentItemIndex() == |
|
1484 KMceSettingsRemoteMailboxInUseSelectableEmailInUse ) |
|
1485 { |
|
1486 aContext.iContext = KES_HLP_EMAIL_SETTING; |
|
1487 } |
|
1488 else |
|
1489 { |
|
1490 // start |
|
1491 TUid mtmType; |
|
1492 TInt item = list->CurrentItemIndex(); |
|
1493 CMsvEntry* entry = NULL; |
|
1494 |
|
1495 TRAP_IGNORE( entry = iSession->GetEntryL( |
|
1496 (*iAccountArray)[item-1].iUid.iUid )); |
|
1497 |
|
1498 if ( entry ) |
|
1499 { |
|
1500 TMsvEntry tentry = entry->Entry(); |
|
1501 mtmType = tentry.iMtm; |
|
1502 delete entry; |
|
1503 |
|
1504 if ( ( mtmType != KSenduiMtmImap4Uid ) && |
|
1505 ( mtmType != KSenduiMtmPop3Uid ) ) |
|
1506 { |
|
1507 aContext.iContext = KES_HLP_THIRDPARTY_MAILBOX; |
|
1508 } |
|
1509 else |
|
1510 { |
|
1511 aContext.iContext = KES_HLP_SMTP_MAILBOX; |
|
1512 } |
|
1513 } |
|
1514 } |
|
1515 } |
|
1516 else // iProductIncludesSelectableEmail |
|
1517 { |
|
1518 if ( iMessageType == KSenduiMtmSyncMLEmailUid ) |
|
1519 { |
|
1520 aContext.iContext = KMCE_HLP_SETT_SMAILBOX/*KMCE_HLP_SETTINGS_SMAIL*/; |
|
1521 } |
|
1522 else |
|
1523 { |
|
1524 aContext.iContext = KMCE_HLP_SETTINGS_EMAIL; |
|
1525 } |
|
1526 } |
|
1527 } |
|
1528 |
|
1529 // ---------------------------------------------------- |
|
1530 // CMceSettingsMultipleServicesDialog::LaunchHelpL |
|
1531 // Launch help using context |
|
1532 // |
|
1533 // ---------------------------------------------------- |
|
1534 void CMceSettingsMultipleServicesDialog::LaunchHelpL() const |
|
1535 { |
|
1536 CCoeAppUi* appUi = STATIC_CAST( CCoeAppUi*, ControlEnv()->AppUi() ); |
|
1537 CArrayFix<TCoeHelpContext>* helpContext = appUi->AppHelpContextL(); |
|
1538 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext ); |
|
1539 } |
|
1540 |
|
1541 |
|
1542 // ---------------------------------------------------- |
|
1543 // CMceSettingsMultipleServicesDialog::ResetMtmServicesDialog |
|
1544 // Sets the flag to indicate that the MTM services subdialog |
|
1545 // is not open |
|
1546 // ---------------------------------------------------- |
|
1547 void CMceSettingsMultipleServicesDialog::ResetMtmServicesDialog( TAny* aAny ) |
|
1548 { |
|
1549 CMceSettingsMultipleServicesDialog* serviceDialog = ( CMceSettingsMultipleServicesDialog*)aAny; |
|
1550 serviceDialog->iSubDialogOpen = EFalse; |
|
1551 } |
|
1552 |
|
1553 // ---------------------------------------------------- |
|
1554 // CMceSettingsMultipleServicesDialog::OfferKeyEventL |
|
1555 // Handles this setting dialog view's arrow keys. |
|
1556 // Forwards other keys. |
|
1557 // |
|
1558 // ---------------------------------------------------- |
|
1559 TKeyResponse CMceSettingsMultipleServicesDialog::OfferKeyEventL( |
|
1560 const TKeyEvent& aKeyEvent, |
|
1561 TEventCode aType ) |
|
1562 { |
|
1563 if ( aType == EEventKey && |
|
1564 ( aKeyEvent.iCode==EKeyUpArrow || aKeyEvent.iCode==EKeyDownArrow ) ) |
|
1565 { |
|
1566 CEikTextListBox* list=STATIC_CAST( |
|
1567 CEikTextListBox*, |
|
1568 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
1569 list->OfferKeyEventL( aKeyEvent, aType ); |
|
1570 SetMSKButtonL(); |
|
1571 return EKeyWasConsumed; |
|
1572 } |
|
1573 return CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
1574 } |
|
1575 |
|
1576 // ---------------------------------------------------- |
|
1577 // CMceSettingsMultipleServicesDialog::SetMSKButtonL |
|
1578 // Sets the MSK for the view |
|
1579 // |
|
1580 // ---------------------------------------------------- |
|
1581 void CMceSettingsMultipleServicesDialog::SetMSKButtonL() |
|
1582 { |
|
1583 CEikTextListBox* list=STATIC_CAST( |
|
1584 CEikTextListBox*, |
|
1585 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
1586 const TInt index = list->CurrentItemIndex(); |
|
1587 const TInt numberOfItem = list->Model()->NumberOfItems(); |
|
1588 TInt resourceId; |
|
1589 if ( iProductIncludesSelectableEmail ) |
|
1590 { |
|
1591 resourceId = |
|
1592 index==0 ? R_MCE_MSK_BUTTON_CHANGE : R_MCE_MSK_BUTTON_OPEN; |
|
1593 } |
|
1594 else |
|
1595 { |
|
1596 resourceId = |
|
1597 index==0 ? R_MCE_MSK_BUTTON_OPEN : R_MCE_MSK_BUTTON_CHANGE; |
|
1598 } |
|
1599 CEikButtonGroupContainer& cba = ButtonGroupContainer(); |
|
1600 cba.SetCommandL( KMSKPosition, resourceId ); |
|
1601 cba.DrawNow(); |
|
1602 } |
|
1603 |
|
1604 // ---------------------------------------------------- |
|
1605 // CMceSettingsMultipleServicesDialog::SubdialogClosed |
|
1606 // Informs that subdialog has been closed |
|
1607 // |
|
1608 // ---------------------------------------------------- |
|
1609 void CMceSettingsMultipleServicesDialog::SubdialogClosed() |
|
1610 { |
|
1611 iSubDialogOpen = EFalse; |
|
1612 iSubDialogForceClosed = EFalse; |
|
1613 } |
|
1614 |
|
1615 // ---------------------------------------------------- |
|
1616 CMsvEntrySelection* CMceSettingsMultipleServicesDialog::GetEmailAccountsL( |
|
1617 CMsvSession& aSession ) |
|
1618 { |
|
1619 CMsvEntrySelection* sel = new( ELeave ) CMsvEntrySelection(); |
|
1620 CleanupStack::PushL( sel ); |
|
1621 CMsvEntry* entry = aSession.GetEntryL( KMsvRootIndexEntryIdValue ); |
|
1622 CleanupStack::PushL( entry ); |
|
1623 if ( iMceIntegration ) |
|
1624 { |
|
1625 TInt cnt = entry->Count(); |
|
1626 if ( cnt != 0 ) |
|
1627 { |
|
1628 entry->SetSortTypeL( TMsvSelectionOrdering( |
|
1629 KMsvGroupByType | KMsvGroupByStandardFolders, |
|
1630 EMsvSortByDetailsReverse, ETrue ) ); |
|
1631 const TMsvEntry* tentry; |
|
1632 for ( TInt cc = entry->Count(); --cc >= 0; ) |
|
1633 { |
|
1634 tentry = &(*entry)[cc]; |
|
1635 |
|
1636 if ( tentry->iType.iUid == KUidMsvServiceEntryValue && |
|
1637 tentry->Id() != KMsvLocalServiceIndexEntryIdValue ) |
|
1638 { |
|
1639 const TBool noRelatedId = |
|
1640 tentry->iRelatedId == KMsvNullIndexEntryId || |
|
1641 tentry->iRelatedId == tentry->Id(); |
|
1642 |
|
1643 TBool appendEmail = EFalse; |
|
1644 |
|
1645 if ( tentry->Visible() ) |
|
1646 { |
|
1647 appendEmail = ETrue; |
|
1648 } |
|
1649 else |
|
1650 { |
|
1651 CMtmUiDataRegistry* uiRegistry = |
|
1652 CMtmUiDataRegistry::NewL( *iSession ); |
|
1653 CleanupStack::PushL(uiRegistry); |
|
1654 if ( uiRegistry->IsPresent( tentry->iMtm ) && |
|
1655 uiRegistry->IsPresent( KUidMsgTypePOP3 ) ) |
|
1656 { |
|
1657 if( uiRegistry->TechnologyTypeUid( tentry->iMtm ) == |
|
1658 KSenduiTechnologyMailUid ) |
|
1659 { |
|
1660 appendEmail = ETrue; |
|
1661 } |
|
1662 } |
|
1663 CleanupStack::PopAndDestroy( uiRegistry ); |
|
1664 } |
|
1665 |
|
1666 if ( appendEmail ) |
|
1667 { |
|
1668 // Add this service if: |
|
1669 // it is visible, or,there is no associated related |
|
1670 // service, or, we have been asked to list all services. |
|
1671 sel->AppendL( tentry->Id() ); |
|
1672 } |
|
1673 } |
|
1674 } |
|
1675 } |
|
1676 } |
|
1677 CleanupStack::PopAndDestroy( entry ); |
|
1678 CleanupStack::Pop( sel ); |
|
1679 return sel; |
|
1680 } |
|
1681 |
|
1682 // ---------------------------------------------------- |
|
1683 // CMceSettingsMultipleServicesDialog::MtmAccountsL |
|
1684 // ---------------------------------------------------- |
|
1685 CUidNameArray* CMceSettingsMultipleServicesDialog::MtmEmailAccountsL() |
|
1686 { |
|
1687 CUidNameArray* accounts = new (ELeave) CUidNameArray( |
|
1688 KMceSettingsArrayGranularity ); |
|
1689 CleanupStack::PushL( accounts ); |
|
1690 |
|
1691 CMsvEntrySelection* sel = NULL; |
|
1692 |
|
1693 sel = GetEmailAccountsL( *iSession ); |
|
1694 |
|
1695 CleanupStack::PushL( sel ); |
|
1696 |
|
1697 CMsvEntry* rootEntry=CMsvEntry::NewL( |
|
1698 *iSession, |
|
1699 KMsvRootIndexEntryId, |
|
1700 TMsvSelectionOrdering( KMsvNoGrouping, EMsvSortByNone, ETrue ) ); |
|
1701 CleanupStack::PushL( rootEntry ); |
|
1702 |
|
1703 if ( !iEmailApi ) |
|
1704 { |
|
1705 iEmailApi = CreateEmailApiL( iSession ); |
|
1706 } |
|
1707 |
|
1708 const MImumInHealthServices* healthApi = &iEmailApi->HealthServicesL(); |
|
1709 |
|
1710 TInt error = MceSettingsUtils::GetHealthyMailboxListL( |
|
1711 *healthApi, |
|
1712 iMailboxArray, |
|
1713 iMessageType != KSenduiMtmSyncMLEmailUid, |
|
1714 iMessageType != KSenduiMtmSyncMLEmailUid, |
|
1715 iMessageType == KSenduiMtmSyncMLEmailUid,ETrue ); |
|
1716 if ( error == KErrNone && |
|
1717 ( iMtmPluginId == 0 || iMessageType == KSenduiMtmSyncMLEmailUid ) ) |
|
1718 { |
|
1719 const TInt mailboxArrayCount = iMailboxArray.Count(); |
|
1720 TMsvId msvId; |
|
1721 |
|
1722 for ( TInt cc = 0; cc < mailboxArrayCount; cc++) |
|
1723 { |
|
1724 msvId = iMailboxArray[cc]; |
|
1725 |
|
1726 TMsvEntry tentry2; |
|
1727 TRAPD( err2, ( tentry2 = rootEntry->ChildDataL( msvId ) ) ); |
|
1728 |
|
1729 const TInt count = accounts->Count(); |
|
1730 TBool foundService = EFalse; |
|
1731 |
|
1732 if ( err2 == KErrNone ) |
|
1733 { |
|
1734 |
|
1735 //check that related service is not already added to array |
|
1736 for ( TInt loop = 0; loop < count; loop ++ ) |
|
1737 { |
|
1738 if ( tentry2.iRelatedId == iMailboxArray[loop] ) |
|
1739 { |
|
1740 foundService = ETrue; |
|
1741 break; |
|
1742 } |
|
1743 } |
|
1744 if ( !foundService ) |
|
1745 { |
|
1746 TUid uid; |
|
1747 uid.iUid = tentry2.Id(); |
|
1748 TUidNameInfo info( uid, tentry2.iDetails.Left( |
|
1749 KMceSettingsMailboxTextLength ) ); |
|
1750 accounts->AppendL( info ); |
|
1751 } |
|
1752 |
|
1753 } |
|
1754 } |
|
1755 } |
|
1756 TUid uid; |
|
1757 CMtmUiDataRegistry* uiRegistry = CMtmUiDataRegistry::NewL( *iSession ); |
|
1758 CleanupStack::PushL( uiRegistry ); |
|
1759 const TInt numAccounts = sel->Count(); |
|
1760 for ( TInt cc = 0; cc < numAccounts; cc++) |
|
1761 { |
|
1762 uid.iUid = sel->At( cc ); |
|
1763 TMsvEntry tentry; |
|
1764 TRAPD( err, ( tentry = rootEntry->ChildDataL( uid.iUid ) ) ); |
|
1765 |
|
1766 TBool appendEmail = EFalse; |
|
1767 |
|
1768 // This avoids FS boxes to show in SyncML list |
|
1769 if ( iMessageType != KSenduiMtmSyncMLEmailUid ) |
|
1770 { |
|
1771 if ( tentry.Visible() ) |
|
1772 { |
|
1773 appendEmail = ETrue; |
|
1774 } |
|
1775 else |
|
1776 { |
|
1777 if ( uiRegistry->IsPresent( tentry.iMtm ) && |
|
1778 uiRegistry->IsPresent( KUidMsgTypePOP3 ) ) |
|
1779 { |
|
1780 TUid mailMTMTechType = |
|
1781 uiRegistry->TechnologyTypeUid( KUidMsgTypePOP3 ); |
|
1782 if( uiRegistry->TechnologyTypeUid( tentry.iMtm ) == |
|
1783 mailMTMTechType ) |
|
1784 { |
|
1785 appendEmail = ETrue; |
|
1786 } |
|
1787 } |
|
1788 } |
|
1789 |
|
1790 // Remove 3'rd party mailboxes which are not registered to handle |
|
1791 // S60 mailboxes |
|
1792 if ( iMtmPluginId != 0 && |
|
1793 tentry.iMtm.iUid != iMtmPluginId ) |
|
1794 { |
|
1795 appendEmail = EFalse; |
|
1796 } |
|
1797 } // != KSenduiMtmSyncMLEmailUid |
|
1798 |
|
1799 if ( err == KErrNone && |
|
1800 uiRegistry->IsPresent( tentry.iMtm ) && appendEmail ) |
|
1801 { |
|
1802 const TInt count = accounts->Count(); |
|
1803 TBool foundService = EFalse; |
|
1804 //check that related service is not already added to array |
|
1805 for ( TInt loop = 0; loop < count; loop ++ ) |
|
1806 { |
|
1807 if ( tentry.iRelatedId == (*accounts)[loop].iUid.iUid ) |
|
1808 { |
|
1809 foundService = ETrue; |
|
1810 break; |
|
1811 } |
|
1812 } |
|
1813 if ( !foundService ) |
|
1814 { |
|
1815 TUidNameInfo info( uid, tentry.iDetails.Left( |
|
1816 KMceSettingsMailboxTextLength ) ); |
|
1817 accounts->AppendL( info ); |
|
1818 } |
|
1819 } |
|
1820 } |
|
1821 CleanupStack::PopAndDestroy( uiRegistry ); |
|
1822 CleanupStack::PopAndDestroy( rootEntry ); |
|
1823 CleanupStack::PopAndDestroy( sel ); |
|
1824 CleanupStack::Pop( accounts ); |
|
1825 return accounts; |
|
1826 } |
|
1827 |
|
1828 // ---------------------------------------------------- |
|
1829 // CMceSettingsMultipleServicesDialog::UpdateForArrayChangeL |
|
1830 // ---------------------------------------------------- |
|
1831 void CMceSettingsMultipleServicesDialog::UpdateServicesArrayL() |
|
1832 { |
|
1833 CEikTextListBox* list = STATIC_CAST( CEikTextListBox*, |
|
1834 Control( EMceSettingsMultipleServicesDialogChoiceList ) ); |
|
1835 |
|
1836 TInt selectedIndex = list->CurrentItemIndex(); |
|
1837 const TInt count = iAccountArray->Count(); |
|
1838 CUidNameArray* sel = MtmEmailAccountsL(); |
|
1839 CleanupStack::PushL( sel ); |
|
1840 const TInt newCount = sel->Count(); |
|
1841 iAccountArray->Reset(); |
|
1842 iSettingsItemArray->Reset(); |
|
1843 SetAccountInUseL(); |
|
1844 TBuf <KMceSettingsMtmNameBufLength> mtms; |
|
1845 |
|
1846 for ( TInt loop = 0; loop < newCount; loop++ ) |
|
1847 { |
|
1848 iAccountArray->AppendL( sel->At( loop ) ); |
|
1849 |
|
1850 |
|
1851 mtms.Copy( KMceMtmName1 ); |
|
1852 mtms.Append( (*sel)[loop].iName ); |
|
1853 mtms.Append( KMceMtmName2 ); |
|
1854 iSettingsItemArray->AppendL( mtms ); |
|
1855 mtms.Zero(); |
|
1856 } |
|
1857 CleanupStack::PopAndDestroy( sel ); |
|
1858 |
|
1859 if ( newCount > count ) |
|
1860 { |
|
1861 list->HandleItemAdditionL(); |
|
1862 } |
|
1863 else if ( newCount < count ) |
|
1864 { |
|
1865 list->HandleItemRemovalL(); |
|
1866 } |
|
1867 else |
|
1868 { |
|
1869 // no action |
|
1870 } |
|
1871 |
|
1872 if ( newCount > 0 ) |
|
1873 { |
|
1874 if ( selectedIndex >= 0 && selectedIndex < newCount ) |
|
1875 { |
|
1876 list->SetCurrentItemIndex( selectedIndex ); |
|
1877 } |
|
1878 else |
|
1879 { |
|
1880 list->SetCurrentItemIndex( 0/*newCount - 1*/ ); |
|
1881 } |
|
1882 } |
|
1883 list->DrawNow(); |
|
1884 } |
|
1885 |
|
1886 // End of File |