150 else |
150 else |
151 { |
151 { |
152 CleanupStack::PushL( mailbox ); |
152 CleanupStack::PushL( mailbox ); |
153 CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox ); |
153 CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox ); |
154 CleanupStack::PushL( mailboxDetails ); |
154 CleanupStack::PushL( mailboxDetails ); |
155 |
155 |
156 TBuf<KMaxDescLen> cid; |
156 TBuf<KMaxDescLen> cid; |
157 TInt next(1); |
157 TInt next(1); |
158 |
158 |
159 // Check if same mailbox is already in iAccountsArray once or more |
159 // Check if same mailbox is already in iAccountsArray once or more |
160 for ( TInt i = 0; i < iAccountsArray.Count(); i++ ) |
160 for ( TInt i = 0; i < iAccountsArray.Count(); i++ ) |
161 { |
161 { |
162 TInt id = (TInt)iAccountsArray[i]->iMailboxId.Id(); |
162 TInt id = (TInt)iAccountsArray[i]->iMailboxId.Id(); |
163 if (id == mailboxId) |
163 if (id == mailboxId) |
164 { |
164 { |
165 next++; |
165 next++; |
166 } |
166 } |
167 } |
167 } |
168 iSettings->GetContentId(mailboxId, next, cid); |
168 iSettings->GetContentId(mailboxId, next, cid); |
169 mailboxDetails->SetWidgetInstance(cid); |
169 mailboxDetails->SetWidgetInstance(cid); |
170 iAccountsArray.AppendL( mailboxDetails ); |
170 iAccountsArray.AppendL( mailboxDetails ); |
171 CleanupStack::Pop( mailboxDetails ); |
171 CleanupStack::Pop( mailboxDetails ); |
172 CleanupStack::PopAndDestroy( mailbox ); |
172 CleanupStack::PopAndDestroy( mailbox ); |
173 } |
173 } |
174 } |
174 } |
175 } |
175 } |
176 |
176 |
177 // --------------------------------------------------------- |
177 // --------------------------------------------------------- |
337 // --------------------------------------------------------- |
338 // --------------------------------------------------------- |
338 // |
339 // |
339 void CMailCpsHandler::UpdateMailboxesL(TInt aInstance, const TDesC& aContentId) |
340 void CMailCpsHandler::UpdateMailboxesL(TInt aInstance, const TDesC& aContentId) |
340 { |
341 { |
341 FUNC_LOG; |
342 FUNC_LOG; |
342 TInt row(1); // start from first row |
343 // Look up 3rd party plugin that handles this account |
343 TInt mailbox(0); |
344 CMailPluginProxy* plugin = GetExtPluginL( aContentId ); |
344 TBool found( EFalse ); |
345 if ( plugin ) // handle external 3rd party accounts |
345 // try to find mailbox with matching contentId |
346 { |
346 for ( mailbox = 0; mailbox < iAccountsArray.Count(); mailbox++ ) |
347 // Publish its data |
347 { |
348 plugin->UpdateAccountL( aContentId ); |
348 if ( !aContentId.Compare( *iAccountsArray[mailbox]->iWidgetInstance ) ) |
349 } |
349 { |
350 else // handle internal accounts |
350 INFO_1("iAccountsArray.Count() == %d", iAccountsArray.Count()); |
351 { |
351 found = ETrue; |
352 TInt row(1); // start from first row |
352 break; |
353 TInt mailbox(0); |
353 } |
354 TBool found( EFalse ); |
354 } |
355 // try to find mailbox with matching contentId |
355 |
356 for ( mailbox = 0; mailbox < iAccountsArray.Count(); mailbox++ ) |
356 // if contentId found from array, update the mailbox |
357 { |
357 if ( found ) |
358 if ( !aContentId.Compare( *iAccountsArray[mailbox]->iWidgetInstance ) ) |
358 { |
359 { |
359 // Update fields from left to right |
360 INFO_1("iAccountsArray.Count() == %d", iAccountsArray.Count()); |
360 UpdateMailBoxIconL( mailbox, aInstance, row ); |
361 found = ETrue; |
361 UpdateMailboxNameL( mailbox, aInstance, row ); |
362 break; |
362 UpdateIndicatorIconL( mailbox, aInstance, row ); |
363 } |
363 row++; |
364 } |
364 UpdateMessagesL( mailbox, aInstance, 1, row); |
365 |
365 row++; |
366 // if contentId found from array, update the mailbox |
366 UpdateMessagesL( mailbox, aInstance, 2, row); |
367 if ( found ) |
|
368 { |
|
369 // Update fields from left to right |
|
370 UpdateMailBoxIconL( mailbox, aInstance, row ); |
|
371 UpdateMailboxNameL( mailbox, aInstance, row ); |
|
372 UpdateIndicatorIconL( mailbox, aInstance, row ); |
|
373 row++; |
|
374 UpdateMessagesL( mailbox, aInstance, 1, row); |
|
375 row++; |
|
376 UpdateMessagesL( mailbox, aInstance, 2, row); |
|
377 } |
|
378 else |
|
379 { |
|
380 // Clean mailbox name |
|
381 iLiwIf->PublishActiveMailboxNameL( aInstance, 1, KNullDesC ); |
|
382 // Clean mailbox icon |
|
383 TFSMailMsgId mailBoxId; // id not essential here |
|
384 iLiwIf->PublishMailboxIconL( aInstance, 1, KNullIcon, mailBoxId); |
|
385 // Clean indicator icon |
|
386 iLiwIf->PublishIndicatorIconL( aInstance, 1, KNullIcon); |
|
387 // Clean message rows |
|
388 UpdateEmptyMessagesL( aInstance, 2 ); |
|
389 UpdateEmptyMessagesL( aInstance, 3 ); |
|
390 } |
367 } |
391 } |
368 } |
392 } |
369 |
393 |
370 // --------------------------------------------------------- |
394 // --------------------------------------------------------- |
371 // CMailCpsHandler::UpdateMailboxNameL |
395 // CMailCpsHandler::UpdateMailboxNameL |
382 if ( aMailBoxNumber < iAccountsArray.Count() ) |
406 if ( aMailBoxNumber < iAccountsArray.Count() ) |
383 { |
407 { |
384 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
408 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
385 CFSMailBox* mailbox( NULL ); |
409 CFSMailBox* mailbox( NULL ); |
386 mailbox = MailClient().GetMailBoxByUidL( mailBoxId ); |
410 mailbox = MailClient().GetMailBoxByUidL( mailBoxId ); |
387 |
411 |
388 if(mailbox) |
412 if(mailbox) |
389 { |
413 { |
390 mailBoxFound = ETrue; |
414 mailBoxFound = ETrue; |
391 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) ); |
415 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) ); |
392 delete mailbox; |
416 delete mailbox; |
393 |
417 |
394 TBuf<KMaxDescLen> accountName; |
418 TBuf<KMaxDescLen> accountName; |
395 accountName.Append(*iAccountsArray[aMailBoxNumber]->iMailboxName); |
419 accountName.Append(*iAccountsArray[aMailBoxNumber]->iMailboxName); |
396 |
420 |
397 TInt unreadCount(GetUnreadCountL(iAccountsArray[aMailBoxNumber]->iMailboxId)); |
421 TInt unreadCount(GetUnreadCountL(iAccountsArray[aMailBoxNumber]->iMailboxId)); |
398 if ( unreadCount > 0 ) |
422 if ( unreadCount > 0 ) |
399 { |
423 { |
400 // Use localisation format when displaying also unread messages |
424 // Use localisation format when displaying also unread messages |
401 |
425 |
402 // Arrays must be used when loc string contains indexed parameters |
426 // Arrays must be used when loc string contains indexed parameters |
403 CDesCArrayFlat* strings = new CDesCArrayFlat( 1 ); |
427 CDesCArrayFlat* strings = new CDesCArrayFlat( 1 ); |
404 CleanupStack::PushL( strings ); |
428 CleanupStack::PushL( strings ); |
405 strings->AppendL( accountName ); // replace "%0U" with mailbox name |
429 strings->AppendL( accountName ); // replace "%0U" with mailbox name |
406 |
430 |
407 CArrayFix<TInt>* ints = new(ELeave) CArrayFixFlat<TInt>( 1 ); |
431 CArrayFix<TInt>* ints = new(ELeave) CArrayFixFlat<TInt>( 1 ); |
408 CleanupStack::PushL( ints ); |
432 CleanupStack::PushL( ints ); |
409 ints->AppendL( unreadCount ); // replace "%1N" with number of unread messages |
433 ints->AppendL( unreadCount ); // replace "%1N" with number of unread messages |
410 |
434 |
411 HBufC* mailboxAndCount = StringLoader::LoadLC( R_EMAILWIDGET_TEXT_MAILBOX_AND_MAILCOUNT, |
435 HBufC* mailboxAndCount = StringLoader::LoadLC( R_EMAILWIDGET_TEXT_MAILBOX_AND_MAILCOUNT, |
412 *strings, |
436 *strings, |
413 *ints ); |
437 *ints ); |
414 |
438 |
415 iLiwIf->PublishActiveMailboxNameL( |
439 iLiwIf->PublishActiveMailboxNameL( |
416 aWidgetInstance, |
440 aWidgetInstance, |
417 aRowNumber, *mailboxAndCount, |
441 aRowNumber, *mailboxAndCount); |
418 iAccountsArray.Count(), |
442 |
419 mailBoxId, folderId); |
|
420 |
|
421 CleanupStack::PopAndDestroy(mailboxAndCount); |
443 CleanupStack::PopAndDestroy(mailboxAndCount); |
422 CleanupStack::PopAndDestroy(ints); |
444 CleanupStack::PopAndDestroy(ints); |
423 CleanupStack::PopAndDestroy(strings); |
445 CleanupStack::PopAndDestroy(strings); |
424 } |
446 } |
425 else |
447 else |
426 { |
448 { |
427 // show only mailbox name |
449 // show only mailbox name |
428 |
450 |
429 iLiwIf->PublishActiveMailboxNameL( |
451 iLiwIf->PublishActiveMailboxNameL( |
430 aWidgetInstance, |
452 aWidgetInstance, |
431 aRowNumber, accountName, |
453 aRowNumber, accountName); |
432 iAccountsArray.Count(), |
|
433 mailBoxId, folderId); |
|
434 } |
454 } |
435 } |
455 } |
436 } |
456 } |
437 else if(!mailBoxFound) |
457 else if(!mailBoxFound) |
438 { |
458 { |
439 // Publishing empty descriptor for rows that should not contain |
459 // Publishing empty descriptor for rows that should not contain |
440 // anything on widget UI. |
460 // anything on widget UI. |
441 iLiwIf->PublishActiveMailboxNameL( aWidgetInstance, |
461 iLiwIf->PublishActiveMailboxNameL( aWidgetInstance, |
442 aRowNumber, |
462 aRowNumber, |
443 KNullDesC, |
463 KNullDesC); |
444 NULL, |
|
445 mailBoxId, |
|
446 folderId ); |
|
447 } |
464 } |
448 } |
465 } |
449 |
466 |
450 |
467 |
451 // --------------------------------------------------------- |
468 // --------------------------------------------------------- |
494 CleanupClosePushL( folderMessages ); |
511 CleanupClosePushL( folderMessages ); |
495 |
512 |
496 TFSMailDetails details( EFSMsgDataEnvelope ); |
513 TFSMailDetails details( EFSMsgDataEnvelope ); |
497 RArray<TFSMailSortCriteria> sorting; |
514 RArray<TFSMailSortCriteria> sorting; |
498 CleanupClosePushL( sorting ); |
515 CleanupClosePushL( sorting ); |
499 |
516 |
500 TFSMailSortCriteria sortCriteria; |
517 TFSMailSortCriteria sortCriteria; |
501 sortCriteria.iField = EFSMailSortByDate; |
518 sortCriteria.iField = EFSMailSortByDate; |
502 sortCriteria.iOrder = EFSMailDescending; |
519 sortCriteria.iOrder = EFSMailDescending; |
503 sorting.Append( sortCriteria ); |
520 sorting.Append( sortCriteria ); |
504 // List all or maximum number of messages |
521 // List all or maximum number of messages |
505 MFSMailIterator* iterator = folder->ListMessagesL( details, sorting ); |
522 MFSMailIterator* iterator = folder->ListMessagesL( details, sorting ); |
506 CleanupDeletePushL( iterator ); // standard CleanupStack::PushL does not work with non-C-class pointer |
523 CleanupDeletePushL( iterator ); // standard CleanupStack::PushL does not work with non-C-class pointer |
507 |
524 |
508 TFSMailMsgId dummy; |
525 TFSMailMsgId dummy; |
509 iterator->NextL( dummy, aMessageNumber, folderMessages); |
526 iterator->NextL( dummy, aMessageNumber, folderMessages); |
510 TInt count (folderMessages.Count()); |
527 TInt count (folderMessages.Count()); |
511 if(!count || (count == 1 && aRow == 3)) |
528 if(!count || (count == 1 && aRow == 3)) |
512 { |
529 { |
513 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
530 UpdateEmptyMessagesL( aWidgetInstance, aRow ); |
514 |
531 |
515 CleanupStack::PopAndDestroy( iterator ); |
532 CleanupStack::PopAndDestroy( iterator ); |
516 CleanupStack::PopAndDestroy( &sorting ); |
533 CleanupStack::PopAndDestroy( &sorting ); |
517 CleanupStack::PopAndDestroy( &folderMessages ); |
534 CleanupStack::PopAndDestroy( &folderMessages ); |
518 CleanupStack::PopAndDestroy( folder ); |
535 CleanupStack::PopAndDestroy( folder ); |
519 |
536 |
537 else |
556 else |
538 { |
557 { |
539 sender.Append(fromAddress->GetEmailAddress()); |
558 sender.Append(fromAddress->GetEmailAddress()); |
540 } |
559 } |
541 } |
560 } |
542 |
561 |
543 // Get message time and format it correctly |
562 // Get message time and format it correctly |
544 TTime msgTime = msg->GetDate(); |
563 TTime msgTime = msg->GetDate(); |
545 HBufC* timeString( NULL ); |
564 HBufC* timeString( NULL ); |
546 timeString = GetMessageTimeStringL( msgTime ); |
565 timeString = GetMessageTimeStringL( msgTime ); |
547 CleanupDeletePushL( timeString ); |
566 CleanupDeletePushL( timeString ); |
548 |
567 |
549 // Publish message details |
568 // Publish message details |
550 PublishMessageL( aWidgetInstance, |
569 PublishMessageL( aWidgetInstance, |
551 *msg, |
570 *msg, |
552 sender, |
571 sender, |
|
572 subject, |
553 *timeString, |
573 *timeString, |
554 aRow ); |
574 aRow ); |
555 |
575 |
556 CleanupStack::PopAndDestroy( timeString ); |
576 CleanupStack::PopAndDestroy( timeString ); |
557 CleanupStack::PopAndDestroy( msg ); |
577 CleanupStack::PopAndDestroy( msg ); |
558 CleanupStack::PopAndDestroy( iterator ); |
578 CleanupStack::PopAndDestroy( iterator ); |
559 CleanupStack::PopAndDestroy( &sorting ); |
579 CleanupStack::PopAndDestroy( &sorting ); |
560 CleanupStack::PopAndDestroy( &folderMessages ); |
580 CleanupStack::PopAndDestroy( &folderMessages ); |
573 FUNC_LOG; |
593 FUNC_LOG; |
574 |
594 |
575 // Get current local time |
595 // Get current local time |
576 TTime currentTime; |
596 TTime currentTime; |
577 currentTime.HomeTime(); |
597 currentTime.HomeTime(); |
578 |
598 |
579 // Get universal time offset and add it to message time |
599 // Get universal time offset and add it to message time |
580 TLocale locale; |
600 TLocale locale; |
581 TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() ); |
601 TTimeIntervalSeconds universalTimeOffset( locale.UniversalTimeOffset() ); |
582 aMessageTime += universalTimeOffset; |
602 aMessageTime += universalTimeOffset; |
583 |
603 |
584 // If daylight saving is on, add one hour offset to message time |
604 // If daylight saving is on, add one hour offset to message time |
585 if ( locale.QueryHomeHasDaylightSavingOn() ) |
605 if ( locale.QueryHomeHasDaylightSavingOn() ) |
586 { |
606 { |
587 TTimeIntervalHours daylightSaving( 1 ); |
607 TTimeIntervalHours daylightSaving( 1 ); |
588 aMessageTime += daylightSaving; |
608 aMessageTime += daylightSaving; |
589 } |
609 } |
590 |
610 |
591 // Get datetime objects and compare dates |
611 // Get datetime objects and compare dates |
592 TDateTime currentDate = currentTime.DateTime(); |
612 TDateTime currentDate = currentTime.DateTime(); |
593 TDateTime messageDate = aMessageTime.DateTime(); |
613 TDateTime messageDate = aMessageTime.DateTime(); |
594 HBufC* formatString( NULL ); |
614 HBufC* formatString( NULL ); |
595 |
615 |
596 if ( currentDate.Year() == messageDate.Year() |
616 if ( currentDate.Year() == messageDate.Year() |
597 && currentDate.Month() == messageDate.Month() |
617 && currentDate.Month() == messageDate.Month() |
598 && currentDate.Day() == messageDate.Day()) |
618 && currentDate.Day() == messageDate.Day()) |
599 { |
619 { |
600 // Message arrived today |
620 // Message arrived today |
601 formatString = StringLoader::LoadLC( R_QTN_TIME_USUAL_WITH_ZERO ); |
621 formatString = StringLoader::LoadLC( R_QTN_TIME_USUAL_WITH_ZERO ); |
602 } |
622 } |
603 else |
623 else |
604 { |
624 { |
605 // Message arrived earlier than today |
625 // Message arrived earlier than today |
606 formatString = StringLoader::LoadLC( R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO ); |
626 formatString = StringLoader::LoadLC( R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO ); |
607 } |
627 } |
608 |
628 |
609 // Format time string using chosen time or date formatString |
629 // Format time string using chosen time or date formatString |
610 TBuf<KMaxShortDateFormatSpec*2> timeString; |
630 TBuf<KMaxShortDateFormatSpec*2> timeString; |
611 TRAP_IGNORE( aMessageTime.FormatL( timeString, formatString->Des() ) ); |
631 TRAP_IGNORE( aMessageTime.FormatL( timeString, formatString->Des() ) ); |
612 CleanupStack::PopAndDestroy( formatString ); |
632 CleanupStack::PopAndDestroy( formatString ); |
613 // If format fails, result is empty |
633 // If format fails, result is empty |
614 |
634 |
615 HBufC* result = timeString.Alloc(); |
635 HBufC* result = timeString.Alloc(); |
616 TPtr ptr = result->Des(); |
636 TPtr ptr = result->Des(); |
617 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
637 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr ); |
618 return result; |
638 return result; |
619 } |
639 } |
623 // CMailCpsHandler::PublishMessageL |
643 // CMailCpsHandler::PublishMessageL |
624 // |
644 // |
625 // --------------------------------------------------------- |
645 // --------------------------------------------------------- |
626 // |
646 // |
627 void CMailCpsHandler::PublishMessageL( TInt aWidgetInstance, CFSMailMessage& aMessage, |
647 void CMailCpsHandler::PublishMessageL( TInt aWidgetInstance, CFSMailMessage& aMessage, |
628 const TDesC& aSenderName, const TDesC& aTime, TInt aRow ) |
648 const TDesC& aSenderName, const TDesC& aSubject, |
|
649 const TDesC& aTime, TInt aRow ) |
629 { |
650 { |
630 FUNC_LOG; |
651 FUNC_LOG; |
631 |
652 |
632 TFSMailMsgId msgId( aMessage.GetMessageId() ); |
653 TFSMailMsgId msgId( aMessage.GetMessageId() ); |
633 |
654 |
634 iLiwIf->PublishMailboxIconL( aWidgetInstance, aRow, GetMailIcon( &aMessage ), msgId ); |
655 iLiwIf->PublishMailboxIconL( aWidgetInstance, aRow, GetMailIcon( &aMessage ), msgId ); |
635 iLiwIf->PublishMailDetailL( aWidgetInstance, aRow, aSenderName, ESender ); |
656 iLiwIf->PublishMailDetailL( aWidgetInstance, aRow, aSenderName, ESender ); |
|
657 iLiwIf->PublishMailDetailL( aWidgetInstance, aRow, aSubject, ESubject ); |
636 iLiwIf->PublishMailDetailL( aWidgetInstance, aRow, aTime, ETime ); |
658 iLiwIf->PublishMailDetailL( aWidgetInstance, aRow, aTime, ETime ); |
637 } |
659 } |
638 |
660 |
639 // --------------------------------------------------------- |
661 // --------------------------------------------------------- |
640 // CMailCpsHandler::UpdateEmptyMessagesL |
662 // CMailCpsHandler::UpdateEmptyMessagesL |
642 // --------------------------------------------------------- |
664 // --------------------------------------------------------- |
643 // |
665 // |
644 void CMailCpsHandler::UpdateEmptyMessagesL( const TInt aWidgetInstance, |
666 void CMailCpsHandler::UpdateEmptyMessagesL( const TInt aWidgetInstance, |
645 const TInt aRow ) |
667 const TInt aRow ) |
646 { |
668 { |
647 FUNC_LOG; |
669 FUNC_LOG; |
648 |
670 |
649 TFSMailMsgId mailBoxId; // id not essential here |
671 TFSMailMsgId mailBoxId; // id not essential here |
650 |
672 |
651 iLiwIf->PublishMailDetailL( |
673 iLiwIf->PublishMailDetailL( |
652 aWidgetInstance, |
674 aWidgetInstance, |
653 aRow, |
675 aRow, |
654 KNullDes, |
676 KNullDes, |
655 ESender); |
677 ESender); |
656 |
678 |
|
679 iLiwIf->PublishMailDetailL( |
|
680 aWidgetInstance, |
|
681 aRow, |
|
682 KNullDes, |
|
683 ESubject); |
|
684 |
657 iLiwIf->PublishMailboxIconL( |
685 iLiwIf->PublishMailboxIconL( |
658 aWidgetInstance, |
686 aWidgetInstance, |
659 aRow, |
687 aRow, |
660 KNullIcon, |
688 KNullIcon, |
661 mailBoxId); |
689 mailBoxId); |
662 |
690 |
663 iLiwIf->PublishMailDetailL( |
691 iLiwIf->PublishMailDetailL( |
664 aWidgetInstance, |
692 aWidgetInstance, |
665 aRow, |
693 aRow, |
666 KNullDes, |
694 KNullDes, |
667 ETime); |
695 ETime); |
668 } |
696 } |
669 /* |
697 |
670 // --------------------------------------------------------- |
|
671 // CMailCpsHandler::UpdateConnectStateL |
|
672 // --------------------------------------------------------- |
|
673 // |
|
674 void CMailCpsHandler::UpdateConnectStateL( const TInt aMailBoxNumber, const TInt aRowNumber ) |
|
675 { |
|
676 FUNC_LOG; |
|
677 if ( aMailBoxNumber < iAccountsArray.Count() ) |
|
678 { |
|
679 TFSMailMsgId mailBoxId; |
|
680 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
|
681 CFSMailBox* mailbox( NULL ); |
|
682 mailbox = MailClient().GetMailBoxByUidL( mailBoxId ); |
|
683 if(mailbox) |
|
684 { |
|
685 iLiwIf->PublishConnectIconL(mailbox->GetMailBoxStatus(), aRowNumber); |
|
686 } |
|
687 } |
|
688 else |
|
689 { |
|
690 iLiwIf->PublishConnectIconL( EFSMailBoxOffline, aRowNumber ); |
|
691 } |
|
692 } |
|
693 */ |
|
694 // --------------------------------------------------------- |
698 // --------------------------------------------------------- |
695 // CMailCpsHandler::UpdateMailBoxIconL |
699 // CMailCpsHandler::UpdateMailBoxIconL |
696 // --------------------------------------------------------- |
700 // --------------------------------------------------------- |
697 // |
701 // |
698 void CMailCpsHandler::UpdateMailBoxIconL( const TInt aMailBoxNumber, |
702 void CMailCpsHandler::UpdateMailBoxIconL( const TInt aMailBoxNumber, |
699 const TInt aWidgetInstance, |
703 const TInt aWidgetInstance, |
700 const TInt aRowNumber ) |
704 const TInt aRowNumber ) |
701 { |
705 { |
702 FUNC_LOG; |
706 FUNC_LOG; |
703 |
707 |
704 TFSMailMsgId mailBoxId; // id required only for getting branded mailbox icon |
708 TFSMailMsgId mailBoxId; // id required only for getting branded mailbox icon |
705 |
709 |
706 if ( aMailBoxNumber < iAccountsArray.Count() ) |
710 if ( aMailBoxNumber < iAccountsArray.Count() ) |
707 { |
711 { |
708 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
712 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
709 iLiwIf->PublishMailboxIconL( aWidgetInstance, |
713 iLiwIf->PublishMailboxIconL( aWidgetInstance, |
710 aRowNumber, |
714 aRowNumber, |
711 EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account, |
715 EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account, |
712 mailBoxId); |
716 mailBoxId); |
713 } |
717 } |
714 else |
718 else |
715 { |
719 { |
716 iLiwIf->PublishMailboxIconL( aWidgetInstance, aRowNumber, KNullIcon, mailBoxId); |
720 iLiwIf->PublishMailboxIconL( aWidgetInstance, aRowNumber, KNullIcon, mailBoxId); |
717 } |
721 } |
718 } |
722 } |
719 |
723 |
720 // --------------------------------------------------------- |
724 // --------------------------------------------------------- |
721 // CMailCpsHandler::UpdateIndicatorIconL |
725 // CMailCpsHandler::UpdateIndicatorIconL |
722 // --------------------------------------------------------- |
726 // --------------------------------------------------------- |
723 // |
727 // |
724 void CMailCpsHandler::UpdateIndicatorIconL( const TInt aMailBoxNumber, |
728 void CMailCpsHandler::UpdateIndicatorIconL( const TInt aMailBoxNumber, |
725 const TInt aWidgetInstance, |
729 const TInt aWidgetInstance, |
726 const TInt aRowNumber ) |
730 const TInt aRowNumber ) |
727 |
731 |
728 { |
732 { |
729 FUNC_LOG; |
733 FUNC_LOG; |
730 |
734 |
731 if ( aMailBoxNumber < iAccountsArray.Count() ) |
735 if ( aMailBoxNumber < iAccountsArray.Count() ) |
732 { |
736 { |
733 TFSMailMsgId mailBoxId; |
737 TFSMailMsgId mailBoxId; |
734 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
738 mailBoxId = iAccountsArray[aMailBoxNumber]->iMailboxId; |
735 |
739 |
736 if ( iSettings->GetNewMailState( mailBoxId ) ) |
740 if ( iSettings->GetNewMailState( mailBoxId ) ) |
737 { |
741 { |
738 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
742 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
739 aRowNumber, |
743 aRowNumber, |
740 EMbmCmailhandlerpluginQgn_stat_message_mail_uni ); |
744 EMbmCmailhandlerpluginQgn_stat_message_mail_uni ); |
741 } |
745 } |
742 |
746 |
743 else if( !IsOutboxEmptyL(mailBoxId) ) |
747 else if( !IsOutboxEmptyL(mailBoxId) ) |
744 { |
748 { |
745 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
749 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
746 aRowNumber, |
750 aRowNumber, |
747 EMbmCmailhandlerpluginQgn_indi_cmail_outbox_msg); |
751 EMbmCmailhandlerpluginQgn_indi_cmail_outbox_msg); |
748 } |
752 } |
749 else |
753 else |
750 { |
754 { |
751 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
755 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
752 aRowNumber, |
756 aRowNumber, |
753 KNullIcon); |
757 KNullIcon); |
754 } |
758 } |
755 } |
759 } |
756 else |
760 else |
757 { |
761 { |
758 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
762 iLiwIf->PublishIndicatorIconL( aWidgetInstance, |
759 aRowNumber, |
763 aRowNumber, |
760 KNullIcon); |
764 KNullIcon); |
761 } |
765 } |
762 } |
766 } |
763 |
|
764 /* |
|
765 // --------------------------------------------------------- |
|
766 // CMailCpsHandler::ClearMessageTimeL |
|
767 // --------------------------------------------------------- |
|
768 // |
|
769 void CMailCpsHandler::ClearMessageTimeL( const TInt aRowNumber ) |
|
770 { |
|
771 FUNC_LOG; |
|
772 |
|
773 iLiwIf->PublishMailDetailL( |
|
774 aRowNumber, |
|
775 KNullDes, |
|
776 ETime); |
|
777 } |
|
778 */ |
|
779 |
767 |
780 // --------------------------------------------------------- |
768 // --------------------------------------------------------- |
781 // CMailCpsHandler::CapabilitiesToContinueL |
769 // CMailCpsHandler::CapabilitiesToContinueL |
782 // --------------------------------------------------------- |
770 // --------------------------------------------------------- |
783 // |
771 // |
861 { |
843 { |
862 HandleMailDeletedEventL( aMailbox, aParam1, aParam2 ); |
844 HandleMailDeletedEventL( aMailbox, aParam1, aParam2 ); |
863 UpdateFullL(); |
845 UpdateFullL(); |
864 break; |
846 break; |
865 } |
847 } |
866 case TFSEventMailChanged: |
848 default: |
867 { |
849 { |
868 HandleMailChangedEventL( aMailbox, aParam1, aParam2 ); |
|
869 break; |
850 break; |
870 } |
851 } |
871 case TFSEventNewFolder: |
|
872 { |
|
873 HandleNewFolderEventL( aMailbox, aParam1, aParam2 ); |
|
874 break; |
|
875 } |
|
876 default: |
|
877 { |
|
878 break; |
|
879 } |
|
880 } |
852 } |
881 } |
853 } |
882 |
854 |
883 // --------------------------------------------------------- |
855 // --------------------------------------------------------- |
884 // CMailCpsHandler::HandleNewMailboxEventL |
856 // CMailCpsHandler::HandleNewMailboxEventL |
885 // --------------------------------------------------------- |
857 // --------------------------------------------------------- |
886 // |
858 // |
887 void CMailCpsHandler::HandleNewMailboxEventL( const TFSMailMsgId aMailbox ) |
859 void CMailCpsHandler::HandleNewMailboxEventL( const TFSMailMsgId aMailbox ) |
888 { |
860 { |
889 FUNC_LOG; |
861 FUNC_LOG; |
890 |
862 if (iWaitingForNewMailbox) |
891 // Check that max mailbox count is not already reached |
863 { |
892 const TInt iiMax( iAccountsArray.Count() ); |
864 iSettings->AssociateWidgetToSetting( iWaitingForNewMailbox->Des(), aMailbox ); |
893 if( iiMax >= iSettings->MaxMailboxCount() ) |
865 } |
894 { |
|
895 return; |
|
896 } |
|
897 |
|
898 // Check that mailbox is not already in widget |
|
899 for ( TInt ii = 0; ii < iiMax; ii++ ) |
|
900 { |
|
901 if( iAccountsArray[ii]->iMailboxId.Id() == aMailbox.Id() ) |
|
902 { |
|
903 return; |
|
904 } |
|
905 } |
|
906 |
|
907 CFSMailBox* mailbox( NULL ); |
|
908 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
|
909 if ( !mailbox ) |
|
910 { |
|
911 return; // nothing that could be done |
|
912 } |
|
913 else |
|
914 { |
|
915 CleanupStack::PushL( mailbox ); |
|
916 CMailMailboxDetails* mailboxDetails = CreateMailboxDetailsL( *mailbox ); |
|
917 CleanupStack::PushL( mailboxDetails ); |
|
918 iAccountsArray.AppendL( mailboxDetails ); |
|
919 CleanupStack::Pop( mailboxDetails ); |
|
920 CleanupStack::PopAndDestroy( mailbox ); |
|
921 } |
|
922 |
|
923 iSettings->AddMailboxL( aMailbox ); |
|
924 } |
866 } |
925 |
867 |
926 // --------------------------------------------------------- |
868 // --------------------------------------------------------- |
927 // CMailCpsHandler::HandleMailboxRenamedEventL |
869 // CMailCpsHandler::HandleMailboxRenamedEventL |
928 // --------------------------------------------------------- |
870 // --------------------------------------------------------- |
1127 |
1069 |
1128 CleanupStack::PopAndDestroy( entries ); |
1070 CleanupStack::PopAndDestroy( entries ); |
1129 } |
1071 } |
1130 |
1072 |
1131 // --------------------------------------------------------- |
1073 // --------------------------------------------------------- |
1132 // CMailCpsHandler::HandleMailChangedEventL |
|
1133 // --------------------------------------------------------- |
|
1134 // |
|
1135 void CMailCpsHandler::HandleMailChangedEventL( |
|
1136 TFSMailMsgId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/ ) |
|
1137 { |
|
1138 FUNC_LOG; |
|
1139 } |
|
1140 |
|
1141 // --------------------------------------------------------- |
|
1142 // CMailCpsHandler::HandleNewFolderEventL |
|
1143 // --------------------------------------------------------- |
|
1144 // |
|
1145 void CMailCpsHandler::HandleNewFolderEventL( |
|
1146 TFSMailMsgId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/ ) |
|
1147 { |
|
1148 FUNC_LOG; |
|
1149 } |
|
1150 |
|
1151 // --------------------------------------------------------- |
|
1152 // CMailCpsHandler::GetUnreadCountL |
1074 // CMailCpsHandler::GetUnreadCountL |
1153 // --------------------------------------------------------- |
1075 // --------------------------------------------------------- |
1154 // |
1076 // |
1155 TInt CMailCpsHandler::GetUnreadCountL(TFSMailMsgId aMailbox) |
1077 TInt CMailCpsHandler::GetUnreadCountL(TFSMailMsgId aMailbox) |
1156 { |
1078 { |
1157 FUNC_LOG; |
1079 FUNC_LOG; |
1158 CFSMailBox* mailbox( NULL ); |
1080 CFSMailBox* mailbox( NULL ); |
1159 TInt unread (0); |
1081 TInt unread (0); |
1160 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
1082 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
1161 if(mailbox) |
1083 if(mailbox) |
1162 { |
1084 { |
1163 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) ); |
1085 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) ); |
1164 // Check that folder is correct |
1086 // Check that folder is correct |
1165 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId ); |
1087 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId ); |
1166 if ( !folder ) |
1088 if ( !folder ) |
1167 { |
1089 { |
1168 return KErrNotFound; |
1090 return KErrNotFound; |
1169 } |
1091 } |
1170 CleanupStack::PushL( folder ); |
1092 CleanupStack::PushL( folder ); |
1171 |
1093 |
1172 unread = folder->GetUnreadCount(); |
1094 unread = folder->GetUnreadCount(); |
1173 |
1095 |
1174 CleanupStack::PopAndDestroy( folder ); |
1096 CleanupStack::PopAndDestroy( folder ); |
1175 |
1097 |
1176 if (unread > KMaxUnreadCount) |
1098 if (unread > KMaxUnreadCount) |
1177 { |
1099 { |
1178 unread = KMaxUnreadCount; |
1100 unread = KMaxUnreadCount; |
1179 } |
1101 } |
1180 } |
1102 } |
1191 FUNC_LOG; |
1113 FUNC_LOG; |
1192 CFSMailBox* mailbox( NULL ); |
1114 CFSMailBox* mailbox( NULL ); |
1193 TInt unseen (0); |
1115 TInt unseen (0); |
1194 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
1116 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
1195 if(mailbox) |
1117 if(mailbox) |
1196 { |
1118 { |
1197 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) ); |
1119 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSInbox ) ); |
1198 // Check that folder is correct |
1120 // Check that folder is correct |
1199 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId ); |
1121 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId ); |
1200 if ( !folder ) |
1122 if ( !folder ) |
1201 { |
1123 { |
1202 return KErrNotFound; |
1124 return KErrNotFound; |
1203 } |
1125 } |
1204 CleanupStack::PushL( folder ); |
1126 CleanupStack::PushL( folder ); |
1205 |
1127 |
1206 unseen = folder->GetUnseenCount(); |
1128 unseen = folder->GetUnseenCount(); |
1207 |
1129 |
1208 CleanupStack::PopAndDestroy( folder ); |
1130 CleanupStack::PopAndDestroy( folder ); |
1209 |
1131 |
1210 if (unseen > KMaxUnreadCount) |
1132 if (unseen > KMaxUnreadCount) |
1211 { |
1133 { |
1212 unseen = KMaxUnreadCount; |
1134 unseen = KMaxUnreadCount; |
1213 } |
1135 } |
1214 } |
1136 } |
1226 CFSMailBox* mailbox( NULL ); |
1148 CFSMailBox* mailbox( NULL ); |
1227 TBool ret(ETrue); |
1149 TBool ret(ETrue); |
1228 TInt msgCount(0); |
1150 TInt msgCount(0); |
1229 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
1151 mailbox = MailClient().GetMailBoxByUidL( aMailbox ); |
1230 if(mailbox) |
1152 if(mailbox) |
1231 { |
1153 { |
1232 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSOutbox ) ); |
1154 TFSMailMsgId folderId( mailbox->GetStandardFolderId( EFSOutbox ) ); |
1233 // Check that folder is correct |
1155 // Check that folder is correct |
1234 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId ); |
1156 CFSMailFolder* folder = MailClient().GetFolderByUidL( aMailbox, folderId ); |
1235 if ( !folder ) |
1157 if ( !folder ) |
1236 { |
1158 { |
1237 return KErrNotFound; |
1159 return KErrNotFound; |
1238 } |
1160 } |
1239 CleanupStack::PushL( folder ); |
1161 CleanupStack::PushL( folder ); |
1240 |
1162 |
1241 msgCount = folder->GetMessageCount(); |
1163 msgCount = folder->GetMessageCount(); |
1242 |
1164 |
1243 if ( msgCount<1 ) |
1165 if ( msgCount<1 ) |
1244 { |
1166 { |
1245 CleanupStack::PopAndDestroy( folder ); |
1167 CleanupStack::PopAndDestroy( folder ); |
1246 return ret; |
1168 return ret; |
1247 } |
1169 } |
1248 |
1170 |
1249 TFSMailDetails details( EFSMsgDataEnvelope ); |
1171 TFSMailDetails details( EFSMsgDataEnvelope ); |
1250 RArray<TFSMailSortCriteria> sorting; |
1172 RArray<TFSMailSortCriteria> sorting; |
1251 CleanupClosePushL( sorting ); |
1173 CleanupClosePushL( sorting ); |
1252 TFSMailSortCriteria sortCriteria; |
1174 TFSMailSortCriteria sortCriteria; |
1253 sortCriteria.iField = EFSMailDontCare; |
1175 sortCriteria.iField = EFSMailDontCare; |
1254 sortCriteria.iOrder = EFSMailDescending; |
1176 sortCriteria.iOrder = EFSMailDescending; |
1255 sorting.Append( sortCriteria ); |
1177 sorting.Append( sortCriteria ); |
1256 // List all or maximum number of messages |
1178 // List all or maximum number of messages |
1257 MFSMailIterator* iterator = folder->ListMessagesL( details, sorting ); |
1179 MFSMailIterator* iterator = folder->ListMessagesL( details, sorting ); |
1258 CleanupStack::PopAndDestroy( &sorting ); |
1180 CleanupStack::PopAndDestroy( &sorting ); |
1259 CleanupDeletePushL( iterator ); |
1181 CleanupDeletePushL( iterator ); |
1260 |
1182 |
1261 RPointerArray<CFSMailMessage> messages; |
1183 RPointerArray<CFSMailMessage> messages; |
1262 CleanupClosePushL( messages ); |
1184 CleanupClosePushL( messages ); |
1263 TInt amount( msgCount ); |
1185 iterator->NextL( TFSMailMsgId(), msgCount, messages ); |
1264 iterator->NextL( TFSMailMsgId(), amount, messages ); |
1186 |
1265 |
1187 TInt arrayCount(messages.Count()); |
1266 for (TInt i = 0; i < msgCount; i++) |
1188 for (TInt i = 0; i < arrayCount; i++) |
1267 { |
1189 { |
1268 TFSMailMsgId msgId = messages[0]->GetMessageId(); |
1190 TFSMailMsgId msgId = messages[i]->GetMessageId(); |
1269 CFSMailMessage* msg( NULL ); |
1191 CFSMailMessage* msg( NULL ); |
1270 msg = MailClient().GetMessageByUidL( aMailbox, folderId, msgId, EFSMsgDataEnvelope ); |
1192 msg = MailClient().GetMessageByUidL( aMailbox, folderId, msgId, EFSMsgDataEnvelope ); |
1271 CleanupDeletePushL( msg ); |
1193 if (msg) |
1272 TFSMailMsgId mailboxId = msg->GetMailBoxId(); |
1194 { |
1273 CleanupStack::PopAndDestroy( msg ); |
1195 CleanupDeletePushL( msg ); |
1274 |
1196 TFSMailMsgId mailboxId = msg->GetMailBoxId(); |
1275 if (mailboxId == aMailbox) |
1197 CleanupStack::PopAndDestroy( msg ); |
1276 { |
1198 |
1277 ret = EFalse; |
1199 if (mailboxId == aMailbox) |
1278 break; |
1200 { |
|
1201 ret = EFalse; |
|
1202 break; |
|
1203 } |
1279 } |
1204 } |
1280 } |
1205 } |
1281 |
1206 |
1282 CleanupStack::PopAndDestroy( &messages ); |
1207 CleanupStack::PopAndDestroy( &messages ); |
1283 CleanupStack::PopAndDestroy( iterator ); |
1208 CleanupStack::PopAndDestroy( iterator ); |
1328 // ----------------------------------------------------------------------------- |
1253 // ----------------------------------------------------------------------------- |
1329 // CMailCpsHandler::GetUnreadMsgIcon |
1254 // CMailCpsHandler::GetUnreadMsgIcon |
1330 // ----------------------------------------------------------------------------- |
1255 // ----------------------------------------------------------------------------- |
1331 TInt CMailCpsHandler::GetUnreadMsgIcon( CFSMailMessage* aMsg ) |
1256 TInt CMailCpsHandler::GetUnreadMsgIcon( CFSMailMessage* aMsg ) |
1332 { |
1257 { |
1333 FUNC_LOG; |
1258 FUNC_LOG; |
1334 TInt icon(EMbmCmailhandlerpluginQgn_indi_cmail_unread); |
1259 TInt icon(EMbmCmailhandlerpluginQgn_indi_cmail_unread); |
1335 |
1260 |
1336 // Unread calendar invitation |
1261 // Unread calendar invitation |
1337 if ( aMsg->IsFlagSet( EFSMsgFlag_CalendarMsg )) |
1262 if ( aMsg->IsFlagSet( EFSMsgFlag_CalendarMsg )) |
1338 { |
1263 { |
1339 icon = GetUnreadCalMsgIcon( aMsg ); |
1264 icon = GetUnreadCalMsgIcon( aMsg ); |
1340 } |
1265 } |
1341 else // Normal message icons |
1266 else // Normal message icons |
1342 { |
1267 { |
1343 // Check whether msg has attachment or not |
1268 // Check whether msg has attachment or not |
1344 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments )) // Has attachments |
1269 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments )) // Has attachments |
1345 { |
1270 { |
1418 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded_low_prio; |
1343 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded_low_prio; |
1419 } |
1344 } |
1420 else |
1345 else |
1421 { |
1346 { |
1422 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_low_prio; |
1347 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_low_prio; |
1423 } |
1348 } |
1424 } |
1349 } |
1425 else // Normal priority, no attachments |
1350 else // Normal priority, no attachments |
1426 { |
1351 { |
1427 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
1352 if ( aMsg->IsFlagSet( EFSMsgFlag_Answered ) ) |
1428 { |
1353 { |
1429 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_replied; |
1354 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_replied; |
1430 } |
1355 } |
1431 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
1356 else if ( aMsg->IsFlagSet( EFSMsgFlag_Forwarded ) ) |
1432 { |
1357 { |
1433 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded; |
1358 icon = EMbmCmailhandlerpluginQgn_indi_cmail_unread_forwarded; |
1434 } |
1359 } |
1435 } |
1360 } |
1436 } |
1361 } |
1437 } |
1362 } |
1438 return icon; |
1363 return icon; |
1439 } |
1364 } |
1440 |
1365 |
1441 // ----------------------------------------------------------------------------- |
1366 // ----------------------------------------------------------------------------- |
1442 // CMailCpsHandler::GetReadMsgIcon |
1367 // CMailCpsHandler::GetReadMsgIcon |
1443 // ----------------------------------------------------------------------------- |
1368 // ----------------------------------------------------------------------------- |
1444 TInt CMailCpsHandler::GetReadMsgIcon( CFSMailMessage* aMsg ) |
1369 TInt CMailCpsHandler::GetReadMsgIcon( CFSMailMessage* aMsg ) |
1445 { |
1370 { |
1446 FUNC_LOG; |
1371 FUNC_LOG; |
1447 TInt icon(EMbmCmailhandlerpluginQgn_indi_cmail_read); |
1372 TInt icon(EMbmCmailhandlerpluginQgn_indi_cmail_read); |
1448 |
1373 |
1449 if ( aMsg->IsFlagSet( EFSMsgFlag_CalendarMsg )) |
1374 if ( aMsg->IsFlagSet( EFSMsgFlag_CalendarMsg )) |
1450 { |
1375 { |
1451 icon = GetReadCalMsgIcon( aMsg ); |
1376 icon = GetReadCalMsgIcon( aMsg ); |
1552 // ----------------------------------------------------------------------------- |
1477 // ----------------------------------------------------------------------------- |
1553 // CMailCpsHandler::GetUnreadCalMsgIcon |
1478 // CMailCpsHandler::GetUnreadCalMsgIcon |
1554 // ----------------------------------------------------------------------------- |
1479 // ----------------------------------------------------------------------------- |
1555 TInt CMailCpsHandler::GetUnreadCalMsgIcon( CFSMailMessage* aMsg ) |
1480 TInt CMailCpsHandler::GetUnreadCalMsgIcon( CFSMailMessage* aMsg ) |
1556 { |
1481 { |
1557 FUNC_LOG; |
1482 FUNC_LOG; |
1558 TInt icon(0); |
1483 TInt icon(0); |
1559 |
1484 |
1560 if ( aMsg->IsFlagSet( EFSMsgFlag_Important ) ) |
1485 if ( aMsg->IsFlagSet( EFSMsgFlag_Important ) ) |
1561 { |
1486 { |
1562 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1487 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1563 { |
1488 { |
1564 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_attachments_high_prio ; |
1489 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_attachments_high_prio ; |
1565 } |
1490 } |
1566 else |
1491 else |
1567 { |
1492 { |
1568 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_high_prio; |
1493 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_high_prio; |
1569 } |
1494 } |
1570 } |
1495 } |
1571 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) |
1496 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) |
1572 { |
1497 { |
1573 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1498 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1574 { |
1499 { |
1575 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_attachments_low_prio; |
1500 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_attachments_low_prio; |
1576 } |
1501 } |
1577 else |
1502 else |
1578 { |
1503 { |
1579 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_low_prio; |
1504 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_low_prio; |
1580 } |
1505 } |
1581 } |
1506 } |
1582 else |
1507 else |
1583 { |
1508 { |
1584 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1509 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1585 { |
1510 { |
1586 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_attachments; |
1511 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread_attachments; |
1587 } |
1512 } |
1588 else |
1513 else |
1589 { |
1514 { |
1590 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread; |
1515 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_unread; |
1591 } |
1516 } |
1592 } |
1517 } |
1593 |
1518 |
1594 return icon; |
1519 return icon; |
1595 } |
1520 } |
1596 |
1521 |
1597 // ----------------------------------------------------------------------------- |
1522 // ----------------------------------------------------------------------------- |
1598 // CMailCpsHandler::GetReadCalMsgIcon |
1523 // CMailCpsHandler::GetReadCalMsgIcon |
1599 // ----------------------------------------------------------------------------- |
1524 // ----------------------------------------------------------------------------- |
1600 TInt CMailCpsHandler::GetReadCalMsgIcon( CFSMailMessage* aMsg ) |
1525 TInt CMailCpsHandler::GetReadCalMsgIcon( CFSMailMessage* aMsg ) |
1601 { |
1526 { |
1602 FUNC_LOG; |
1527 FUNC_LOG; |
1603 TInt icon(0); |
1528 TInt icon(0); |
1604 |
1529 |
1605 if ( aMsg->IsFlagSet( EFSMsgFlag_Important ) ) |
1530 if ( aMsg->IsFlagSet( EFSMsgFlag_Important ) ) |
1606 { |
1531 { |
1607 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1532 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1608 { |
1533 { |
1609 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_attachments_high_prio ; |
1534 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_attachments_high_prio ; |
1610 } |
1535 } |
1611 else |
1536 else |
1612 { |
1537 { |
1613 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_high_prio; |
1538 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_high_prio; |
1614 } |
1539 } |
1615 } |
1540 } |
1616 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) |
1541 else if ( aMsg->IsFlagSet( EFSMsgFlag_Low ) ) |
1617 { |
1542 { |
1618 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1543 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1619 { |
1544 { |
1620 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_attachments_low_prio; |
1545 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_attachments_low_prio; |
1621 } |
1546 } |
1622 else |
1547 else |
1623 { |
1548 { |
1624 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_low_prio; |
1549 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_low_prio; |
1625 } |
1550 } |
1626 } |
1551 } |
1627 else |
1552 else |
1628 { |
1553 { |
1629 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1554 if ( aMsg->IsFlagSet( EFSMsgFlag_Attachments ) ) |
1630 { |
1555 { |
1631 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_attachments; |
1556 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read_attachments; |
1632 } |
1557 } |
1633 else |
1558 else |
1634 { |
1559 { |
1635 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read; |
1560 icon = EMbmCmailhandlerpluginQgn_indi_cmail_calendar_event_read; |
1636 } |
1561 } |
1637 } |
1562 } |
1638 |
1563 |
1639 return icon; |
1564 return icon; |
1640 } |
1565 } |
1641 |
1566 |
1642 // ----------------------------------------------------------------------------- |
1567 // ----------------------------------------------------------------------------- |
1732 // Is the contentId related to internal mailbox or external? |
1658 // Is the contentId related to internal mailbox or external? |
1733 if( nativeMailboxId ) |
1659 if( nativeMailboxId ) |
1734 { |
1660 { |
1735 TUid mailBoxUid; |
1661 TUid mailBoxUid; |
1736 mailBoxUid.iUid = nativeMailboxId; |
1662 mailBoxUid.iUid = nativeMailboxId; |
1737 |
1663 |
1738 TFSMailMsgId mailBoxId; |
1664 TFSMailMsgId mailBoxId; |
1739 mailBoxId.SetId(mailBoxUid.iUid); |
1665 mailBoxId.SetId(mailBoxUid.iUid); |
1740 TUid pluginUid; |
1666 TUid pluginUid; |
1741 pluginUid.iUid = iSettings->GetPluginUidByContentId(aContentId); |
1667 pluginUid.iUid = iSettings->GetPluginUidByContentId(aContentId); |
1742 mailBoxId.SetPluginId(pluginUid); |
1668 mailBoxId.SetPluginId(pluginUid); |
1743 CFSMailBox* mailBox = MailClient().GetMailBoxByUidL( mailBoxId ); |
1669 CFSMailBox* mailBox = MailClient().GetMailBoxByUidL( mailBoxId ); |
1744 CleanupStack::PushL( mailBox ); |
1670 CleanupStack::PushL( mailBox ); |
1745 if ( mailBox ) |
1671 if ( mailBox ) |
1746 { |
1672 { |
1747 TFSMailMsgId inboxFolderId = mailBox->GetStandardFolderId( EFSInbox ); |
1673 TFSMailMsgId inboxFolderId = mailBox->GetStandardFolderId( EFSInbox ); |
1748 |
1674 |
1749 TMailListActivationData tmp; |
1675 TMailListActivationData tmp; |
1750 tmp.iFolderId = inboxFolderId; |
1676 tmp.iFolderId = inboxFolderId; |
1751 tmp.iMailBoxId = mailBoxId; |
1677 tmp.iMailBoxId = mailBoxId; |
1752 const TPckgBuf<TMailListActivationData> pkgOut( tmp ); |
1678 const TPckgBuf<TMailListActivationData> pkgOut( tmp ); |
1753 iEnv->EikAppUi()->ActivateViewL( TVwsViewId(KUidEmailUi, KMailListId), |
1679 iEnv->EikAppUi()->ActivateViewL( |
1754 KStartListWithFolderId, |
1680 TVwsViewId(KUidEmailUi, KMailListId), |
1755 pkgOut); |
1681 KStartListWithFolderIdFromHomeScreen, pkgOut); |
1756 } |
1682 } |
1757 CleanupStack::PopAndDestroy( mailBox ); |
1683 CleanupStack::PopAndDestroy( mailBox ); |
1758 } |
1684 } |
1759 else |
1685 else |
1760 { |
1686 { |
1761 LaunchExtAppL( aContentId ); |
1687 LaunchExtAppL( aContentId ); |
1762 } |
1688 } |
1763 } |
1689 } |
1764 |
1690 |
1765 // ----------------------------------------------------------------------------- |
1691 // ----------------------------------------------------------------------------- |
1766 // CMailCpsHandler::LaunchEmailUIL() |
1692 // CMailCpsHandler::LaunchEmailWizardL() |
1767 // ----------------------------------------------------------------------------- |
1693 // ----------------------------------------------------------------------------- |
1768 // |
1694 // |
1769 void CMailCpsHandler::LaunchEmailWizardL() |
1695 void CMailCpsHandler::LaunchEmailWizardL( const TDesC& aContentId ) |
1770 { |
1696 { |
1771 FUNC_LOG; |
1697 FUNC_LOG; |
1772 TUid viewUid(KNullUid); |
1698 TUid viewUid(KNullUid); |
1773 iEnv->EikAppUi()->ActivateViewL( TVwsViewId(KUidWizardApp, KUidEmailWizardView), |
1699 iEnv->EikAppUi()->ActivateViewL( TVwsViewId(KUidWizardApp, KUidEmailWizardView), |
1774 viewUid, |
1700 viewUid, |
1775 KNullDesC8); |
1701 KNullDesC8); |
|
1702 SetWaitingForNewMailbox( aContentId ); |
1776 } |
1703 } |
1777 |
1704 |
1778 // ----------------------------------------------------------------------------- |
1705 // ----------------------------------------------------------------------------- |
1779 // CMailCpsHandler::LaunchExtAppL() |
1706 // CMailCpsHandler::LaunchExtAppL() |
1780 // ----------------------------------------------------------------------------- |
1707 // ----------------------------------------------------------------------------- |
1803 { |
1730 { |
1804 plugin = iExternalPlugins[i]; |
1731 plugin = iExternalPlugins[i]; |
1805 } |
1732 } |
1806 } |
1733 } |
1807 return plugin; |
1734 return plugin; |
1808 } |
|
1809 |
|
1810 // ----------------------------------------------------------------------------- |
|
1811 // CMailCpsHandler::UpdateExtAccountL |
|
1812 // ----------------------------------------------------------------------------- |
|
1813 // |
|
1814 void CMailCpsHandler::UpdateExtAccountL( const TDesC& aContentId ) |
|
1815 { |
|
1816 FUNC_LOG; |
|
1817 // Look up plugin that handles this account |
|
1818 CMailPluginProxy* plugin = GetExtPluginL( aContentId ); |
|
1819 if ( plugin ) |
|
1820 { |
|
1821 // Publish its data |
|
1822 plugin->UpdateAccountL( aContentId ); |
|
1823 } |
|
1824 } |
|
1825 |
|
1826 // --------------------------------------------------------------------------- |
|
1827 // CMailCpsHandler::AssociateWidget |
|
1828 // --------------------------------------------------------------------------- |
|
1829 // |
|
1830 TBool CMailCpsHandler::AssociateWidgetToSetting( const TDesC& aContentId ) |
|
1831 { |
|
1832 FUNC_LOG; |
|
1833 return iSettings->AssociateWidgetToSetting( aContentId ); |
|
1834 } |
1735 } |
1835 |
1736 |
1836 // --------------------------------------------------------------------------- |
1737 // --------------------------------------------------------------------------- |
1837 // CMailCpsHandler::DissociateWidget |
1738 // CMailCpsHandler::DissociateWidget |
1838 // --------------------------------------------------------------------------- |
1739 // --------------------------------------------------------------------------- |
1839 // |
1740 // |
1840 void CMailCpsHandler::DissociateWidgetFromSettingL( const TDesC& aContentId ) |
1741 void CMailCpsHandler::DissociateWidgetFromSettingL( const TDesC& aContentId ) |
1841 { |
1742 { |
1842 FUNC_LOG; |
1743 FUNC_LOG; |
1843 //Do not dissociate if device is shutting down |
1744 iSettings->DissociateWidgetFromSettingL( aContentId ); |
1844 TInt status( 0 ); |
|
1845 RProperty::Get( KPSUidStartup, KPSGlobalSystemState, status ); |
|
1846 if (status != ESwStateShuttingDown) |
|
1847 { |
|
1848 iSettings->DissociateWidgetFromSettingL( aContentId ); |
|
1849 } |
|
1850 } |
1745 } |
1851 |
1746 |
1852 // --------------------------------------------------------------------------- |
1747 // --------------------------------------------------------------------------- |
1853 // CMailCpsHandler::TotalMailboxCount |
1748 // CMailCpsHandler::TotalMailboxCount |
1854 // --------------------------------------------------------------------------- |
1749 // --------------------------------------------------------------------------- |
1884 |
1779 |
1885 for ( TInt i = 0; i < plugins.Count(); i++ ) |
1780 for ( TInt i = 0; i < plugins.Count(); i++ ) |
1886 { |
1781 { |
1887 TUid implUid = plugins[i]->ImplementationUid(); |
1782 TUid implUid = plugins[i]->ImplementationUid(); |
1888 INFO_1("Instantiating plugin %d", implUid.iUid); |
1783 INFO_1("Instantiating plugin %d", implUid.iUid); |
1889 EmailInterface::CEmailObserverPlugin* plugin = |
1784 EmailInterface::CEmailObserverPlugin* plugin = |
1890 EmailInterface::CEmailObserverPlugin::NewL( implUid, this ); |
1785 EmailInterface::CEmailObserverPlugin::NewL( implUid, this ); |
1891 MEmailData& data( plugin->EmailDataL() ); |
1786 MEmailData& data( plugin->EmailDataL() ); |
1892 totalMailboxCount += data.MailboxesL().Count(); |
1787 totalMailboxCount += data.MailboxesL().Count(); |
1893 } |
1788 } |
1894 |
1789 |
1895 CleanupStack::PopAndDestroy(); // plugins |
1790 CleanupStack::PopAndDestroy(); // plugins |
1896 return totalMailboxCount; |
1791 return totalMailboxCount; |
1897 } |
|
1898 |
|
1899 // --------------------------------------------------------------------------- |
|
1900 // CMailCpsHandler::ManualAccountSelectionL |
|
1901 // --------------------------------------------------------------------------- |
|
1902 // |
|
1903 void CMailCpsHandler::ManualAccountSelectionL( const TDesC& aContentId ) |
|
1904 { |
|
1905 FUNC_LOG; |
|
1906 |
|
1907 if ( FirstBootL() ) |
|
1908 { |
|
1909 if (!iSettings->FindFromContentIdListL(aContentId)) |
|
1910 { |
|
1911 iSettings->AddToContentIdListL(aContentId); |
|
1912 } |
|
1913 } |
|
1914 else |
|
1915 { |
|
1916 if (!iSettings->FindFromContentIdListL(aContentId)) |
|
1917 { |
|
1918 iSettings->AddToContentIdListL(aContentId); |
|
1919 if ( TotalMailboxCountL() ) |
|
1920 { |
|
1921 LaunchWidgetSettingsL(aContentId); |
|
1922 } |
|
1923 else |
|
1924 { |
|
1925 LaunchEmailWizardL(); |
|
1926 } |
|
1927 } |
|
1928 } |
|
1929 } |
|
1930 |
|
1931 // --------------------------------------------------------------------------- |
|
1932 // CMailCpsHandler::FirstBootL |
|
1933 // --------------------------------------------------------------------------- |
|
1934 TBool CMailCpsHandler::FirstBootL() |
|
1935 { |
|
1936 FUNC_LOG; |
|
1937 TInt value( 0 ); |
|
1938 TBool ret(EFalse); |
|
1939 |
|
1940 CRepository* repository(NULL); |
|
1941 |
|
1942 TRAPD( err, repository = CRepository::NewL( KCRUidStartup ) ); |
|
1943 if ( err == KErrNone ) |
|
1944 { |
|
1945 err = repository->Get( KStartupFirstBoot, value ); |
|
1946 } |
|
1947 delete repository; |
|
1948 |
|
1949 if (!value) |
|
1950 { |
|
1951 ret = ETrue; |
|
1952 } |
|
1953 |
|
1954 return ret; |
|
1955 } |
1792 } |
1956 |
1793 |
1957 // --------------------------------------------------------------------------- |
1794 // --------------------------------------------------------------------------- |
1958 // CMailCpsHandler::EmailObserverEvent |
1795 // CMailCpsHandler::EmailObserverEvent |
1959 // --------------------------------------------------------------------------- |
1796 // --------------------------------------------------------------------------- |
1960 void CMailCpsHandler::EmailObserverEvent( EmailInterface::MEmailData& /*aData*/ ) |
1797 void CMailCpsHandler::EmailObserverEvent( EmailInterface::MEmailData& /*aData*/ ) |
1961 { |
1798 { |
|
1799 FUNC_LOG; |
1962 // Nothing to do |
1800 // Nothing to do |
1963 } |
1801 } |
|
1802 |
|
1803 // ----------------------------------------------------------------------------- |
|
1804 // CMailCpsHandler::SetWaitingForNewMailbox() |
|
1805 // ----------------------------------------------------------------------------- |
|
1806 // |
|
1807 void CMailCpsHandler::SetWaitingForNewMailbox( const TDesC& aContentId ) |
|
1808 { |
|
1809 FUNC_LOG; |
|
1810 HBufC* newCid = aContentId.Alloc(); |
|
1811 if ( newCid ) |
|
1812 { |
|
1813 delete iWaitingForNewMailbox; |
|
1814 iWaitingForNewMailbox = newCid; |
|
1815 } |
|
1816 } |
|
1817 |
|
1818 // ----------------------------------------------------------------------------- |
|
1819 // CMailCpsHandler::CleanWaitingForNewMailbox() |
|
1820 // ----------------------------------------------------------------------------- |
|
1821 // |
|
1822 void CMailCpsHandler::CleanWaitingForNewMailbox() |
|
1823 { |
|
1824 FUNC_LOG; |
|
1825 if (iWaitingForNewMailbox) |
|
1826 { |
|
1827 delete iWaitingForNewMailbox; |
|
1828 iWaitingForNewMailbox = NULL; |
|
1829 } |
|
1830 } |