messagingapp/msgui/appengine/src/conversationmsgstorehandler.cpp
changeset 41 25fe1fe642e3
parent 37 518b245aa84c
child 51 3507212d340e
equal deleted inserted replaced
40:224522e33db9 41:25fe1fe642e3
    13 *
    13 *
    14 * Description:  
    14 * Description:  
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 #include <hbglobal.h>
    18 #include <textresolver.h> // from CommonEngine
    19 #include <textresolver.h> // from CommonEngine
    19 #include <mtclreg.h>
    20 #include <mtclreg.h>
    20 #include <mmsnotificationclient.h>
    21 #include <mmsnotificationclient.h>
    21 #include <mmssettings.h>
    22 #include <mmssettings.h>
    22 #include <xqconversions.h> // from xqutils
    23 #include <xqconversions.h> // from xqutils
    43 // CONSTANTS
    44 // CONSTANTS
    44 const TUid KSmsMtmUid ={KSenduiMtmSmsUidValue};
    45 const TUid KSmsMtmUid ={KSenduiMtmSmsUidValue};
    45 const TUid KMmsMtmUid ={KSenduiMtmMmsUidValue};
    46 const TUid KMmsMtmUid ={KSenduiMtmMmsUidValue};
    46 _LIT(KUnixEpoch, "19700000:000000.000000");
    47 _LIT(KUnixEpoch, "19700000:000000.000000");
    47 #define BYTES_TO_KBYTES_FACTOR 1024
    48 #define BYTES_TO_KBYTES_FACTOR 1024
       
    49 
       
    50 // LOCALIZATION
       
    51 #define LOC_MESSAGE_SIZE hbTrId("txt_messaging_list_size")
       
    52 #define LOC_CLASS_ADVERTISEMENT hbTrId("txt_messaging_list_advertisement")
       
    53 #define LOC_CLASS_INFORMATIONAL hbTrId("txt_messaging_list_informational")
       
    54 #define LOC_CLASS_PERSONAL hbTrId("txt_messaging_list_personal")
       
    55 #define LOC_MMS_RETRIEVAL_FAILED hbTrId("txt_messaging_dialog_mms_retrieval_failed")
       
    56 #define LOC_MMS_NOTIF_EXPIRED hbTrId("Message Expired !")   //TODO: localization
       
    57 #define LOC_MMS_WAITING hbTrId("txt_wireframe_list_multimedia_message_waiting")
       
    58 #define LOC_MMS_RETRIEVING hbTrId("Retrieving message...")   //TODO: localization
       
    59 #define LOC_MMS_EXPIRY_DATE hbTrId("txt_messaging_list_expiry_date")
    48 
    60 
    49 // TODO: read global setting of formats on the phone
    61 // TODO: read global setting of formats on the phone
    50 const QString DATE_FORMAT("dd/MM");
    62 const QString DATE_FORMAT("dd/MM");
    51 const QString TIME_FORMAT("hh:mm");
    63 const QString TIME_FORMAT("hh:mm");
    52 
    64 
   672 
   684 
   673 //---------------------------------------------------------------
   685 //---------------------------------------------------------------
   674 // ConversationMsgStoreHandler::NotificationMsgSizeL
   686 // ConversationMsgStoreHandler::NotificationMsgSizeL
   675 // @see header
   687 // @see header
   676 //---------------------------------------------------------------
   688 //---------------------------------------------------------------
   677 QString ConversationMsgStoreHandler::NotificationMsgSizeL()
   689 QString ConversationMsgStoreHandler::NotificationMsgSize()
   678 {
   690 {
   679     // Size of message.
   691     // Size of message.
   680     TInt size = iNotificationClient->MessageTransferSize( );
   692     TInt size = iNotificationClient->MessageTransferSize( );
   681     
   693 
   682     // read max receive size limit from settings
   694     // read max receive size limit from settings
   683     CMmsSettings* settings = CMmsSettings::NewL();
   695     TInt maxSize = 0;
   684     CleanupStack::PushL( settings );
   696     TRAP_IGNORE(maxSize = MaxReceiveSizeLimitL());
   685     iNotificationClient->RestoreSettingsL();
       
   686     settings->CopyL( iNotificationClient->MmsSettings() );
       
   687     TInt maxSize = static_cast<TInt>(settings->MaximumReceiveSize() );
       
   688     CleanupStack::PopAndDestroy( settings );
       
   689 
   697 
   690     // apply max size limit rule
   698     // apply max size limit rule
   691     if( maxSize > 0 )
   699     if( maxSize > 0 )
   692     {
   700     {
   693         if( size > maxSize )
   701         if( size > maxSize )
   694         {
   702         {
   695             size = maxSize;
   703             size = maxSize;
   696         }
   704         }
   697     }
   705     }
   698 
   706 
   699     // Finally make the UI string
   707     TInt fileSize = size / BYTES_TO_KBYTES_FACTOR;
   700     int fileSize = size / BYTES_TO_KBYTES_FACTOR;
       
   701     if ( size % BYTES_TO_KBYTES_FACTOR )
   708     if ( size % BYTES_TO_KBYTES_FACTOR )
   702     {
   709     {
   703         fileSize++;
   710         fileSize++;
   704     }
   711     }
   705     // TODO: use localized string constants here
   712 
   706     QString sizeString = QString("%1").arg(fileSize);
   713     return LOC_MESSAGE_SIZE.arg(fileSize);
   707     sizeString.append(" Kb");
       
   708     return sizeString;
       
   709 }
   714 }
   710 
   715 
   711 //---------------------------------------------------------------
   716 //---------------------------------------------------------------
   712 // ConversationMsgStoreHandler::NotificationClass
   717 // ConversationMsgStoreHandler::NotificationClass
   713 // @see header
   718 // @see header
   714 //---------------------------------------------------------------
   719 //---------------------------------------------------------------
   715 QString ConversationMsgStoreHandler::NotificationClass()
   720 QString ConversationMsgStoreHandler::NotificationClass()
   716 {
   721 {
   717     //TODO: use localized string
       
   718     QString notificationClass;
   722     QString notificationClass;
   719     TInt msgClass = iNotificationClient->MessageClass( );
   723     TInt msgClass = iNotificationClient->MessageClass( );
   720     switch( msgClass )
   724     switch( msgClass )
   721     {
   725     {
   722         case EMmsClassPersonal:
   726         case EMmsClassPersonal:
   723         {
   727         {
   724             notificationClass = "Personal";
   728             notificationClass = LOC_CLASS_PERSONAL;
   725             break;
   729             break;
   726         }
   730         }
   727         case EMmsClassAdvertisement:
   731         case EMmsClassAdvertisement:
   728         {
   732         {
   729             notificationClass = "Advertisement";
   733             notificationClass = LOC_CLASS_ADVERTISEMENT;
   730             break;
   734             break;
   731         }
   735         }
   732         case EMmsClassInformational:
   736         case EMmsClassInformational:
   733         {
   737         {
   734             notificationClass = "Informative";
   738             notificationClass = LOC_CLASS_INFORMATIONAL;
   735             break;
   739             break;
   736         }
   740         }
   737         default:
   741         default:
   738         {   // In case no class is returned (0), don't add the field
   742         {   // In case no class is returned (0), don't add the field
   739             break;
   743             break;
   748 //---------------------------------------------------------------
   752 //---------------------------------------------------------------
   749 void ConversationMsgStoreHandler::NotificationStatus(
   753 void ConversationMsgStoreHandler::NotificationStatus(
   750         int& status,
   754         int& status,
   751         QString& statusStr)
   755         QString& statusStr)
   752 {
   756 {
   753     // TODO : use standard strings provided by Arul
       
   754     // fetch mms notification status from store handler
   757     // fetch mms notification status from store handler
   755     // and map as per our UI requirements
   758     // and map as per our UI requirements
   756     TMsvEntry entry = iNotificationClient->Entry().Entry();
   759     TMsvEntry entry = iNotificationClient->Entry().Entry();
   757     status = MmsNotificationStatus(entry.Id());
   760     status = MmsNotificationStatus(entry.Id());
   758     switch(status)
   761     switch(status)
   759     {
   762     {
   760         case ConvergedMessage::NotifFailed:
   763         case ConvergedMessage::NotifFailed:
   761         {
   764         {
   762             statusStr = "Message retrieval failed !";
   765             statusStr = LOC_MMS_RETRIEVAL_FAILED;
   763             break;
   766             break;
   764         }
   767         }
   765         case ConvergedMessage::NotifExpired:
   768         case ConvergedMessage::NotifExpired:
   766         {
   769         {
   767             statusStr = "Message Expired !";
   770             statusStr = LOC_MMS_NOTIF_EXPIRED;
   768             break;
   771             break;
   769         }
   772         }
   770         case ConvergedMessage::NotifReadyForFetching:
   773         case ConvergedMessage::NotifReadyForFetching:
   771         {
   774         {
   772             statusStr = "Multimedia Message waiting...";
   775             statusStr = LOC_MMS_WAITING;
   773             break;
   776             break;
   774         }
   777         }
   775         case ConvergedMessage::NotifWaiting:
   778         case ConvergedMessage::NotifWaiting:
   776         case ConvergedMessage::NotifRetrieving:
   779         case ConvergedMessage::NotifRetrieving:
   777         {
   780         {
   778             statusStr = "Retrieving message...";
   781             statusStr = LOC_MMS_RETRIEVING;
   779             break;
   782             break;
   780         }
   783         }
   781         default:
   784         default:
   782         {
   785         {
   783             // not handled, do nothing
   786             // not handled, do nothing
   788 
   791 
   789 //---------------------------------------------------------------
   792 //---------------------------------------------------------------
   790 // ConversationMsgStoreHandler::NotificationExpiryDate
   793 // ConversationMsgStoreHandler::NotificationExpiryDate
   791 // @see header
   794 // @see header
   792 //---------------------------------------------------------------
   795 //---------------------------------------------------------------
   793 void ConversationMsgStoreHandler::NotificationExpiryDate(
   796 QString ConversationMsgStoreHandler::NotificationExpiryDate()
   794         TTime& expiryTime,
   797 {
   795         QString& expiryTimeStr)
   798     TTime expiryTime = 0;
   796 {
   799     QString expiryTimeStr;
       
   800 
   797     // get expiry time from entry
   801     // get expiry time from entry
   798     expiryTime = iNotificationClient->ExpiryDate( );
   802     expiryTime = iNotificationClient->ExpiryDate( );
   799     TLocale locale;
   803     TLocale locale;
   800     expiryTime += locale.UniversalTimeOffset();
   804     expiryTime += locale.UniversalTimeOffset();
   801     if (locale.QueryHomeHasDaylightSavingOn())          
   805     if (locale.QueryHomeHasDaylightSavingOn())          
   806     
   810     
   807     // create formatted string for the expiry time
   811     // create formatted string for the expiry time
   808     TTime unixEpoch(KUnixEpoch);
   812     TTime unixEpoch(KUnixEpoch);
   809     TTimeIntervalSeconds seconds;
   813     TTimeIntervalSeconds seconds;
   810     expiryTime.SecondsFrom(unixEpoch, seconds);
   814     expiryTime.SecondsFrom(unixEpoch, seconds);
   811     QDateTime dateTime;
   815     return LOC_MMS_EXPIRY_DATE.arg(seconds.Int());
   812     dateTime.setTime_t(seconds.Int());
       
   813     if (dateTime.date() == QDateTime::currentDateTime().date()) {
       
   814         expiryTimeStr = dateTime.toString(TIME_FORMAT);
       
   815     }
       
   816     else {
       
   817         expiryTimeStr = dateTime.toString(DATE_FORMAT);
       
   818     }
       
   819 }
   816 }
   820 
   817 
   821 //-----------------------------------------------------------------------------
   818 //-----------------------------------------------------------------------------
   822 // ConversationMsgStoreHandler::DownloadMessageL
   819 // ConversationMsgStoreHandler::DownloadMessageL
   823 // 
   820 // 
   965         case KSenduiMMSNotificationUidValue:            
   962         case KSenduiMMSNotificationUidValue:            
   966             msgType = ConvergedMessage::MmsNotification;
   963             msgType = ConvergedMessage::MmsNotification;
   967             break;
   964             break;
   968         case KSenduiMtmBioUidValue:
   965         case KSenduiMtmBioUidValue:
   969             { 
   966             { 
       
   967  			if (entry.iMtmData1 == KSenduiMtmBtUidValue) 
       
   968 				{
       
   969             	msgType = ConvergedMessage::BT;
       
   970 
       
   971             	if (entry.iBioType == KMsgBioUidVCard.iUid) 
       
   972 					{	
       
   973                		 msgSubType = ConvergedMessage::VCard;
       
   974             		}
       
   975             	else if (entry.iBioType == KMsgBioUidVCalendar.iUid) 
       
   976 					{
       
   977 			
       
   978                		 msgSubType = ConvergedMessage::VCal;
       
   979             		}
       
   980 
       
   981            	 break;
       
   982        		 }
   970             msgType = ConvergedMessage::BioMsg; 
   983             msgType = ConvergedMessage::BioMsg; 
   971 
   984 
   972             // based on the biotype uid set message type
   985             // based on the biotype uid set message type
   973             if(entry.iBioType == KMsgBioUidRingingTone.iUid)
   986             if(entry.iBioType == KMsgBioUidRingingTone.iUid)
   974                 {
   987                 {
   995         msgType = ConvergedMessage::None;
  1008         msgType = ConvergedMessage::None;
   996         break;
  1009         break;
   997     }
  1010     }
   998 }
  1011 }
   999 
  1012 
       
  1013 //----------------------------------------------------------------------------
       
  1014 // ConversationMsgStoreHandler::getMsgSubType
       
  1015 // @see header
       
  1016 //----------------------------------------------------------------------------
  1000 int ConversationMsgStoreHandler::getMsgSubType(int msgId)
  1017 int ConversationMsgStoreHandler::getMsgSubType(int msgId)
  1001 {
  1018 {
  1002     int msgType = ConvergedMessage::None;
  1019     int msgType = ConvergedMessage::None;
  1003     int msgSubType = ConvergedMessage::None;
  1020     int msgSubType = ConvergedMessage::None;
  1004     CMsvEntry* cEntry = NULL;
  1021     CMsvEntry* cEntry = NULL;
  1008         extractMsgType(entry, msgType, msgSubType);
  1025         extractMsgType(entry, msgType, msgSubType);
  1009     }
  1026     }
  1010     return msgSubType;
  1027     return msgSubType;
  1011 }
  1028 }
  1012 
  1029 
       
  1030 //----------------------------------------------------------------------------
       
  1031 // ConversationMsgStoreHandler::MaxReceiveSizeLimitL
       
  1032 // @see header
       
  1033 //----------------------------------------------------------------------------
       
  1034 TInt ConversationMsgStoreHandler::MaxReceiveSizeLimitL()
       
  1035 {
       
  1036     CMmsSettings* settings = CMmsSettings::NewL();
       
  1037     CleanupStack::PushL( settings );
       
  1038     iNotificationClient->RestoreSettingsL();
       
  1039     settings->CopyL( iNotificationClient->MmsSettings() );
       
  1040     TInt maxSize = static_cast<TInt>(settings->MaximumReceiveSize() );
       
  1041     CleanupStack::PopAndDestroy( settings );
       
  1042     return maxSize;
       
  1043 }
       
  1044 
  1013 // End of file
  1045 // End of file