messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp
changeset 52 12db4185673b
parent 44 36f374c67aa8
child 70 a15d9966050f
equal deleted inserted replaced
44:36f374c67aa8 52:12db4185673b
    41 #include <MsgMediaResolver.h>
    41 #include <MsgMediaResolver.h>
    42 
    42 
    43 #include "UniSendingSettings.h"
    43 #include "UniSendingSettings.h"
    44 #include "unidatamodelloader.h"
    44 #include "unidatamodelloader.h"
    45 #include "unidatamodelplugininterface.h"
    45 #include "unidatamodelplugininterface.h"
       
    46 #include "msgcontacthandler.h"
    46 #include <xqconversions.h>
    47 #include <xqconversions.h>
    47 #include "debugtraces.h"
    48 #include "debugtraces.h"
    48 #include "UniEditorGenUtils.h"
    49 #include "UniEditorGenUtils.h"
    49 
    50 
    50 // Possible values for mms validity period in seconds
    51 // Possible values for mms validity period in seconds
    60 
    61 
    61 #define KSenduiMtmMmsUidValue 0x100058E1
    62 #define KSenduiMtmMmsUidValue 0x100058E1
    62 const TUid KSenduiMtmMmsUid = {KSenduiMtmMmsUidValue};
    63 const TUid KSenduiMtmMmsUid = {KSenduiMtmMmsUidValue};
    63 
    64 
    64 #define LOC_FWD hbTrId("txt_messaging_formlabel_fwd")
    65 #define LOC_FWD hbTrId("txt_messaging_formlabel_fwd")
       
    66 #define LOC_RE hbTrId("txt_messaging_formlabel_re")
    65 
    67 
    66 // -----------------------------------------------------------------------------
    68 // -----------------------------------------------------------------------------
    67 // Two-phased constructor.
    69 // Two-phased constructor.
    68 // @see Header
    70 // @see Header
    69 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
   136        convertFromDraftsL(*msg);
   138        convertFromDraftsL(*msg);
   137     }
   139     }
   138     else if( aOperation == UniEditorPluginInterface::Forward)
   140     else if( aOperation == UniEditorPluginInterface::Forward)
   139     {
   141     {
   140         convertFromForwardHandlerL(*msg);          
   142         convertFromForwardHandlerL(*msg);          
       
   143     }
       
   144     else if(aOperation == UniEditorPluginInterface::Reply)
       
   145     {
       
   146         convertFromReplyHandlerL(msg);
       
   147     }
       
   148     else if(aOperation == UniEditorPluginInterface::ReplyAll)
       
   149     {
       
   150         convertFromReplyAllHandlerL(msg);
       
   151     }
       
   152     else if(aOperation == UniEditorPluginInterface::Default)
       
   153     {
       
   154         convertFromDefaultHandlerL(msg);
   141     }
   155     }
   142     CleanupStack::Pop(msg);
   156     CleanupStack::Pop(msg);
   143     QDEBUG_WRITE("Exit convertFromL");
   157     QDEBUG_WRITE("Exit convertFromL");
   144     return msg;
   158     return msg;
   145 }
   159 }
   273         for (int i = 0; i < slideContentList.size(); ++i)
   287         for (int i = 0; i < slideContentList.size(); ++i)
   274         {
   288         {
   275             if( slideContentList.at(i)->mimetype().contains("text") )
   289             if( slideContentList.at(i)->mimetype().contains("text") )
   276             {
   290             {
   277                 QString textContent;
   291                 QString textContent;
       
   292                 QByteArray textArray;
   278                 QFile file(slideContentList.at(i)->path());
   293                 QFile file(slideContentList.at(i)->path());
   279                 if (file.open(QIODevice::ReadOnly)) {
   294                 if (file.open(QIODevice::ReadOnly)) {
   280                     textContent = file.readAll();
   295                     textArray = file.readAll();
       
   296                     char *data = new char[textArray.size()+1];
       
   297                     strcpy(data,textArray.data());
       
   298                     //This is needed since MMS text content 
       
   299                     //is stored in UTF8 format
       
   300                     textContent = textContent.fromUtf8(data,strlen(data));
   281                     aMessage.setBodyText(textContent);
   301                     aMessage.setBodyText(textContent);
   282                     file.close();
   302                     file.close();
       
   303                     delete []data;
   283                 }
   304                 }
   284                 else {
   305                 else {
   285                     return;
   306                     return;
   286                 }
   307                 }
   287             }
   308             }
   943 //
   964 //
   944 void CUniEditorMmsPluginPrivate::RestoreReady(TInt /*aParseResult*/, TInt /*aError*/)
   965 void CUniEditorMmsPluginPrivate::RestoreReady(TInt /*aParseResult*/, TInt /*aError*/)
   945 {
   966 {
   946 }
   967 }
   947 
   968 
   948 
   969 // -----------------------------------------------------------------------------
   949 // HandleSessionEventL
   970 // HandleSessionEventL
   950 // @see Header
   971 // @see Header
   951 // -----------------------------------------------------------------------------
   972 // -----------------------------------------------------------------------------
   952 //
   973 //
   953 void CUniEditorMmsPluginPrivate::HandleSessionEventL(TMsvSessionEvent /*aEvent*/,
   974 void CUniEditorMmsPluginPrivate::HandleSessionEventL(TMsvSessionEvent /*aEvent*/,
   955                                                   TAny* /*aArg2*/, TAny* /*aArg3*/)
   976                                                   TAny* /*aArg2*/, TAny* /*aArg3*/)
   956 {
   977 {
   957 // do nothing
   978 // do nothing
   958 }
   979 }
   959 
   980 
       
   981 // -----------------------------------------------------------------------------
       
   982 // populateSenderL
       
   983 // @see Header
       
   984 // -----------------------------------------------------------------------------
       
   985 //
       
   986 void CUniEditorMmsPluginPrivate::populateSenderL(
       
   987         ConvergedMessage& aMessage)
       
   988     {
       
   989     // get sender address    
       
   990     HBufC* fromAddress = (MmsMtmL()->Sender()).AllocLC();
       
   991     HBufC* pureAddr = TMmsGenUtils::PureAddress(*fromAddress).AllocLC();
       
   992     HBufC* aliasAddr = TMmsGenUtils::Alias(*fromAddress).AllocLC();
       
   993 
       
   994     if(pureAddr->Length() > 0)
       
   995         {
       
   996         ConvergedMessageAddress messageAddress(
       
   997                 XQConversions::s60DescToQString(*pureAddr),
       
   998                 XQConversions::s60DescToQString(*aliasAddr));
       
   999         aMessage.addToRecipient(messageAddress);
       
  1000         }
       
  1001     CleanupStack::PopAndDestroy(3, fromAddress );
       
  1002     }
       
  1003 
       
  1004 // -----------------------------------------------------------------------------
       
  1005 // convertFromReplyHandlerL
       
  1006 // @see Header
       
  1007 // -----------------------------------------------------------------------------
       
  1008 //
       
  1009 void CUniEditorMmsPluginPrivate::convertFromReplyHandlerL(
       
  1010         ConvergedMessage* aMessage)
       
  1011     {
       
  1012     // for received mms, populate sender address into To-field
       
  1013     // for sent mms, populate recipients into To-field
       
  1014     TMsvEntry entry = MmsMtmL()->Entry().Entry();
       
  1015     if( entry.Parent() == KMsvGlobalInBoxIndexEntryIdValue )
       
  1016         {
       
  1017         populateSenderL(*aMessage);
       
  1018         }
       
  1019     else
       
  1020         {
       
  1021         populateRecipientsL(*aMessage);
       
  1022         }
       
  1023     
       
  1024     // resolve contacts
       
  1025     ConvergedMessageAddressList addrList = aMessage->toAddressList();
       
  1026     int addrCount = addrList.count();
       
  1027     for(int i=0; i<addrCount; i++)
       
  1028         {
       
  1029         ConvergedMessageAddress* addr = addrList.at(i);
       
  1030         // resolve contact if alias is empty
       
  1031         if(addr->alias().isEmpty())
       
  1032             {
       
  1033             QString alias;
       
  1034             int count;
       
  1035             int localId =
       
  1036                     MsgContactHandler::resolveContactDisplayName(
       
  1037                             addr->address(), alias, count);
       
  1038             addr->setAlias(alias);
       
  1039             }
       
  1040         }
       
  1041     }
       
  1042 
       
  1043 // -----------------------------------------------------------------------------
       
  1044 // convertFromReplyAllHandlerL
       
  1045 // @see Header
       
  1046 // -----------------------------------------------------------------------------
       
  1047 //
       
  1048 void CUniEditorMmsPluginPrivate::convertFromReplyAllHandlerL(
       
  1049         ConvergedMessage* aMessage)
       
  1050     {
       
  1051     // populate all recipients (and sender for received mms)
       
  1052     TMsvEntry entry = MmsMtmL()->Entry().Entry();
       
  1053     if( entry.Parent() == KMsvGlobalInBoxIndexEntryIdValue )
       
  1054         {
       
  1055         populateSenderL(*aMessage);
       
  1056         }
       
  1057     populateRecipientsL(*aMessage);
       
  1058     
       
  1059     // resolve to-field contacts
       
  1060     ConvergedMessageAddressList addrList = aMessage->toAddressList();
       
  1061     int addrCount = addrList.count();
       
  1062     for(int i=0; i<addrCount; i++)
       
  1063         {
       
  1064         ConvergedMessageAddress* addr = addrList.at(i);
       
  1065         // resolve contact if alias is empty
       
  1066         if(addr->alias().isEmpty())
       
  1067             {
       
  1068             QString alias;
       
  1069             int count;
       
  1070             int localId =
       
  1071                     MsgContactHandler::resolveContactDisplayName(
       
  1072                             addr->address(), alias, count);
       
  1073             addr->setAlias(alias);
       
  1074             }
       
  1075         }
       
  1076 
       
  1077     // resolve cc-field contacts
       
  1078     addrList = aMessage->ccAddressList();
       
  1079     addrCount = addrList.count();
       
  1080     for(int i=0; i<addrCount; i++)
       
  1081         {
       
  1082         ConvergedMessageAddress* addr = addrList.at(i);
       
  1083         // resolve contact if alias is empty
       
  1084         if(addr->alias().isEmpty())
       
  1085             {
       
  1086             QString alias;
       
  1087             int count;
       
  1088             int localId =
       
  1089                     MsgContactHandler::resolveContactDisplayName(
       
  1090                             addr->address(), alias, count);
       
  1091             addr->setAlias(alias);
       
  1092             }
       
  1093         }
       
  1094 
       
  1095     // resolve bcc-field contacts
       
  1096     addrList = aMessage->bccAddressList();
       
  1097     addrCount = addrList.count();
       
  1098     for(int i=0; i<addrCount; i++)
       
  1099         {
       
  1100         ConvergedMessageAddress* addr = addrList.at(i);
       
  1101         // resolve contact if alias is empty
       
  1102         if(addr->alias().isEmpty())
       
  1103             {
       
  1104             QString alias;
       
  1105             int count;
       
  1106             int localId =
       
  1107                     MsgContactHandler::resolveContactDisplayName(
       
  1108                             addr->address(), alias, count);
       
  1109             addr->setAlias(alias);
       
  1110             }
       
  1111         }
       
  1112 
       
  1113     // populate the subject field
       
  1114     QString subject = XQConversions::s60DescToQString(
       
  1115             MmsMtmL()->SubjectL());
       
  1116     if(!subject.startsWith(LOC_RE, Qt::CaseInsensitive))
       
  1117         {
       
  1118         subject.insert(0, LOC_RE);
       
  1119         }
       
  1120     aMessage->setSubject(subject);
       
  1121     }
       
  1122 
       
  1123 // -----------------------------------------------------------------------------
       
  1124 // convertFromDefaultHandlerL
       
  1125 // @see Header
       
  1126 // -----------------------------------------------------------------------------
       
  1127 void CUniEditorMmsPluginPrivate::convertFromDefaultHandlerL(ConvergedMessage* aMessage)
       
  1128 {
       
  1129     QDEBUG_WRITE("Enter convertFromDefaultHandlerL");
       
  1130 
       
  1131     TMsvEntry entry = MmsMtmL()->Entry().Entry();
       
  1132     
       
  1133     if( entry.Parent() == KMsvGlobalInBoxIndexEntryIdValue )
       
  1134         {
       
  1135         // get sender address    
       
  1136         HBufC* fromAddress = (MmsMtmL()->Sender()).AllocLC();
       
  1137         HBufC* pureAddr = TMmsGenUtils::PureAddress(*fromAddress).AllocLC();
       
  1138         HBufC* aliasAddr = TMmsGenUtils::Alias(*fromAddress).AllocLC();
       
  1139 
       
  1140         if(pureAddr->Length() > 0)
       
  1141             {
       
  1142             ConvergedMessageAddress messageAddress(
       
  1143                     XQConversions::s60DescToQString(*pureAddr),
       
  1144                     XQConversions::s60DescToQString(*aliasAddr));
       
  1145             aMessage->addFromRecipient(messageAddress);
       
  1146             }
       
  1147         CleanupStack::PopAndDestroy(3, fromAddress );
       
  1148         }
       
  1149     else
       
  1150         {
       
  1151         populateRecipientsL(*aMessage);
       
  1152         }
       
  1153 
       
  1154     //populate convergedmessage with the subject prepended with FW:
       
  1155     QString subject = XQConversions::s60DescToQString(MmsMtmL()->SubjectL());
       
  1156     aMessage->setSubject(subject);
       
  1157 
       
  1158     // Priority
       
  1159     TMsvPriority priority = entry.Priority();
       
  1160     if( EMsvHighPriority == priority )
       
  1161     {
       
  1162         aMessage->setPriority(ConvergedMessage::High);
       
  1163     }
       
  1164     else if( EMsvLowPriority == priority )
       
  1165     {
       
  1166         aMessage->setPriority(ConvergedMessage::Low);
       
  1167     }
       
  1168     else if( EMsvMediumPriority == priority )
       
  1169     {
       
  1170         aMessage->setPriority(ConvergedMessage::Normal);
       
  1171     }
       
  1172 
       
  1173     //Populate body and attachments
       
  1174     //The region info inside slides is not maintained
       
  1175     populateMessageBodyL(*aMessage);
       
  1176     
       
  1177     QDEBUG_WRITE("Exit convertFromDefaultHandlerL");
       
  1178 }
   960 //  End of File
  1179 //  End of File