|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Dialog showing all email MTMs |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <coemain.h> |
|
22 #include <aknnotewrappers.h> |
|
23 #include <eikenv.h> |
|
24 #include "MceSettingsEmailSel.h" |
|
25 #include <MceSettingsEmailSel.rsg> |
|
26 #include <MceSettings.rsg> |
|
27 #include <ConeResLoader.h> |
|
28 #include <data_caging_path_literals.hrh> |
|
29 #include <msvstd.h> |
|
30 #include <msvapi.h> |
|
31 #include <msvids.h> |
|
32 #include <StringLoader.h> |
|
33 #include <centralrepository.h> |
|
34 #include <MessagingDomainCRKeys.h> |
|
35 #include <mtmuids.h> |
|
36 #include <mtudcbas.h> |
|
37 #include <mtmuibas.h> |
|
38 #include <SendUiConsts.h> |
|
39 #include <bautils.h> |
|
40 #include <MtmExtendedCapabilities.hrh> |
|
41 #include <MuiuMsvUiServiceUtilities.h> |
|
42 #include <mtudreg.h> |
|
43 #include <miutset.h> |
|
44 #include <ImumInternalApi.h> |
|
45 #include <ImumInHealthServices.h> |
|
46 #include <muiuflags.h> |
|
47 #include <muiuemailtools.h> |
|
48 #include <featmgr.h> |
|
49 |
|
50 const TInt KArrayGranularity = 3; |
|
51 const TInt KCapabilitiesUnset = -1; |
|
52 |
|
53 _LIT( KMceEmailSelResourceFileName, |
|
54 "\\resource\\MceSettingsEmailSel.rsc" ); |
|
55 #define KUidMsgTypeFsMtmVal 0x2001F406 |
|
56 |
|
57 // EXTERNAL DATA STRUCTURES |
|
58 |
|
59 // EXTERNAL FUNCTION PROTOTYPES |
|
60 |
|
61 // CONSTANTS |
|
62 |
|
63 // MACROS |
|
64 |
|
65 // LOCAL CONSTANTS AND MACROS |
|
66 |
|
67 // MODULE DATA STRUCTURES |
|
68 |
|
69 // LOCAL FUNCTION PROTOTYPES |
|
70 |
|
71 // FORWARD DECLARATIONS |
|
72 |
|
73 // ============================= LOCAL FUNCTIONS =============================== |
|
74 |
|
75 |
|
76 // ============================ MEMBER FUNCTIONS =============================== |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CSampleApplication::CreateDocumentL |
|
80 // Create a Sample document, and return a pointer to it. |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 CMceSettingsEmailSel* CMceSettingsEmailSel::NewL() |
|
84 { |
|
85 // Create an object, and return a pointer to it |
|
86 CMceSettingsEmailSel* self = new (ELeave) CMceSettingsEmailSel; |
|
87 CleanupStack::PushL( self ); |
|
88 self->ConstructL(); |
|
89 CleanupStack::Pop(); |
|
90 return self; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CMceSettingsEmailSel::ConstructL |
|
95 // 2nd phase contructor that can leave. |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 void CMceSettingsEmailSel::ConstructL() |
|
99 { |
|
100 iMsvSessionPtr = CMsvSession::OpenSyncL( *this ); |
|
101 iMtmStore = CMtmStore::NewL( *iMsvSessionPtr ); |
|
102 LoadResourceL(); |
|
103 iRequiredCapabilities.iFlags = KCapabilitiesUnset; |
|
104 |
|
105 if ( FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework ) ) |
|
106 { |
|
107 iEmailFramework = ETrue; |
|
108 } |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // CMceSettingsEmailSel::CMceSettingsEmailSel |
|
113 // contructor |
|
114 // --------------------------------------------------------- |
|
115 // |
|
116 CMceSettingsEmailSel::CMceSettingsEmailSel() |
|
117 :iEmailFramework(EFalse) |
|
118 { |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // CMceSettingsEmailSel::~CMceSettingsEmailSel |
|
123 // Destructor |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 CMceSettingsEmailSel::~CMceSettingsEmailSel() |
|
127 { |
|
128 if( iMtmStore ) |
|
129 { |
|
130 delete iMtmStore; |
|
131 } |
|
132 if( iMsvSessionPtr ) |
|
133 { |
|
134 delete iMsvSessionPtr; |
|
135 } |
|
136 UnLoadResource(); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------- |
|
140 // CMceSettingsEmailSel::LoadResourceL |
|
141 // Load the resource for the dll module |
|
142 // --------------------------------------------------------- |
|
143 // |
|
144 void CMceSettingsEmailSel::LoadResourceL() |
|
145 { |
|
146 TFileName resourceFileNameBuf( KMceEmailSelResourceFileName ); |
|
147 |
|
148 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
149 BaflUtils::NearestLanguageFile( eikEnv->FsSession(), |
|
150 resourceFileNameBuf ); |
|
151 iResourceOffset = eikEnv->AddResourceFileL( resourceFileNameBuf ); |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------- |
|
155 // CMceSettingsEmailSel::UnLoadResource |
|
156 // Unload the resource for the dll module |
|
157 // --------------------------------------------------------- |
|
158 // |
|
159 void CMceSettingsEmailSel::UnLoadResource() |
|
160 { |
|
161 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
162 eikEnv->DeleteResourceFile( iResourceOffset ); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // CMceSettingsEmailSel::HandleSessionEventL |
|
167 // From MMsvSessionObserver |
|
168 // --------------------------------------------------------- |
|
169 // |
|
170 void CMceSettingsEmailSel::HandleSessionEventL( |
|
171 TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, |
|
172 TAny* /*aArg2*/, TAny* /*aArg3*/ ) |
|
173 { |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------- |
|
177 // CMceSettingsEmailSel::ShowEmailSelectDlgL |
|
178 // |
|
179 // --------------------------------------------------------- |
|
180 // |
|
181 EXPORT_C TBool CMceSettingsEmailSel::ShowSelectEmailDlgL( |
|
182 TMsvId& aSelectedService, TUid& aMtmType, |
|
183 TSendingCapabilities aRequiredCapabilities ) |
|
184 { |
|
185 CMceSettingsEmailSel* dlg = CMceSettingsEmailSel::NewL(); |
|
186 |
|
187 CleanupStack::PushL( dlg ); |
|
188 TBool retVal = dlg->ShowSelectDlgL( |
|
189 aSelectedService, aMtmType, aRequiredCapabilities ); |
|
190 CleanupStack::PopAndDestroy( dlg ); |
|
191 return retVal; |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------- |
|
195 // CMceSettingsEmailSel::ShowSelectDlgL |
|
196 // |
|
197 // --------------------------------------------------------- |
|
198 // |
|
199 TBool CMceSettingsEmailSel::ShowSelectDlgL( |
|
200 TMsvId& aSelectedService, TUid& aMtmType, |
|
201 TSendingCapabilities aRequiredCapabilities ) |
|
202 { |
|
203 iRequiredCapabilities = aRequiredCapabilities; |
|
204 // List items for list query. |
|
205 CDesCArrayFlat* listItems = new (ELeave) CDesCArrayFlat( |
|
206 KArrayGranularity ); |
|
207 CleanupStack::PushL( listItems ); |
|
208 |
|
209 // This array is used to map user selection to correct service. |
|
210 CArrayFix<TUid>* listItemUids = |
|
211 new ( ELeave ) CArrayFixFlat<TUid>( KArrayGranularity ); |
|
212 CleanupStack::PushL( listItemUids ); |
|
213 |
|
214 // Get and filter available MTM services supporting attachments. |
|
215 FilterEmailServicesL( *listItems, *listItemUids ); |
|
216 |
|
217 //Check if Cmail is enabled |
|
218 if(iEmailFramework) |
|
219 { |
|
220 return ShowCmailSelectDlgL(aSelectedService, aMtmType,listItems, listItemUids ); |
|
221 } |
|
222 |
|
223 // no accounts defined, nothing to show |
|
224 if ( 0 == listItems->Count() ) |
|
225 { |
|
226 CleanupStack::PopAndDestroy( listItemUids ); |
|
227 CleanupStack::PopAndDestroy( listItems ); |
|
228 aSelectedService = KMsvUnknownServiceIndexEntryId; |
|
229 return ETrue; |
|
230 } |
|
231 |
|
232 // only one account, selection dialog not shown |
|
233 if( listItems->Count() == 1 ) |
|
234 { |
|
235 aSelectedService = (*listItemUids)[0].iUid; |
|
236 |
|
237 TMsvEntry entry; |
|
238 TMsvId serviceId; |
|
239 User::LeaveIfError( iMsvSessionPtr->GetEntry( |
|
240 (*listItemUids)[0].iUid, serviceId, entry ) ); |
|
241 if ( entry.iMtm == KSenduiMtmPop3Uid || |
|
242 entry.iMtm == KSenduiMtmImap4Uid ) |
|
243 { |
|
244 aMtmType = KSenduiMtmSmtpUid; |
|
245 aSelectedService = entry.iRelatedId; // related = SMTP |
|
246 } |
|
247 else |
|
248 { |
|
249 aMtmType = entry.iMtm; |
|
250 } |
|
251 |
|
252 CleanupStack::PopAndDestroy( listItemUids ); |
|
253 CleanupStack::PopAndDestroy( listItems ); |
|
254 return ETrue; |
|
255 } |
|
256 |
|
257 // Show list query. |
|
258 TInt choice = KErrNotFound; |
|
259 CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( &choice ); |
|
260 dlg->PrepareLC( R_SEND_EMAIL_LIST_QUERY ); |
|
261 dlg->SetItemTextArray( listItems ); |
|
262 dlg->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
263 |
|
264 if ( !dlg->RunLD() ) |
|
265 { |
|
266 // Cancel |
|
267 CleanupStack::PopAndDestroy( listItemUids ); |
|
268 CleanupStack::PopAndDestroy( listItems ); |
|
269 return EFalse; |
|
270 } |
|
271 |
|
272 aSelectedService = (*listItemUids)[choice].iUid; |
|
273 |
|
274 TMsvEntry entry; |
|
275 TMsvId serviceId; |
|
276 User::LeaveIfError( iMsvSessionPtr->GetEntry( |
|
277 aSelectedService, serviceId, entry ) ); |
|
278 if ( entry.iMtm == KSenduiMtmPop3Uid || |
|
279 entry.iMtm == KSenduiMtmImap4Uid ) |
|
280 { |
|
281 aMtmType = KSenduiMtmSmtpUid; |
|
282 aSelectedService = entry.iRelatedId; // related = SMTP |
|
283 } |
|
284 else |
|
285 { |
|
286 aMtmType = entry.iMtm; |
|
287 } |
|
288 |
|
289 CleanupStack::PopAndDestroy( listItemUids ); |
|
290 CleanupStack::PopAndDestroy( listItems ); |
|
291 return ETrue; |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------- |
|
295 // CMceSettingsEmailSel::ShowCmailSelectDlgL |
|
296 // |
|
297 // --------------------------------------------------------- |
|
298 // |
|
299 TBool CMceSettingsEmailSel::ShowCmailSelectDlgL(TMsvId& aSelectedService, |
|
300 TUid& aMtmType, |
|
301 CDesCArrayFlat* aListItems, |
|
302 CArrayFix<TUid>* aListItemUids) |
|
303 { |
|
304 TBool retval = EFalse; |
|
305 //Add the non cmail boxes at the end of cmail list |
|
306 for(int cnt = 0; cnt < aListItems->Count(); cnt++ ) |
|
307 { |
|
308 iCmaillistItems->AppendL(aListItems->MdcaPoint(cnt)); |
|
309 iCmaillistItemUids->AppendL(aListItemUids->At(cnt)); |
|
310 } |
|
311 |
|
312 // no accounts defined, nothing to show |
|
313 if ( 0 == iCmaillistItems->Count() ) |
|
314 { |
|
315 aSelectedService = KMsvUnknownServiceIndexEntryId; |
|
316 retval = ETrue; |
|
317 } |
|
318 |
|
319 // only one account, selection dialog not shown |
|
320 if( iCmaillistItems->Count() == 1 && !retval ) |
|
321 { |
|
322 aSelectedService = (*iCmaillistItemUids)[0].iUid; |
|
323 |
|
324 TMsvEntry entry; |
|
325 TMsvId serviceId; |
|
326 User::LeaveIfError( iMsvSessionPtr->GetEntry( |
|
327 (*iCmaillistItemUids)[0].iUid, serviceId, entry ) ); |
|
328 if ( entry.iMtm == KSenduiMtmPop3Uid || |
|
329 entry.iMtm == KSenduiMtmImap4Uid ) |
|
330 { |
|
331 aMtmType = KSenduiMtmSmtpUid; |
|
332 aSelectedService = entry.iRelatedId; // related = SMTP |
|
333 } |
|
334 else |
|
335 { |
|
336 aMtmType = entry.iMtm; |
|
337 } |
|
338 retval = ETrue; |
|
339 } |
|
340 TBool cancel = EFalse; |
|
341 if( !retval ) |
|
342 { |
|
343 // Show list query. |
|
344 TInt choice = KErrNotFound; |
|
345 CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( &choice ); |
|
346 dlg->PrepareLC( R_SEND_EMAIL_LIST_QUERY ); |
|
347 dlg->SetItemTextArray( iCmaillistItems ); |
|
348 dlg->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
349 |
|
350 if ( !dlg->RunLD() ) |
|
351 { |
|
352 // Cancel |
|
353 cancel = ETrue; |
|
354 //retval = EFalse; |
|
355 } |
|
356 if(!cancel) |
|
357 { |
|
358 aSelectedService = (*iCmaillistItemUids)[choice].iUid; |
|
359 |
|
360 TMsvEntry entry; |
|
361 TMsvId serviceId; |
|
362 User::LeaveIfError( iMsvSessionPtr->GetEntry( |
|
363 aSelectedService, serviceId, entry ) ); |
|
364 aMtmType = entry.iMtm; |
|
365 } |
|
366 } |
|
367 delete iCmaillistItemUids; |
|
368 iCmaillistItemUids = NULL; |
|
369 delete iCmaillistItems; |
|
370 iCmaillistItems = NULL;; |
|
371 CleanupStack::PopAndDestroy( aListItemUids ); |
|
372 CleanupStack::PopAndDestroy( aListItems ); |
|
373 if(cancel) |
|
374 return EFalse; |
|
375 else |
|
376 return ETrue; |
|
377 } |
|
378 // --------------------------------------------------------- |
|
379 // TPtrC8Ident |
|
380 // Hash Table Function |
|
381 // --------------------------------------------------------- |
|
382 // |
|
383 TBool TPtrC8Ident(const TPtrC16& aL, const TPtrC16& aR) |
|
384 { |
|
385 return DefaultIdentity::Des16(aL, aR); |
|
386 } |
|
387 |
|
388 // --------------------------------------------------------- |
|
389 // TPtrC8Hash |
|
390 // Hash Table Function |
|
391 // --------------------------------------------------------- |
|
392 // |
|
393 TUint32 TPtrC8Hash(const TPtrC16& aPtr) |
|
394 { |
|
395 return DefaultHash::Des16(aPtr); |
|
396 |
|
397 } |
|
398 // --------------------------------------------------------- |
|
399 // CMceSettingsEmailSel::FilterEmailServicesL |
|
400 // |
|
401 // --------------------------------------------------------- |
|
402 // |
|
403 void CMceSettingsEmailSel::FilterEmailServicesL( |
|
404 CDesCArrayFlat& aListItems, |
|
405 CArrayFix<TUid>& aListItemUids ) |
|
406 { |
|
407 iDefaultIndex = -1; |
|
408 |
|
409 TInt keyValue; |
|
410 CRepository* repository = NULL; |
|
411 TRAPD( ret, repository = CRepository::NewL( KCRUidSelectableDefaultEmailSettings ) ); |
|
412 |
|
413 if ( ret == KErrNone ) |
|
414 { |
|
415 if ( repository->Get( KSelectableDefaultMailAccount , keyValue ) != KErrNone ) |
|
416 { |
|
417 iDefaultIndex = -1; |
|
418 } |
|
419 // Check if there is other than platform email application registered |
|
420 // to handle S60 mailboxes |
|
421 TInt err = repository->Get( KIntegratedEmailAppMtmPluginId , |
|
422 iMtmPluginID ); |
|
423 if ( err != KErrNone ) |
|
424 { |
|
425 iMtmPluginID = 0; |
|
426 } |
|
427 } |
|
428 delete repository; |
|
429 |
|
430 // fetch email mtms |
|
431 CMsvEntry* entry = iMsvSessionPtr->GetEntryL( KMsvRootIndexEntryId ); |
|
432 CleanupStack::PushL( entry ); |
|
433 |
|
434 TInt cnt = entry->Count(); |
|
435 |
|
436 // Add default item first |
|
437 if(!iEmailFramework) |
|
438 { |
|
439 entry->SetSortTypeL( TMsvSelectionOrdering( |
|
440 KMsvGroupByType | KMsvGroupByStandardFolders, |
|
441 EMsvSortByDetailsReverse, ETrue ) ); |
|
442 |
|
443 for ( TInt cc = entry->Count(); --cc >= 0; ) |
|
444 { |
|
445 iTentryDef = (*entry)[cc]; |
|
446 if(!IsMailBoxHealthyL(iTentryDef)) |
|
447 { |
|
448 continue; |
|
449 } |
|
450 |
|
451 if ( iTentryDef.iType.iUid == KUidMsvServiceEntryValue && |
|
452 iTentryDef.Id() != KMsvLocalServiceIndexEntryIdValue ) |
|
453 { |
|
454 const TBool noRelatedId = |
|
455 iTentryDef.iRelatedId == KMsvNullIndexEntryId || |
|
456 iTentryDef.iRelatedId == iTentryDef.Id(); |
|
457 |
|
458 if ( IsEmailEntryL(iTentryDef) && |
|
459 ( ( iTentryDef.Id() == keyValue ) || |
|
460 ( iTentryDef.iRelatedId == keyValue) ) ) |
|
461 { |
|
462 TBool append = ETrue; |
|
463 // query capability (attachment) |
|
464 TUid entryUid; |
|
465 entryUid = iTentryDef.iMtm; |
|
466 |
|
467 if ( iTentryDef.iMtm == KSenduiMtmPop3Uid || |
|
468 iTentryDef.iMtm == KSenduiMtmImap4Uid ) |
|
469 { |
|
470 entryUid = KSenduiMtmSmtpUid; |
|
471 } |
|
472 |
|
473 TBool ret = EFalse; |
|
474 TRAPD( err, ret = QueryCapabilitiesAndValidateAccountL( |
|
475 entryUid ) ) |
|
476 if ( ret && ( err == KErrNone ) ) |
|
477 { |
|
478 append = ETrue; |
|
479 } |
|
480 else |
|
481 { |
|
482 append = EFalse; |
|
483 } |
|
484 |
|
485 const TInt count = aListItemUids.Count(); |
|
486 |
|
487 // Check that related service is not already added to |
|
488 // array |
|
489 for ( TInt loop = 0; loop < count; loop ++ ) |
|
490 { |
|
491 if ( iTentryDef.iRelatedId == |
|
492 aListItemUids.At(loop).iUid ) |
|
493 { |
|
494 append = EFalse; |
|
495 break; |
|
496 } |
|
497 } |
|
498 |
|
499 if( append ) |
|
500 { |
|
501 // Add this service if: |
|
502 // it is visible, or,there is no associated related |
|
503 // service, or, we have been asked to list all |
|
504 // services. |
|
505 HBufC* stringholder; |
|
506 stringholder = StringLoader::LoadLC( |
|
507 R_MCE_POPUP_DEFAULT_EMAIL, |
|
508 iTentryDef.iDetails ); //Pushes stringholder onto the |
|
509 //Cleanup Stack. |
|
510 |
|
511 entryUid.iUid = iTentryDef.Id(); |
|
512 aListItems.AppendL( stringholder->Des() ); |
|
513 aListItemUids.AppendL( entryUid ); |
|
514 iDefaultIndex = cc; |
|
515 CleanupStack::PopAndDestroy( stringholder ); |
|
516 iTentryDef = (*entry)[iDefaultIndex]; |
|
517 break; |
|
518 } |
|
519 } |
|
520 } |
|
521 } |
|
522 } |
|
523 |
|
524 //Add Other Email Boxes |
|
525 AddOtherEmailBoxesL(aListItems, aListItemUids, entry); |
|
526 |
|
527 if(iEmailFramework) |
|
528 { |
|
529 //Hash Table to store the information of non cmail mailboxes for sorting and arranging their uids |
|
530 RHashMap<TPtrC16, TInt32 >* nonCmailUid = new( ELeave )RHashMap< TPtrC16, TInt32 > |
|
531 (&TPtrC8Hash , &TPtrC8Ident); |
|
532 CleanupStack::PushL( nonCmailUid); |
|
533 |
|
534 for(TInt loop = 0; loop < aListItems.Count() ; loop++ ) |
|
535 { |
|
536 nonCmailUid->Insert(aListItems.MdcaPoint(loop), aListItemUids.At(loop).iUid ); |
|
537 } |
|
538 |
|
539 //Sort the non cmail items alphabatically |
|
540 aListItems.Sort(ECmpFolded); |
|
541 |
|
542 //Reset the array to load the Uids in new sorted order |
|
543 aListItemUids.Reset(); |
|
544 |
|
545 for(TInt loop = 0; loop < aListItems.Count() ; loop++ ) |
|
546 { |
|
547 TInt32* uid = nonCmailUid->Find(aListItems.MdcaPoint(loop)); |
|
548 aListItemUids.AppendL(TUid::Uid( *uid )); |
|
549 } |
|
550 |
|
551 CleanupStack::PopAndDestroy( nonCmailUid ); |
|
552 } |
|
553 CleanupStack::PopAndDestroy( entry ); |
|
554 |
|
555 } |
|
556 // --------------------------------------------------------- |
|
557 // TPtrC8Hash |
|
558 // Hash Table Function |
|
559 // --------------------------------------------------------- |
|
560 // |
|
561 TUint32 TPtrC8Hash(const TInt64 & atime) |
|
562 { |
|
563 return DefaultHash::Integer(atime); |
|
564 } |
|
565 |
|
566 // --------------------------------------------------------- |
|
567 // TInt64Ident |
|
568 // Hash Table Function |
|
569 // --------------------------------------------------------- |
|
570 // |
|
571 TBool TInt64Ident(const TInt64& aL, const TInt64& aR) |
|
572 { |
|
573 return DefaultIdentity::Integer(aL, aR); |
|
574 |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------- |
|
578 // CMceSettingsEmailSel::IsEmailEntryL |
|
579 // |
|
580 // (other items were commented in a header). |
|
581 // --------------------------------------------------------- |
|
582 // |
|
583 TBool CMceSettingsEmailSel::IsEmailEntryL(TMsvEntry tentry) |
|
584 { |
|
585 TBool appendEmail = EFalse; |
|
586 if ( tentry.Visible() ) |
|
587 { |
|
588 appendEmail = ETrue; |
|
589 } |
|
590 else |
|
591 { |
|
592 CMtmUiDataRegistry* uiRegistry = |
|
593 CMtmUiDataRegistry::NewL( *iMsvSessionPtr ); |
|
594 CleanupStack::PushL(uiRegistry); |
|
595 if ( uiRegistry->IsPresent( tentry.iMtm ) && |
|
596 uiRegistry->IsPresent( KUidMsgTypePOP3 ) ) |
|
597 { |
|
598 TUid mailMTMTechType = |
|
599 uiRegistry->TechnologyTypeUid( KUidMsgTypePOP3 ); |
|
600 if( uiRegistry->TechnologyTypeUid( tentry.iMtm ) == |
|
601 mailMTMTechType ) |
|
602 { |
|
603 appendEmail = ETrue; |
|
604 } |
|
605 } |
|
606 CleanupStack::PopAndDestroy( uiRegistry ); |
|
607 } |
|
608 return appendEmail; |
|
609 } |
|
610 |
|
611 // --------------------------------------------------------- |
|
612 // CMceSettingsEmailSel::AppendCmailBoxesL( |
|
613 // |
|
614 // (other items were commented in a header). |
|
615 // --------------------------------------------------------- |
|
616 // |
|
617 void CMceSettingsEmailSel::AppendCmailBoxesL(CArrayFix<TInt64 >* atimeItems, CMsvEntry* aEntry) |
|
618 { |
|
619 //Sort the cmail Entry items based on time |
|
620 TKeyArrayFix key( 0, ECmpTInt64 ); |
|
621 atimeItems->Sort(key); |
|
622 TUid cmailEntryUid; |
|
623 |
|
624 //Array to get the list of Cmail Boxes |
|
625 iCmaillistItems = new (ELeave) CDesCArrayFlat( |
|
626 KArrayGranularity ); |
|
627 |
|
628 iCmaillistItemUids = new ( ELeave ) CArrayFixFlat<TUid>( KArrayGranularity ); |
|
629 |
|
630 // Go one by one in Hash table |
|
631 if(atimeItems->Count() > 0) |
|
632 { |
|
633 for(TInt cnt = (atimeItems->Count() - 1) ; cnt >= 0 ; cnt--) |
|
634 { |
|
635 //Take one by one the Time Entry and Find the correponding Position Key |
|
636 //from key get the correponding Entry |
|
637 TInt* entrypos = iCmailBoxes->Find(atimeItems->At(cnt)); |
|
638 TMsvEntry cmailentry = (*aEntry)[*entrypos]; |
|
639 |
|
640 iCmaillistItems->AppendL(cmailentry.iDetails); |
|
641 cmailEntryUid.iUid = cmailentry.Id(); |
|
642 iCmaillistItemUids->AppendL(cmailEntryUid); |
|
643 } |
|
644 } |
|
645 } |
|
646 |
|
647 // --------------------------------------------------------- |
|
648 // CMceSettingsEmailSel::AddOtherEmailBoxesL |
|
649 // |
|
650 // (other items were commented in a header). |
|
651 // --------------------------------------------------------- |
|
652 // |
|
653 void CMceSettingsEmailSel::AddOtherEmailBoxesL(CDesCArrayFlat& aListItems, CArrayFix<TUid>& aListItemUids , CMsvEntry* aEntry) |
|
654 { |
|
655 CArrayFix<TInt64 >* timeItems; |
|
656 CDesCArrayFlat* cmaillist; |
|
657 TTime timeNow; |
|
658 |
|
659 if(iEmailFramework) |
|
660 { |
|
661 //Added for Cmail Details |
|
662 iCmailBoxes = |
|
663 new( ELeave )RHashMap< TInt64, TInt > |
|
664 (&TPtrC8Hash , &TInt64Ident); |
|
665 |
|
666 // This array is used to map user selection to correct service. |
|
667 timeItems = |
|
668 new ( ELeave ) CArrayFixFlat<TInt64 >( 3 ); |
|
669 CleanupStack::PushL( timeItems ); |
|
670 |
|
671 cmaillist = new (ELeave) CDesCArrayFlat( |
|
672 KArrayGranularity ); |
|
673 CleanupStack::PushL( cmaillist ); |
|
674 |
|
675 aEntry->SetSortTypeL( TMsvSelectionOrdering( |
|
676 KMsvGroupByMtm, |
|
677 EMsvSortByDetailsReverse, ETrue ) ); |
|
678 |
|
679 timeNow.UniversalTime(); |
|
680 |
|
681 } |
|
682 |
|
683 // take entry one by one |
|
684 for ( TInt cc = aEntry->Count(); --cc >= 0; ) |
|
685 { |
|
686 TMsvEntry tentry2 = (*aEntry)[cc]; |
|
687 |
|
688 if(!IsMailBoxHealthyL(tentry2)) |
|
689 { |
|
690 continue; |
|
691 } |
|
692 |
|
693 if ( tentry2.iType.iUid == KUidMsvServiceEntryValue && |
|
694 tentry2.Id() != KMsvLocalServiceIndexEntryIdValue ) |
|
695 { |
|
696 if ( IsEmailEntryL(tentry2) && ( cc != iDefaultIndex ) ) |
|
697 { |
|
698 TBool append = ETrue; |
|
699 TUid entryUid; |
|
700 |
|
701 append = IsMailBoxAppendable( tentry2, &entryUid ); |
|
702 // If related service is SyncML or if 3'rd party email |
|
703 // plugin is registered but the mailbox uid is wrong, |
|
704 // it should be skipped. (This avoids doubles) |
|
705 if(!iEmailFramework) |
|
706 { |
|
707 if ( entryUid != KSenduiMtmSmtpUid || |
|
708 iMtmPluginID != 0 && tentry2.iMtm.iUid != iMtmPluginID ) |
|
709 { |
|
710 append = EFalse; |
|
711 } |
|
712 } |
|
713 if ( append ) |
|
714 { |
|
715 append = IfMailBoxUidAlreadyAdded( &aListItemUids, tentry2 ); |
|
716 |
|
717 if(! IfMailBoxAlreadyAdded(aListItems, cmaillist, tentry2 )) |
|
718 continue; |
|
719 } |
|
720 if ( tentry2.iDetails.Compare(iTentryDef.iDetails) == 0 ) |
|
721 { |
|
722 append = EFalse; |
|
723 } |
|
724 |
|
725 if( append ) |
|
726 { |
|
727 // Add this service if: |
|
728 // it is visible, or,there is no associated related |
|
729 // service, or, we have been asked to list all |
|
730 // services. |
|
731 entryUid.iUid = tentry2.Id(); |
|
732 //If cmail box add to the hash table and cmaillist |
|
733 if(tentry2.iMtm.iUid == KUidMsgTypeFsMtmVal ) |
|
734 { |
|
735 TTimeIntervalMicroSeconds difference = timeNow.MicroSecondsFrom( tentry2.iDate.Int64() ); |
|
736 TInt ret = iCmailBoxes->Insert(difference.Int64() , cc ); |
|
737 timeItems->AppendL(difference.Int64()); |
|
738 cmaillist->AppendL(tentry2.iDetails); |
|
739 } |
|
740 //Add Non Cmail |
|
741 else |
|
742 { |
|
743 aListItemUids.AppendL( entryUid ); |
|
744 aListItems.AppendL( tentry2.iDetails ); |
|
745 } |
|
746 } |
|
747 } |
|
748 } |
|
749 } |
|
750 |
|
751 if(iEmailFramework) |
|
752 { |
|
753 AppendCmailBoxesL(timeItems, aEntry); |
|
754 CleanupStack::PopAndDestroy( cmaillist ); |
|
755 CleanupStack::PopAndDestroy( timeItems ); |
|
756 delete iCmailBoxes; |
|
757 iCmailBoxes = NULL; |
|
758 } |
|
759 } |
|
760 |
|
761 // --------------------------------------------------------- |
|
762 // CMceSettingsEmailSel::IfMailBoxAlreadyAdded |
|
763 // |
|
764 // (other items were commented in a header). |
|
765 // --------------------------------------------------------- |
|
766 // |
|
767 TBool CMceSettingsEmailSel::IfMailBoxAlreadyAdded(CDesCArrayFlat& aListItems, CDesCArrayFlat* aCmaillist, TMsvEntry aTentry) |
|
768 { |
|
769 TBool append = ETrue; |
|
770 if(iEmailFramework) |
|
771 { |
|
772 //Non Cmail/ Third Parties shold not be added twice |
|
773 for ( TInt loop = 0; loop < aListItems.Count(); loop ++ ) |
|
774 { |
|
775 if ( aTentry.iDetails.Compare(aListItems.MdcaPoint(loop)) == 0 ) |
|
776 { |
|
777 append = EFalse; |
|
778 break; |
|
779 } |
|
780 } |
|
781 |
|
782 //Cmail should not be added doubles |
|
783 for ( TInt loop = 0; loop < aCmaillist->Count(); loop ++ ) |
|
784 { |
|
785 if ( aTentry.iDetails.Compare(aCmaillist->MdcaPoint(loop)) == 0) |
|
786 { |
|
787 append = EFalse; |
|
788 break; |
|
789 } |
|
790 } |
|
791 } |
|
792 return append; |
|
793 } |
|
794 |
|
795 // --------------------------------------------------------- |
|
796 // CMceSettingsEmailSel::IsMailBoxAppendable |
|
797 // |
|
798 // (other items were commented in a header). |
|
799 // --------------------------------------------------------- |
|
800 // |
|
801 TBool CMceSettingsEmailSel::IsMailBoxAppendable(TMsvEntry tentry2, TUid* aUid) |
|
802 { |
|
803 TBool append = ETrue; |
|
804 |
|
805 *aUid = tentry2.iMtm; |
|
806 |
|
807 if(!iEmailFramework) |
|
808 { |
|
809 if ( tentry2.iMtm == KSenduiMtmPop3Uid || |
|
810 tentry2.iMtm == KSenduiMtmImap4Uid || |
|
811 tentry2.iMtm.iUid == iMtmPluginID ) |
|
812 { |
|
813 *aUid = KSenduiMtmSmtpUid; |
|
814 } |
|
815 } |
|
816 else |
|
817 { |
|
818 if ( (tentry2.iMtm == KSenduiMtmPop3Uid || |
|
819 tentry2.iMtm == KSenduiMtmImap4Uid) && (tentry2.iMtm.iUid != KUidMsgTypeFsMtmVal)) |
|
820 { |
|
821 *aUid = KSenduiMtmSmtpUid; |
|
822 } |
|
823 } |
|
824 |
|
825 |
|
826 TBool ret = EFalse; |
|
827 TRAPD( err, ret = |
|
828 QueryCapabilitiesAndValidateAccountL( *aUid ) ) |
|
829 if ( ret && ( err == KErrNone ) ) |
|
830 { |
|
831 append = ETrue; |
|
832 } |
|
833 else |
|
834 { |
|
835 append = EFalse; |
|
836 } |
|
837 return append; |
|
838 } |
|
839 |
|
840 // --------------------------------------------------------- |
|
841 // CMceSettingsEmailSel::IsMailBoxHealthyL |
|
842 // |
|
843 // (other items were commented in a header). |
|
844 // --------------------------------------------------------- |
|
845 // |
|
846 TBool CMceSettingsEmailSel::IsMailBoxHealthyL(TMsvEntry aTentry) |
|
847 { |
|
848 TBool retval = EFalse; |
|
849 // Get all the healthy mailmox list. It filters the unhealthy mailbox. |
|
850 CImumInternalApi* emailApi = CreateEmailApiLC( &*iMsvSessionPtr ); |
|
851 const MImumInHealthServices& mailboxDoctor = emailApi->HealthServicesL(); |
|
852 |
|
853 if ( ( !mailboxDoctor.IsMailboxHealthy( aTentry.Id() ) ) && |
|
854 ( !( ( aTentry.iType == KUidMsvServiceEntry ) && |
|
855 ( aTentry.Id() != KMsvLocalServiceIndexEntryId ) && |
|
856 ( !MuiuEmailTools::IsMailMtm( aTentry.iMtm, ETrue ) ) ) ) ) |
|
857 { |
|
858 retval = EFalse; |
|
859 } |
|
860 else |
|
861 retval = ETrue; |
|
862 |
|
863 CleanupStack::PopAndDestroy( emailApi ); |
|
864 return retval; |
|
865 } |
|
866 |
|
867 // --------------------------------------------------------- |
|
868 // CMceSettingsEmailSel::IfMailBoxUidAlreadyAdded |
|
869 // |
|
870 // (other items were commented in a header). |
|
871 // --------------------------------------------------------- |
|
872 // |
|
873 TBool CMceSettingsEmailSel::IfMailBoxUidAlreadyAdded(CArrayFix<TUid>* aListItemsUids, TMsvEntry aTentry) |
|
874 { |
|
875 TBool append = ETrue; |
|
876 const TInt count = aListItemsUids->Count(); |
|
877 // check that related service is not already added to |
|
878 // array |
|
879 for ( TInt loop = 0; loop < count; loop ++ ) |
|
880 { |
|
881 if ( aTentry.iRelatedId == |
|
882 aListItemsUids->At( loop ).iUid ) |
|
883 { |
|
884 append = EFalse; |
|
885 break; |
|
886 } |
|
887 |
|
888 } |
|
889 return append; |
|
890 } |
|
891 |
|
892 // --------------------------------------------------------- |
|
893 // CMceSettingsEmailSel::QueryCapabilitiesAndValidateAccountL |
|
894 // |
|
895 // (other items were commented in a header). |
|
896 // --------------------------------------------------------- |
|
897 // |
|
898 TBool CMceSettingsEmailSel::QueryCapabilitiesAndValidateAccountL( |
|
899 TUid aMtmUid ) |
|
900 { |
|
901 TInt response = 0; |
|
902 const TUid supportEditor = { KUidMsvMtmQuerySupportEditor }; |
|
903 const TUid canCreateNewMsg = { KUidMtmQueryCanCreateNewMsgValue }; |
|
904 |
|
905 // Check to see that accounts (if required) have been set up |
|
906 TMsvId id; |
|
907 TMsvEntry indexEntry; |
|
908 |
|
909 User::LeaveIfError( iMsvSessionPtr->GetEntry( |
|
910 KMsvRootIndexEntryId, id, indexEntry ) ); |
|
911 |
|
912 CBaseMtmUiData& mtmUiData = iMtmStore->MtmUiDataL( aMtmUid ); |
|
913 |
|
914 TInt validAccounts = ETrue; |
|
915 TMsvEntry serviceEntry; |
|
916 serviceEntry.iType.iUid = KUidMsvServiceEntryValue; |
|
917 serviceEntry.iMtm = aMtmUid; |
|
918 |
|
919 if ( mtmUiData.CanCreateEntryL( indexEntry, serviceEntry, response ) ) |
|
920 { |
|
921 CMsvEntrySelection* accounts = |
|
922 MsvUiServiceUtilities::GetListOfAccountsWithMTML( |
|
923 *iMsvSessionPtr, aMtmUid, ETrue ); |
|
924 |
|
925 if ( accounts->Count() == 0 ) |
|
926 { |
|
927 validAccounts = EFalse; |
|
928 } |
|
929 |
|
930 delete accounts; |
|
931 accounts = NULL; |
|
932 } |
|
933 |
|
934 if ( !validAccounts ) |
|
935 { |
|
936 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
937 return EFalse; |
|
938 } |
|
939 |
|
940 // Query capabilities |
|
941 if ( mtmUiData.QueryCapability( |
|
942 canCreateNewMsg, response ) != KErrNone ) |
|
943 { |
|
944 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
945 return EFalse; |
|
946 } |
|
947 |
|
948 mtmUiData.QueryCapability( KUidMtmQueryMaxBodySize, response ); |
|
949 if ( response < iRequiredCapabilities.iBodySize ) |
|
950 { |
|
951 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
952 return EFalse; |
|
953 } |
|
954 |
|
955 mtmUiData.QueryCapability( KUidMtmQueryMaxTotalMsgSize, response ); |
|
956 if ( response < iRequiredCapabilities.iMessageSize ) |
|
957 { |
|
958 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
959 return EFalse; |
|
960 } |
|
961 |
|
962 if ( iRequiredCapabilities.iFlags == TSendingCapabilities::EAllServices ) |
|
963 { // No capabilities required from service |
|
964 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
965 return ETrue; |
|
966 } |
|
967 |
|
968 // Check if support for attachments are required. |
|
969 if ( iRequiredCapabilities.iFlags & |
|
970 TSendingCapabilities::ESupportsAttachments ) |
|
971 { |
|
972 if ( mtmUiData.QueryCapability( |
|
973 KUidMtmQuerySupportAttachments, response ) == KErrNone ) |
|
974 { |
|
975 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
976 return ETrue; |
|
977 } |
|
978 } |
|
979 |
|
980 // Check if support for body text is required. |
|
981 if ( iRequiredCapabilities.iFlags & |
|
982 TSendingCapabilities::ESupportsBodyText ) |
|
983 { |
|
984 if ( mtmUiData.QueryCapability( |
|
985 KUidMtmQuerySupportedBody, response ) == KErrNone ) |
|
986 { |
|
987 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
988 return ETrue; |
|
989 } |
|
990 } |
|
991 |
|
992 // Check if support for BIO sending is required. |
|
993 if ( iRequiredCapabilities.iFlags & |
|
994 TSendingCapabilities::ESupportsBioSending ) |
|
995 { |
|
996 if ( mtmUiData.QueryCapability( |
|
997 KUidMsvQuerySupportsBioMsg, response ) == KErrNone ) |
|
998 { |
|
999 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
1000 return ETrue; |
|
1001 } |
|
1002 } |
|
1003 |
|
1004 // Check if support for editor is required. |
|
1005 if ( iRequiredCapabilities.iFlags & |
|
1006 TSendingCapabilities::ESupportsEditor ) |
|
1007 { |
|
1008 if ( mtmUiData.QueryCapability( |
|
1009 supportEditor, response ) == KErrNone ) |
|
1010 { |
|
1011 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
1012 return ETrue; |
|
1013 } |
|
1014 } |
|
1015 |
|
1016 iMtmStore->ReleaseMtmUiData( aMtmUid ); // Remove from cache |
|
1017 return EFalse; |
|
1018 } |
|
1019 |
|
1020 // End of File |
|
1021 |