diff -r 36f374c67aa8 -r 12db4185673b messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp --- a/messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp Tue Jul 06 14:12:40 2010 +0300 +++ b/messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp Wed Aug 18 09:45:25 2010 +0300 @@ -26,6 +26,7 @@ #include #include #include +#include // USER INCLUDES #include "uniscrollarea.h" @@ -38,6 +39,7 @@ #include "conversationsengine.h" #include "debugtraces.h" #include "nativemessageconsts.h" +#include "mmsconformancecheck.h" // LOCAL CONSTANTS const QString REPLY_ICON("qtg_mono_reply"); @@ -46,17 +48,23 @@ const QString SEND_ICON("qtg_mono_send"); const QString DELETE_ICON("qtg_mono_delete"); +//DB-file +_LIT(KDbFileName, "c:[2002A542]conversations.db"); +// query to see if msg is forwardable +_LIT(KSelectMsgPropertyStmt, " SELECT message_id, msg_property FROM conversation_messages WHERE message_id=:message_id "); + + //LOCALIZED CONSTANTS #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") +#define LOC_DELETE_SHARED_MESSAGE hbTrId("txt_messaging_dialog_same_message_exists_in_multip") //---------------------------------------------------------------------------- // UnifiedViewer::UnifiedViewer // constructor //---------------------------------------------------------------------------- -UnifiedViewer::UnifiedViewer(const qint32 messageId, - int canForwardMessage, +UnifiedViewer::UnifiedViewer(const qint32 messageId, QGraphicsItem *parent) : - MsgBaseView(parent), mForwardMessage(false) + MsgBaseView(parent) { QDEBUG_WRITE("UnifiedViewer contruction start"); @@ -68,8 +76,6 @@ mMessageId = messageId; mViewFeeder = new UniViewerFeeder(mMessageId, this); - if (canForwardMessage > 0) mForwardMessage = true; - mScrollArea = new UniScrollArea(this); this->setWidget(mScrollArea); @@ -114,15 +120,19 @@ } else { - toolbar->addAction(HbIcon(REPLY_ICON), ""); + // do not show reply option for multi recipient outgoing message + if(!(!mViewFeeder->isIncoming() && mViewFeeder->recipientCount()>1)) + { + toolbar->addAction(HbIcon(REPLY_ICON), "", this, SLOT(handleReplyAction())); + } if (mViewFeeder->recipientCount() > 1) { - toolbar->addAction(HbIcon(REPLY_ALL_ICON), ""); + toolbar->addAction(HbIcon(REPLY_ALL_ICON), "", this, SLOT(handleReplyAllAction())); } } - if (mForwardMessage) + if (isForwardOk()) { toolbar->addAction(HbIcon(FORWARD_ICON), "", this, SLOT(handleFwdAction())); } @@ -183,7 +193,7 @@ //Creation of toolbar now depends on content createToolBar(); - + QDEBUG_WRITE("UnifiedViewer populateContent END"); } @@ -193,31 +203,25 @@ //--------------------------------------------------------------- void UnifiedViewer::handleFwdAction() { - ConvergedMessage message; - ConvergedMessageId id(mMessageId); - message.setMessageId(id); - if(mViewFeeder->msgType() == KSenduiMtmMmsUidValue) - { - message.setMessageType(ConvergedMessage::Mms); - } - else - { - message.setMessageType(ConvergedMessage::Sms); - } + launchEditor(MsgBaseView::FORWARD_MSG); +} - QByteArray dataArray; - QDataStream messageStream - (&dataArray, QIODevice::WriteOnly | QIODevice::Append); - message.serialize(messageStream); +//--------------------------------------------------------------- +// UnifiedViewer::handleReplyAction +// @see header file +//--------------------------------------------------------------- +void UnifiedViewer::handleReplyAction() +{ + launchEditor(MsgBaseView::REPLY_MSG); +} - QVariantList params; - params << MsgBaseView::UNIEDITOR; // target view - params << MsgBaseView::UNIVIEWER; // source view - - params << dataArray; - params << MsgBaseView::FORWARD_MSG; - - emit switchView(params); +//--------------------------------------------------------------- +// UnifiedViewer::handleReplyAllAction +// @see header file +//--------------------------------------------------------------- +void UnifiedViewer::handleReplyAllAction() +{ + launchEditor(MsgBaseView::REPLY_ALL_MSG); } //--------------------------------------------------------------- @@ -236,8 +240,18 @@ //--------------------------------------------------------------- void UnifiedViewer::handleDeleteAction() { - HbMessageBox::question(LOC_DELETE_MESSAGE,this, - SLOT(onDialogDeleteMsg(HbAction*)), + QString txt = LOC_DELETE_MESSAGE; + + //if mms and out going. check for sharing + if((mViewFeeder->msgType() == KSenduiMtmMmsUidValue) && (!mViewFeeder->isIncoming())) + { + if(mViewFeeder->recipientCount() > 1 ) + { + txt = LOC_DELETE_SHARED_MESSAGE; + } + } + + HbMessageBox::question(txt,this,SLOT(onDialogDeleteMsg(int)), HbMessageBox::Delete | HbMessageBox::Cancel); } @@ -272,10 +286,9 @@ // UnifiedViewer::onDialogDeleteMsg // @see header file //--------------------------------------------------------------- -void UnifiedViewer::onDialogDeleteMsg(HbAction* action) +void UnifiedViewer::onDialogDeleteMsg(int val) { - HbMessageBox *dlg = qobject_cast (sender()); - if (action == dlg->actions().at(0)) { + if (val == HbMessageBox::Delete) { QList msgIdList; msgIdList << mMessageId; @@ -297,4 +310,81 @@ } } +//--------------------------------------------------------------- +// UnifiedViewer::launchEditor +// @see header file +//--------------------------------------------------------------- +void UnifiedViewer::launchEditor( + MsgBaseView::UniEditorOperation operation) +{ + ConvergedMessage message; + ConvergedMessageId id(mMessageId); + message.setMessageId(id); + if(mViewFeeder->msgType() == KSenduiMtmMmsUidValue) + { + message.setMessageType(ConvergedMessage::Mms); + } + else + { + message.setMessageType(ConvergedMessage::Sms); + } + + QByteArray dataArray; + QDataStream messageStream + (&dataArray, QIODevice::WriteOnly | QIODevice::Append); + message.serialize(messageStream); + + QVariantList params; + params << MsgBaseView::UNIEDITOR; // target view + params << MsgBaseView::UNIVIEWER; // source view + + params << dataArray; + params << operation; + + emit switchView(params); +} + +//--------------------------------------------------------------- +// UnifiedViewer::isForwardOk +// @see header file +//--------------------------------------------------------------- +bool UnifiedViewer::isForwardOk() +{ + bool canForwardMsg = true; + if(mViewFeeder->msgType() == KSenduiMtmMmsUidValue) + { + // open DB + RSqlDatabase sqlDb; + TInt error = sqlDb.Open(KDbFileName); + if(error == KErrNone) + { + RSqlStatement sqlSelectStmt; + CleanupClosePushL(sqlSelectStmt); + sqlSelectStmt.PrepareL(sqlDb,KSelectMsgPropertyStmt); + TInt msgIdIndex = sqlSelectStmt.ParameterIndex(_L(":message_id")); + sqlSelectStmt.BindInt(msgIdIndex, mMessageId); + // read the flag + TInt msgPropertyIndex = + sqlSelectStmt.ColumnIndex(_L("msg_property")); + TInt retValue = 0; + if (sqlSelectStmt.Next() == KSqlAtRow) + { + retValue = static_cast + (sqlSelectStmt.ColumnInt(msgPropertyIndex)); + } + CleanupStack::PopAndDestroy(&sqlSelectStmt); + sqlDb.Close(); + canForwardMsg = (retValue & EPreviewForward)? true:false; + } + else + { + // fall-back plan + MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck; + canForwardMsg = mmsConformanceCheck->validateMsgForForward(mMessageId); + delete mmsConformanceCheck; + } + } + return canForwardMsg; +} + // EOF