--- a/messagingapp/msgui/conversationview/src/msgconversationview.cpp Tue Jul 06 14:12:40 2010 +0300
+++ b/messagingapp/msgui/conversationview/src/msgconversationview.cpp Wed Aug 18 09:45:25 2010 +0300
@@ -58,6 +58,8 @@
#include "mmsconformancecheck.h"
#include "msgsettingsview.h"
#include "msgaudiofetcherview.h"
+#include "unieditorpluginloader.h"
+#include "unieditorplugininterface.h"
//Item specific menu.
@@ -69,6 +71,7 @@
#define LOC_COMMON_SAVE hbTrId("txt_common_menu_save")
#define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
+#define LOC_DELETE_SHARED_MESSAGE hbTrId("txt_messaging_dialog_same_message_exists_in_multip")
#define LOC_SAVE_TO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
//main menu
@@ -80,8 +83,9 @@
#define LOC_ADD_SUBJECT hbTrId("txt_messaging_opt_add_subject")
#define LOC_MSG_SEND_FAILED hbTrId("txt_messaging_dialog_message_sending_failed")
-#define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_settings_incomplete")
+#define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e")
#define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
+#define LOC_MMS_RETRIEVAL_FAILED hbTrId("txt_messaging_dialog_mms_retrieval_failed")
const int INVALID_MSGID = -1;
@@ -103,7 +107,6 @@
mSendUtil(NULL),
mVkbHost(NULL),
mVisibleIndex(),
- mVkbopened(false),
mModelPopulated(false),
mViewReady(false)
{
@@ -274,48 +277,23 @@
// MsgConversationView::longPressed
// @see header file
//---------------------------------------------------------------
-void MsgConversationView::longPressed(HbAbstractViewItem* viewItem,
- const QPointF& point)
-{
- MsgConversationViewItem* item = qgraphicsitem_cast<
- MsgConversationViewItem *> (viewItem);
-
- // Show the item-specific menu
- if (this->isVisible())
- {
- //If message is in Sending state or is Scheduled to be sent later,
- //do not allow any operations on the message
- int sendingState = item->modelIndex().data(SendingState).toInt();
- if(sendingState == ConvergedMessage::Scheduled ||
- sendingState == ConvergedMessage::Sending ||
- sendingState == ConvergedMessage::Waiting)
- {
- return;
- }
- // Create new menu
- HbMenu* contextMenu = new HbMenu();
- contextMenu->setAttribute(Qt::WA_DeleteOnClose);
- contextMenu->setPreferredPos(point);
- setContextMenu(item, contextMenu, sendingState);
- contextMenu->show();
-
- }
-
+void MsgConversationView::longPressed(HbAbstractViewItem* viewItem, const QPointF& point)
+{
+ showContextMenu(viewItem,point,HbPopup::TopLeftCorner);
}
//---------------------------------------------------------------
// MsgConversationView::setContextMenu
// @see header
//---------------------------------------------------------------
-
void MsgConversationView::setContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState)
{
addOpenItemToContextMenu(item , contextMenu,sendingState);
addResendItemToContextMenu(item, contextMenu, sendingState);
addForwardItemToContextMenu(item, contextMenu, sendingState);
addDownloadItemToContextMenu(item, contextMenu);
+ addSaveItemToContextMenu(item , contextMenu,sendingState);
addDeleteItemToContextMenu(item, contextMenu, sendingState);
- addSaveItemToContextMenu(item , contextMenu,sendingState);
}
@@ -358,10 +336,11 @@
(direction == ConvergedMessage::Incoming))
{
HbAction *contextItem = contextMenu->addAction(LOC_SAVE_TO_CONTACTS);
- connect(contextItem, SIGNAL(triggered()),this, SLOT(openItem()));
+ connect(contextItem, SIGNAL(triggered()),this, SLOT(saveVCard()));
return;
}
- if( (sendingState == ConvergedMessage::SentState ) ||
+ if( (sendingState == ConvergedMessage::SentState &&
+ messageSubType != ConvergedMessage::VCard) ||
(direction == ConvergedMessage::Incoming))
{
HbAction *contextItem = contextMenu->addAction(LOC_COMMON_OPEN);
@@ -379,10 +358,13 @@
{
Q_UNUSED(item)
int direction = item->modelIndex().data(Direction).toInt();
+ int messageSubType = item->modelIndex().data(MessageSubType).toInt();
- if( (direction == ConvergedMessage::Outgoing)&&
+
+ if( ((direction == ConvergedMessage::Outgoing) &&
+ (messageSubType != ConvergedMessage::VCard))&&
((sendingState == ConvergedMessage::Resend ) ||
- (sendingState == ConvergedMessage::Suspended )||
+
(sendingState == ConvergedMessage::Failed )))
{
HbAction *contextItem = contextMenu->addAction(LOC_COMMON_SEND);
@@ -420,6 +402,7 @@
if( ((sendingState == ConvergedMessage::SentState) ||
(sendingState == ConvergedMessage::Resend) ||
(sendingState == ConvergedMessage::Failed) ||
+ (sendingState == ConvergedMessage::Suspended )||
(direction == ConvergedMessage::Incoming) ) &&
canForwardMessage)
{
@@ -639,16 +622,11 @@
//---------------------------------------------------------------
void MsgConversationView::contactsFetched(const QVariant& value)
{
- CntServicesContactList contactList =
- qVariantValue<CntServicesContactList>(value);
- int count = contactList.count();
- if(count > 0)
- {
- QVariantList params;
- params << MsgBaseView::ADD_RECIPIENTS;
- params << value;
- launchUniEditor(params);
- }
+ //switch to editor.
+ QVariantList params;
+ params << MsgBaseView::ADD_RECIPIENTS;
+ params << value;
+ launchUniEditor(params);
}
//---------------------------------------------------------------
@@ -722,7 +700,7 @@
qint32 messageId = index.data(ConvergedMsgId).toLongLong();
if(!(ConversationsEngine::instance()->resendMessage(messageId)))
{
- HbMessageBox::warning(LOC_MSG_SEND_FAILED);
+ HbMessageBox::warning(LOC_MSG_SEND_FAILED, 0, 0, HbMessageBox::Ok);
}
}
@@ -737,10 +715,10 @@
QModelIndex index = mConversationList->currentIndex();
if(index.isValid())
{
- qint32 messageId = index.data(ConvergedMsgId).toLongLong();
+ qint32 messageId = index.data(ConvergedMsgId).toLongLong();
if(ConversationsEngine::instance()->downloadMessage(messageId)!=KErrNone)
{
- HbMessageBox::warning("Message Retrieval Failed!"); //TODO: use logical str name
+ HbMessageBox::warning(LOC_MMS_RETRIEVAL_FAILED, 0, 0, HbMessageBox::Ok);
}
}
@@ -751,8 +729,29 @@
// Deletes the message
//---------------------------------------------------------------
void MsgConversationView::deleteItem()
+{
+ QString str = LOC_DELETE_MESSAGE;
+
+ QModelIndex index = mConversationList->currentIndex();
+ if(index.isValid())
{
- HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogdeleteMsg(HbAction*)),
+ int messageType = index.data(MessageType).toInt();
+ int direction = index.data(Direction).toInt();
+
+ if ( direction == ConvergedMessage::Outgoing &&
+ messageType == ConvergedMessage::Mms )
+ {
+ qint32 messageId = index.data(ConvergedMsgId).toLongLong();
+
+ if(isSharedMessage(messageId))
+ {
+ str = LOC_DELETE_SHARED_MESSAGE;
+ }
+ }
+ }
+
+
+ HbMessageBox::question(str,this,SLOT(onDialogdeleteMsg(HbAction*)),
HbMessageBox::Delete | HbMessageBox::Cancel);
}
@@ -887,7 +886,7 @@
void MsgConversationView::openItem(const QModelIndex & index)
{
// Return if invalid index.
- if (!index.isValid() || mVkbopened)
+ if (!index.isValid())
{
return;
}
@@ -920,20 +919,7 @@
}
else if(ConvergedMessage::VCard == messageSubType)
{
- QString filepath = index.data(Attachments).toStringList().at(0);
- bool result = MsgContactsUtil::launchVCardViewer(filepath);
- if(result)
- {
-
- int messageId = index.data(ConvergedMsgId).toInt();
- QList<int> msgIdList;
- if(index.data(UnReadStatus).toInt())
- {
- msgIdList.clear();
- msgIdList << messageId;
- ConversationsEngine::instance()->markMessagesRead(msgIdList);
- }
- }
+ handleShortTap();
return;
}
else if(ConvergedMessage::VCal == messageSubType)
@@ -955,7 +941,7 @@
}
else if(ConvergedMessage::MmsNotification == messageType)
{
- qint32 messageId = index.data(ConvergedMsgId).toLongLong();
+ qint32 messageId = index.data(ConvergedMsgId).toLongLong();
if(!ConversationsEngine::instance()->downloadOperationSupported(messageId))
{
int notificationState = index.data(NotificationStatus).toInt();
@@ -987,6 +973,15 @@
int location = index.data(MessageLocation).toInt();
int sendingState = index.data(SendingState).toInt();
+ // For suspended message both short tap and long tap needs to show the same
+ // context menu.....
+ if(direction == ConvergedMessage::Outgoing
+ &&sendingState == ConvergedMessage::Suspended )
+ {
+ handleShortTap();
+ return;
+ }
+
//If message is in any other state other than 'Sent'
//do not open the message
if(direction == ConvergedMessage::Outgoing
@@ -1009,14 +1004,7 @@
msgIdList << messageId;
ConversationsEngine::instance()->markMessagesRead(msgIdList);
}
-
- qint32 messageProperty = index.data(MessageProperty).toInt();
- bool canForwardMessage = true;
- if (messageType == ConvergedMessage::Mms){
- canForwardMessage = (messageProperty & EPreviewForward)? true:false;
- }
-
//switch view
QVariantList param;
param << MsgBaseView::UNIVIEWER; // target view
@@ -1025,14 +1013,6 @@
param << contactId;
param << messageId;
param << mMessageModel->rowCount();
- if (canForwardMessage == true)
- {
- param << 1;
- }
- else
- {
- param << 0;
- }
emit switchView(param);
}
@@ -1194,9 +1174,9 @@
//---------------------------------------------------------------
void MsgConversationView::vkbOpened()
{
- mVkbopened = true;
+ emit vkbOpened(true);
- emit vkbOpened(true);
+ scrollToBottom();
QRectF appRect = mVkbHost->applicationArea();
qreal spacing = 0.0;
@@ -1208,10 +1188,10 @@
}
this->setMaximumHeight(appRect.height()- cardHeight - spacing);
+ mConversationList->adjustSize();
disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
-
- scrollToBottom();
+
}
//---------------------------------------------------------------
@@ -1220,14 +1200,14 @@
//---------------------------------------------------------------
void MsgConversationView::vkbClosed()
{
- mVkbopened = false;
-
emit vkbOpened(false);
+ scrollToBottom();
+
this->setMaximumHeight(-1);
+ mConversationList->adjustSize();
+
connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
-
- scrollToBottom();
}
//---------------------------------------------------------------
@@ -1346,6 +1326,17 @@
if (action == dlg->actions().at(0)) {
downloadMessage();
}
+
+ //if message unread, mark as read now
+ QModelIndex index = mConversationList->currentIndex();
+ qint32 messageId = index.data(ConvergedMsgId).toLongLong();
+ QList<int> msgIdList;
+ if(index.data(UnReadStatus).toInt())
+ {
+ msgIdList.clear();
+ msgIdList << messageId;
+ ConversationsEngine::instance()->markMessagesRead(msgIdList);
+ }
}
//---------------------------------------------------------------
@@ -1402,4 +1393,99 @@
fetchMoreConversations();
}
+
+//---------------------------------------------------------------
+// MsgConversationView::handleShortTap
+// @see header file
+//---------------------------------------------------------------
+void MsgConversationView::handleShortTap()
+{
+ HbAbstractViewItem* item = mConversationList->currentViewItem();
+ QRectF rc = item->rect();
+ QPointF p = item->mapToScene(rc.center());
+
+ showContextMenu(item,p,HbPopup::TopEdgeCenter);
+}
+
+//---------------------------------------------------------------
+// MsgConversationView::handleShortTap
+// @see header file
+//---------------------------------------------------------------
+void MsgConversationView::showContextMenu(HbAbstractViewItem* viewItem,const QPointF& point, int placement)
+{
+ MsgConversationViewItem* item = qgraphicsitem_cast<MsgConversationViewItem *>(viewItem);
+
+ // Show the item-specific menu
+ if (this->isVisible())
+ {
+ //If message is in Sending state or is Scheduled to be sent later,
+ //do not allow any operations on the message
+ int sendingState = item->modelIndex().data(SendingState).toInt();
+
+ if(sendingState == ConvergedMessage::Scheduled ||
+ sendingState == ConvergedMessage::Sending ||
+ sendingState == ConvergedMessage::Waiting)
+ {
+ return;
+ }
+ // Create new menu
+ HbMenu* contextMenu = new HbMenu();
+ contextMenu->setAttribute(Qt::WA_DeleteOnClose);
+ contextMenu->setPreferredPos(point,HbPopup::Placement(placement));
+ setContextMenu(item, contextMenu, sendingState);
+ contextMenu->show();
+ }
+}
+
+//---------------------------------------------------------------
+// MsgConversationView::saveVCard
+// @see header file
+//---------------------------------------------------------------
+void MsgConversationView::saveVCard()
+{
+ QModelIndex index = mConversationList->currentIndex();
+
+ QString filepath = index.data(Attachments).toStringList().at(0);
+ bool result = MsgContactsUtil::launchVCardViewer(filepath);
+ if(result)
+ {
+ int messageId = index.data(ConvergedMsgId).toInt();
+ QList<int> msgIdList;
+ if(index.data(UnReadStatus).toInt())
+ {
+ msgIdList.clear();
+ msgIdList << messageId;
+ ConversationsEngine::instance()->markMessagesRead(msgIdList);
+ }
+ }
+}
+
+//---------------------------------------------------------------
+// MsgConversationView::isSharedMessage
+// @see header file
+//---------------------------------------------------------------
+bool MsgConversationView::isSharedMessage(qint32 messageId)
+{
+ bool shared = false;
+
+ UniDataModelLoader* pluginLoader = new UniDataModelLoader();
+
+ UniDataModelPluginInterface* pluginInterface =
+ pluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
+
+ CMsvSession* session = pluginInterface->session();
+
+ TMsvEntry entry;
+ TMsvId service;
+ session->GetEntry(messageId, service, entry);
+
+ if(entry.MultipleRecipients())
+ {
+ shared = true;
+ }
+ delete pluginLoader;
+
+ return shared;
+}
+
// EOF