messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp
--- a/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp Tue Jul 06 14:12:40 2010 +0300
+++ b/messagingapp/msgutils/unieditorutils/unieditorplugins/unieditormmsplugin/src/unieditormmsplugin_p.cpp Wed Aug 18 09:45:25 2010 +0300
@@ -43,6 +43,7 @@
#include "UniSendingSettings.h"
#include "unidatamodelloader.h"
#include "unidatamodelplugininterface.h"
+#include "msgcontacthandler.h"
#include <xqconversions.h>
#include "debugtraces.h"
#include "UniEditorGenUtils.h"
@@ -62,6 +63,7 @@
const TUid KSenduiMtmMmsUid = {KSenduiMtmMmsUidValue};
#define LOC_FWD hbTrId("txt_messaging_formlabel_fwd")
+#define LOC_RE hbTrId("txt_messaging_formlabel_re")
// -----------------------------------------------------------------------------
// Two-phased constructor.
@@ -139,6 +141,18 @@
{
convertFromForwardHandlerL(*msg);
}
+ else if(aOperation == UniEditorPluginInterface::Reply)
+ {
+ convertFromReplyHandlerL(msg);
+ }
+ else if(aOperation == UniEditorPluginInterface::ReplyAll)
+ {
+ convertFromReplyAllHandlerL(msg);
+ }
+ else if(aOperation == UniEditorPluginInterface::Default)
+ {
+ convertFromDefaultHandlerL(msg);
+ }
CleanupStack::Pop(msg);
QDEBUG_WRITE("Exit convertFromL");
return msg;
@@ -275,11 +289,18 @@
if( slideContentList.at(i)->mimetype().contains("text") )
{
QString textContent;
+ QByteArray textArray;
QFile file(slideContentList.at(i)->path());
if (file.open(QIODevice::ReadOnly)) {
- textContent = file.readAll();
+ textArray = file.readAll();
+ char *data = new char[textArray.size()+1];
+ strcpy(data,textArray.data());
+ //This is needed since MMS text content
+ //is stored in UTF8 format
+ textContent = textContent.fromUtf8(data,strlen(data));
aMessage.setBodyText(textContent);
file.close();
+ delete []data;
}
else {
return;
@@ -945,7 +966,7 @@
{
}
-
+// -----------------------------------------------------------------------------
// HandleSessionEventL
// @see Header
// -----------------------------------------------------------------------------
@@ -957,4 +978,202 @@
// do nothing
}
+// -----------------------------------------------------------------------------
+// populateSenderL
+// @see Header
+// -----------------------------------------------------------------------------
+//
+void CUniEditorMmsPluginPrivate::populateSenderL(
+ ConvergedMessage& aMessage)
+ {
+ // get sender address
+ HBufC* fromAddress = (MmsMtmL()->Sender()).AllocLC();
+ HBufC* pureAddr = TMmsGenUtils::PureAddress(*fromAddress).AllocLC();
+ HBufC* aliasAddr = TMmsGenUtils::Alias(*fromAddress).AllocLC();
+
+ if(pureAddr->Length() > 0)
+ {
+ ConvergedMessageAddress messageAddress(
+ XQConversions::s60DescToQString(*pureAddr),
+ XQConversions::s60DescToQString(*aliasAddr));
+ aMessage.addToRecipient(messageAddress);
+ }
+ CleanupStack::PopAndDestroy(3, fromAddress );
+ }
+
+// -----------------------------------------------------------------------------
+// convertFromReplyHandlerL
+// @see Header
+// -----------------------------------------------------------------------------
+//
+void CUniEditorMmsPluginPrivate::convertFromReplyHandlerL(
+ ConvergedMessage* aMessage)
+ {
+ // for received mms, populate sender address into To-field
+ // for sent mms, populate recipients into To-field
+ TMsvEntry entry = MmsMtmL()->Entry().Entry();
+ if( entry.Parent() == KMsvGlobalInBoxIndexEntryIdValue )
+ {
+ populateSenderL(*aMessage);
+ }
+ else
+ {
+ populateRecipientsL(*aMessage);
+ }
+
+ // resolve contacts
+ ConvergedMessageAddressList addrList = aMessage->toAddressList();
+ int addrCount = addrList.count();
+ for(int i=0; i<addrCount; i++)
+ {
+ ConvergedMessageAddress* addr = addrList.at(i);
+ // resolve contact if alias is empty
+ if(addr->alias().isEmpty())
+ {
+ QString alias;
+ int count;
+ int localId =
+ MsgContactHandler::resolveContactDisplayName(
+ addr->address(), alias, count);
+ addr->setAlias(alias);
+ }
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// convertFromReplyAllHandlerL
+// @see Header
+// -----------------------------------------------------------------------------
+//
+void CUniEditorMmsPluginPrivate::convertFromReplyAllHandlerL(
+ ConvergedMessage* aMessage)
+ {
+ // populate all recipients (and sender for received mms)
+ TMsvEntry entry = MmsMtmL()->Entry().Entry();
+ if( entry.Parent() == KMsvGlobalInBoxIndexEntryIdValue )
+ {
+ populateSenderL(*aMessage);
+ }
+ populateRecipientsL(*aMessage);
+
+ // resolve to-field contacts
+ ConvergedMessageAddressList addrList = aMessage->toAddressList();
+ int addrCount = addrList.count();
+ for(int i=0; i<addrCount; i++)
+ {
+ ConvergedMessageAddress* addr = addrList.at(i);
+ // resolve contact if alias is empty
+ if(addr->alias().isEmpty())
+ {
+ QString alias;
+ int count;
+ int localId =
+ MsgContactHandler::resolveContactDisplayName(
+ addr->address(), alias, count);
+ addr->setAlias(alias);
+ }
+ }
+
+ // resolve cc-field contacts
+ addrList = aMessage->ccAddressList();
+ addrCount = addrList.count();
+ for(int i=0; i<addrCount; i++)
+ {
+ ConvergedMessageAddress* addr = addrList.at(i);
+ // resolve contact if alias is empty
+ if(addr->alias().isEmpty())
+ {
+ QString alias;
+ int count;
+ int localId =
+ MsgContactHandler::resolveContactDisplayName(
+ addr->address(), alias, count);
+ addr->setAlias(alias);
+ }
+ }
+
+ // resolve bcc-field contacts
+ addrList = aMessage->bccAddressList();
+ addrCount = addrList.count();
+ for(int i=0; i<addrCount; i++)
+ {
+ ConvergedMessageAddress* addr = addrList.at(i);
+ // resolve contact if alias is empty
+ if(addr->alias().isEmpty())
+ {
+ QString alias;
+ int count;
+ int localId =
+ MsgContactHandler::resolveContactDisplayName(
+ addr->address(), alias, count);
+ addr->setAlias(alias);
+ }
+ }
+
+ // populate the subject field
+ QString subject = XQConversions::s60DescToQString(
+ MmsMtmL()->SubjectL());
+ if(!subject.startsWith(LOC_RE, Qt::CaseInsensitive))
+ {
+ subject.insert(0, LOC_RE);
+ }
+ aMessage->setSubject(subject);
+ }
+
+// -----------------------------------------------------------------------------
+// convertFromDefaultHandlerL
+// @see Header
+// -----------------------------------------------------------------------------
+void CUniEditorMmsPluginPrivate::convertFromDefaultHandlerL(ConvergedMessage* aMessage)
+{
+ QDEBUG_WRITE("Enter convertFromDefaultHandlerL");
+
+ TMsvEntry entry = MmsMtmL()->Entry().Entry();
+
+ if( entry.Parent() == KMsvGlobalInBoxIndexEntryIdValue )
+ {
+ // get sender address
+ HBufC* fromAddress = (MmsMtmL()->Sender()).AllocLC();
+ HBufC* pureAddr = TMmsGenUtils::PureAddress(*fromAddress).AllocLC();
+ HBufC* aliasAddr = TMmsGenUtils::Alias(*fromAddress).AllocLC();
+
+ if(pureAddr->Length() > 0)
+ {
+ ConvergedMessageAddress messageAddress(
+ XQConversions::s60DescToQString(*pureAddr),
+ XQConversions::s60DescToQString(*aliasAddr));
+ aMessage->addFromRecipient(messageAddress);
+ }
+ CleanupStack::PopAndDestroy(3, fromAddress );
+ }
+ else
+ {
+ populateRecipientsL(*aMessage);
+ }
+
+ //populate convergedmessage with the subject prepended with FW:
+ QString subject = XQConversions::s60DescToQString(MmsMtmL()->SubjectL());
+ aMessage->setSubject(subject);
+
+ // Priority
+ TMsvPriority priority = entry.Priority();
+ if( EMsvHighPriority == priority )
+ {
+ aMessage->setPriority(ConvergedMessage::High);
+ }
+ else if( EMsvLowPriority == priority )
+ {
+ aMessage->setPriority(ConvergedMessage::Low);
+ }
+ else if( EMsvMediumPriority == priority )
+ {
+ aMessage->setPriority(ConvergedMessage::Normal);
+ }
+
+ //Populate body and attachments
+ //The region info inside slides is not maintained
+ populateMessageBodyL(*aMessage);
+
+ QDEBUG_WRITE("Exit convertFromDefaultHandlerL");
+}
// End of File