411 { |
517 { |
412 return ETrue; |
518 return ETrue; |
413 } |
519 } |
414 return EFalse; |
520 return EFalse; |
415 } |
521 } |
|
522 |
|
523 //----------------------------------------------------------------------------- |
|
524 // ConversationMsgStoreHandler::ResendMessage(TMsvId aId) |
|
525 // |
|
526 // ----------------------------------------------------------------------------- |
|
527 // |
|
528 |
|
529 bool ConversationMsgStoreHandler::ResendMessageL(TMsvId aId) |
|
530 { |
|
531 bool retval = true; |
|
532 TMsvId serviceId; |
|
533 TMsvEntry msgEntry; |
|
534 |
|
535 if(iMsvSession == NULL) |
|
536 { |
|
537 return false; |
|
538 } |
|
539 TInt err = iMsvSession->GetEntry(aId, serviceId, msgEntry); |
|
540 |
|
541 if (KErrNone == err) |
|
542 { |
|
543 TUid mtmUid = msgEntry.iMtm; |
|
544 |
|
545 CMsvEntry* entry = iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId); |
|
546 CleanupStack::PushL(entry); |
|
547 |
|
548 CMuiuOperationWait* wait = CMuiuOperationWait::NewLC(); |
|
549 |
|
550 if (mtmUid == KSmsMtmUid) |
|
551 { |
|
552 UniEditorGenUtils* genUtils = new UniEditorGenUtils(); |
|
553 CleanupStack::PushL(genUtils); |
|
554 |
|
555 // if phone is in offline mode set sending state to suspended |
|
556 // so that mtm does not try to send it. |
|
557 if (iOfflineSupported && genUtils->IsPhoneOfflineL()) |
|
558 { |
|
559 msgEntry.SetSendingState(KMsvSendStateSuspended); |
|
560 msgEntry.iError = KErrGsmOfflineOpNotAllowed; |
|
561 } |
|
562 else |
|
563 { |
|
564 msgEntry.SetSendingState(KMsvSendStateWaiting); |
|
565 } |
|
566 CleanupStack::PopAndDestroy(genUtils); |
|
567 |
|
568 // Update message entry with sending state. |
|
569 entry->SetEntryL(msgEntry.Id()); |
|
570 entry->ChangeL(msgEntry); |
|
571 |
|
572 TMsvId firstId; |
|
573 TSmsUtilities::ServiceIdL(*iMsvSession, firstId); |
|
574 |
|
575 entry->SetEntryL(KMsvGlobalOutBoxIndexEntryId); |
|
576 //send the message |
|
577 entry->CopyL(aId, firstId, wait->iStatus); |
|
578 wait->Start(); |
|
579 } |
|
580 else if (mtmUid == KMmsMtmUid) |
|
581 { |
|
582 //send the message |
|
583 entry->CopyL(aId, msgEntry.iServiceId, wait->iStatus); |
|
584 wait->Start(); |
|
585 } |
|
586 CleanupStack::PopAndDestroy(2, entry); |
|
587 } |
|
588 else |
|
589 { |
|
590 User::LeaveIfError(err); |
|
591 } |
|
592 return retval; |
|
593 } |
|
594 |
|
595 //----------------------------------------------------------------------------- |
|
596 // ConversationMsgStoreHandler::DownloadOperationSupported |
|
597 // ----------------------------------------------------------------------------- |
|
598 bool ConversationMsgStoreHandler::DownloadOperationSupported( |
|
599 const TMsvId& aId) |
|
600 { |
|
601 TMsvId serviceId; |
|
602 TMsvEntry msgEntry; |
|
603 TInt err = iMsvSession->GetEntry(aId,serviceId,msgEntry); |
|
604 |
|
605 TCsMmsNotificationMsgState msgstatus = |
|
606 MmsNotificationStatus( aId ); |
|
607 |
|
608 if ( msgEntry.iType == KUidMsvMessageEntry ) |
|
609 { |
|
610 |
|
611 if( msgEntry.iMtmData2 & KMmsNewOperationForbidden ) // New Forbidden |
|
612 { |
|
613 return false; |
|
614 } |
|
615 // If notification is succesfully routed to app |
|
616 // aContext.iMtmData2 & KMmsMessageRoutedToApplication is ETrue and |
|
617 // if notification is NOT succesfully routed to app |
|
618 // aContext.iError is KMmsErrorUnregisteredApplication. |
|
619 if( ( msgEntry.iError == KMmsErrorUnregisteredApplication ) // To unregistered application |
|
620 || ( msgEntry.iMtmData2 & KMmsMessageRoutedToApplication ) ) |
|
621 { |
|
622 return false; |
|
623 } |
|
624 |
|
625 if( msgstatus == EMsgStatusDeleted ) |
|
626 { // Msg already been deleted from server |
|
627 return false; |
|
628 } |
|
629 |
|
630 if( msgstatus == EMsgStatusReadyForFetching |
|
631 || msgstatus == EMsgStatusFailed ) |
|
632 { // Fetch is supported if the msg is waiting or something has been failed |
|
633 return true; |
|
634 } |
|
635 |
|
636 if ( msgstatus == EMsgStatusForwarded |
|
637 && msgEntry.iMtmData2 & KMmsStoredInMMBox ) |
|
638 { // Fetch is supported if it's forwarded and multiple forward is supported |
|
639 return true; |
|
640 } |
|
641 |
|
642 if( msgstatus == EMsgStatusExpired ) |
|
643 { |
|
644 return false; |
|
645 } |
|
646 } |
|
647 return false; |
|
648 } |
|
649 |
|
650 //--------------------------------------------------------------- |
|
651 // ConversationMsgStoreHandler::setNotificationMessageId |
|
652 // @see header |
|
653 //--------------------------------------------------------------- |
|
654 void ConversationMsgStoreHandler::setNotificationMessageId(int messageId) |
|
655 { |
|
656 // get MMS Notification client mtm & set the content to current entry |
|
657 if(iNotificationClient) |
|
658 { |
|
659 delete iNotificationClient; |
|
660 iNotificationClient = NULL; |
|
661 } |
|
662 CClientMtmRegistry* mtmRegistry = |
|
663 CClientMtmRegistry::NewL( *iMsvSession ); |
|
664 iNotificationClient = static_cast<CMmsNotificationClientMtm*>( |
|
665 mtmRegistry->NewMtmL( KUidMsgMMSNotification )); |
|
666 iNotificationClient->SwitchCurrentEntryL(messageId); |
|
667 iNotificationClient->LoadMessageL(); |
|
668 } |
|
669 |
|
670 //--------------------------------------------------------------- |
|
671 // ConversationMsgStoreHandler::NotificationMsgSize |
|
672 // @see header |
|
673 //--------------------------------------------------------------- |
|
674 QString ConversationMsgStoreHandler::NotificationMsgSize() |
|
675 { |
|
676 // Size of message. |
|
677 TInt size = iNotificationClient->MessageTransferSize( ); |
|
678 |
|
679 // read max receive size limit from settings |
|
680 CMmsSettings* settings = CMmsSettings::NewL(); |
|
681 CleanupStack::PushL( settings ); |
|
682 iNotificationClient->RestoreSettingsL(); |
|
683 settings->CopyL( iNotificationClient->MmsSettings() ); |
|
684 TInt maxSize = static_cast<TInt>(settings->MaximumReceiveSize() ); |
|
685 CleanupStack::PopAndDestroy( settings ); |
|
686 |
|
687 // apply max size limit rule |
|
688 if( maxSize > 0 ) |
|
689 { |
|
690 if( size > maxSize ) |
|
691 { |
|
692 size = maxSize; |
|
693 } |
|
694 } |
|
695 |
|
696 // Finally make the UI string |
|
697 int fileSize = size / BYTES_TO_KBYTES_FACTOR; |
|
698 if ( size % BYTES_TO_KBYTES_FACTOR ) |
|
699 { |
|
700 fileSize++; |
|
701 } |
|
702 // TODO: use localized string constants here |
|
703 QString sizeString = QString("%1").arg(fileSize); |
|
704 sizeString.append(" Kb"); |
|
705 return sizeString; |
|
706 } |
|
707 |
|
708 //--------------------------------------------------------------- |
|
709 // ConversationMsgStoreHandler::NotificationClass |
|
710 // @see header |
|
711 //--------------------------------------------------------------- |
|
712 QString ConversationMsgStoreHandler::NotificationClass() |
|
713 { |
|
714 //TODO: use localized string |
|
715 QString notificationClass; |
|
716 TInt msgClass = iNotificationClient->MessageClass( ); |
|
717 switch( msgClass ) |
|
718 { |
|
719 case EMmsClassPersonal: |
|
720 { |
|
721 notificationClass = "Personal"; |
|
722 break; |
|
723 } |
|
724 case EMmsClassAdvertisement: |
|
725 { |
|
726 notificationClass = "Advertisement"; |
|
727 break; |
|
728 } |
|
729 case EMmsClassInformational: |
|
730 { |
|
731 notificationClass = "Informative"; |
|
732 break; |
|
733 } |
|
734 default: |
|
735 { // In case no class is returned (0), don't add the field |
|
736 break; |
|
737 } |
|
738 } |
|
739 return notificationClass; |
|
740 } |
|
741 |
|
742 //--------------------------------------------------------------- |
|
743 // ConversationMsgStoreHandler::NotificationStatus |
|
744 // @see header |
|
745 //--------------------------------------------------------------- |
|
746 void ConversationMsgStoreHandler::NotificationStatus( |
|
747 int& status, |
|
748 QString& statusStr) |
|
749 { |
|
750 // TODO : use standard strings provided by Arul |
|
751 // fetch mms notification status from store handler |
|
752 // and map as per our UI requirements |
|
753 TMsvEntry entry = iNotificationClient->Entry().Entry(); |
|
754 status = MmsNotificationStatus(entry.Id()); |
|
755 switch(status) |
|
756 { |
|
757 case ConvergedMessage::NotifFailed: |
|
758 { |
|
759 statusStr = "Message retrieval failed !"; |
|
760 break; |
|
761 } |
|
762 case ConvergedMessage::NotifExpired: |
|
763 { |
|
764 statusStr = "Message Expired !"; |
|
765 break; |
|
766 } |
|
767 case ConvergedMessage::NotifReadyForFetching: |
|
768 { |
|
769 statusStr = "Multimedia Message waiting..."; |
|
770 break; |
|
771 } |
|
772 case ConvergedMessage::NotifWaiting: |
|
773 case ConvergedMessage::NotifRetrieving: |
|
774 { |
|
775 statusStr = "Retrieving message..."; |
|
776 break; |
|
777 } |
|
778 default: |
|
779 { |
|
780 // not handled, do nothing |
|
781 break; |
|
782 } |
|
783 } |
|
784 } |
|
785 |
|
786 //--------------------------------------------------------------- |
|
787 // ConversationMsgStoreHandler::NotificationExpiryDate |
|
788 // @see header |
|
789 //--------------------------------------------------------------- |
|
790 void ConversationMsgStoreHandler::NotificationExpiryDate( |
|
791 TTime& expiryTime, |
|
792 QString& expiryTimeStr) |
|
793 { |
|
794 // get expiry time from entry |
|
795 expiryTime = iNotificationClient->ExpiryDate( ); |
|
796 TLocale locale; |
|
797 expiryTime += locale.UniversalTimeOffset(); |
|
798 if (locale.QueryHomeHasDaylightSavingOn()) |
|
799 { |
|
800 TTimeIntervalHours daylightSaving(1); |
|
801 expiryTime += daylightSaving; |
|
802 } |
|
803 |
|
804 // create formatted string for the expiry time |
|
805 TTime unixEpoch(KUnixEpoch); |
|
806 TTimeIntervalSeconds seconds; |
|
807 expiryTime.SecondsFrom(unixEpoch, seconds); |
|
808 QDateTime dateTime; |
|
809 dateTime.setTime_t(seconds.Int()); |
|
810 if (dateTime.date() == QDateTime::currentDateTime().date()) { |
|
811 expiryTimeStr = dateTime.toString(TIME_FORMAT); |
|
812 } |
|
813 else { |
|
814 expiryTimeStr = dateTime.toString(DATE_FORMAT); |
|
815 } |
|
816 } |
|
817 |
|
818 //----------------------------------------------------------------------------- |
|
819 // ConversationMsgStoreHandler::DownloadMessageL |
|
820 // |
|
821 // ----------------------------------------------------------------------------- |
|
822 // |
|
823 |
|
824 TInt ConversationMsgStoreHandler::DownloadMessageL(TMsvId aId) |
|
825 { |
|
826 TMsvId serviceId; |
|
827 TMsvEntry msgEntry; |
|
828 |
|
829 TInt err = iMsvSession->GetEntry(aId,serviceId,msgEntry); |
|
830 |
|
831 if(err!= KErrNone || msgEntry.iMtm!= KUidMsgMMSNotification) |
|
832 { |
|
833 return KErrGeneral; |
|
834 } |
|
835 |
|
836 /*if(!iNotificationClient) |
|
837 { |
|
838 iNotificationClient = static_cast<CMmsNotificationClientMtm*> |
|
839 (iMtmReg->NewMtmL(KUidMsgMMSNotification)); |
|
840 } |
|
841 iNotificationClient->SwitchCurrentEntryL(aId); */ |
|
842 |
|
843 // set context to current entry |
|
844 setNotificationMessageId(aId); |
|
845 |
|
846 TTime currentTime; |
|
847 currentTime.HomeTime( ); |
|
848 TTime expiryTime = iNotificationClient->ExpiryDate( ); |
|
849 TLocale locale; |
|
850 expiryTime += locale.UniversalTimeOffset(); |
|
851 if (locale.QueryHomeHasDaylightSavingOn()) |
|
852 { |
|
853 TTimeIntervalHours daylightSaving(1); |
|
854 expiryTime += daylightSaving; |
|
855 } |
|
856 |
|
857 if( currentTime > expiryTime ) |
|
858 { // Message is expired |
|
859 return KErrGeneral; |
|
860 } |
|
861 |
|
862 //Check if the mms client mtm object is already created or not |
|
863 if( iMmsClient ) |
|
864 { |
|
865 // If mms client mtm object is already created restore the settings |
|
866 iMmsClient->RestoreSettingsL(); |
|
867 } |
|
868 else |
|
869 { |
|
870 iMmsClient = static_cast<CMmsClientMtm*> (iMtmReg->NewMtmL(KMmsMtmUid)); |
|
871 } |
|
872 |
|
873 //TODO chk if only AP check is sufficient |
|
874 TMsvId service = iMmsClient->DefaultServiceL(); |
|
875 TBool valid( iMmsClient->ValidateService( service ) == KErrNone ); |
|
876 if(!valid) |
|
877 { |
|
878 return KErrNotFound; |
|
879 } |
|
880 |
|
881 CMuiuOperationWait* wait =CMuiuOperationWait::NewLC();; |
|
882 |
|
883 CMsvEntrySelection* sel = new ( ELeave ) CMsvEntrySelection; |
|
884 CleanupStack::PushL( sel ); |
|
885 sel->AppendL( aId ); |
|
886 |
|
887 CMsvOperation* op = |
|
888 iNotificationClient->FetchMessagesL( *sel, wait->iStatus ); |
|
889 |
|
890 if( !op ) |
|
891 { |
|
892 CleanupStack::PopAndDestroy( sel ); // selection |
|
893 CleanupStack::PopAndDestroy( wait ); // wait |
|
894 return KErrGeneral; |
|
895 } |
|
896 |
|
897 CleanupStack::PushL( op ); |
|
898 wait->Start(); |
|
899 // Lets ignore the return value of wait |
|
900 |
|
901 CleanupStack::PopAndDestroy( op ); // op |
|
902 CleanupStack::PopAndDestroy( sel ); // selection |
|
903 CleanupStack::PopAndDestroy( wait ); // wait |
|
904 |
|
905 return KErrNone; |
|
906 } |
|
907 |
|
908 //---------------------------------------------------------------------------- |
|
909 // ConversationMsgStoreHandler::markAsReadAndGetType |
|
910 // @see header |
|
911 //---------------------------------------------------------------------------- |
|
912 void ConversationMsgStoreHandler::markAsReadAndGetType(int msgId, |
|
913 int& msgType, |
|
914 int& msgSubType) |
|
915 { |
|
916 msgType = ConvergedMessage::None; |
|
917 msgSubType = ConvergedMessage::None; |
|
918 |
|
919 CMsvEntry* cEntry = NULL; |
|
920 TRAPD(err, cEntry = iMsvSession->GetEntryL(msgId)); |
|
921 if ( err == KErrNone) |
|
922 { |
|
923 TMsvEntry entry = cEntry->Entry(); |
|
924 if ( entry.Unread() ) |
|
925 { |
|
926 // Mark the entry as read |
|
927 entry.SetUnread( EFalse ); |
|
928 cEntry->ChangeL( entry ); |
|
929 } |
|
930 // extract message type |
|
931 extractMsgType(entry,msgType,msgSubType); |
|
932 } |
|
933 |
|
934 delete cEntry; |
|
935 } |
|
936 |
|
937 //---------------------------------------------------------------------------- |
|
938 // ConversationMsgStoreHandler::extractMsgType |
|
939 // @see header |
|
940 //---------------------------------------------------------------------------- |
|
941 void ConversationMsgStoreHandler::extractMsgType(const TMsvEntry& entry, |
|
942 int& msgType, |
|
943 int& msgSubType) |
|
944 { |
|
945 msgType = ConvergedMessage::None; |
|
946 msgSubType = ConvergedMessage::None; |
|
947 |
|
948 switch(entry.iMtm.iUid) |
|
949 { |
|
950 case KSenduiMtmSmsUidValue: |
|
951 msgType = ConvergedMessage::Sms; |
|
952 break; |
|
953 case KSenduiMtmBtUidValue: |
|
954 msgType = ConvergedMessage::BT; |
|
955 break; |
|
956 case KSenduiMtmMmsUidValue: |
|
957 msgType = ConvergedMessage::Mms; |
|
958 break; |
|
959 case KSenduiMMSNotificationUidValue: |
|
960 msgType = ConvergedMessage::MmsNotification; |
|
961 break; |
|
962 case KSenduiMtmBioUidValue: |
|
963 { |
|
964 msgType = ConvergedMessage::BioMsg; |
|
965 |
|
966 // based on the biotype uid set message type |
|
967 if(entry.iBioType == KMsgBioUidRingingTone.iUid) |
|
968 { |
|
969 msgSubType = ConvergedMessage::RingingTone; |
|
970 } |
|
971 else if(entry.iBioType == KMsgBioProvisioningMessage.iUid) |
|
972 { |
|
973 msgSubType = ConvergedMessage::Provisioning; |
|
974 } |
|
975 else if (entry.iBioType == KMsgBioUidVCard.iUid) |
|
976 { |
|
977 msgSubType = ConvergedMessage::VCard; |
|
978 } |
|
979 else if (entry.iBioType == KMsgBioUidVCalendar.iUid) |
|
980 { |
|
981 msgSubType = ConvergedMessage::VCal; |
|
982 } |
|
983 } |
|
984 break; |
|
985 default: |
|
986 msgType = ConvergedMessage::None; |
|
987 break; |
|
988 } |
|
989 } |
416 // End of file |
990 // End of file |