messagingapp/msgui/conversationview/src/msgconversationview.cpp
changeset 52 12db4185673b
parent 44 36f374c67aa8
child 70 a15d9966050f
equal deleted inserted replaced
44:36f374c67aa8 52:12db4185673b
    56 #include "unidatamodelplugininterface.h"
    56 #include "unidatamodelplugininterface.h"
    57 #include "ringbc.h"
    57 #include "ringbc.h"
    58 #include "mmsconformancecheck.h"
    58 #include "mmsconformancecheck.h"
    59 #include "msgsettingsview.h"
    59 #include "msgsettingsview.h"
    60 #include "msgaudiofetcherview.h"
    60 #include "msgaudiofetcherview.h"
       
    61 #include "unieditorpluginloader.h"
       
    62 #include "unieditorplugininterface.h"
    61 
    63 
    62 //Item specific menu.
    64 //Item specific menu.
    63 
    65 
    64 #define LOC_COMMON_OPEN hbTrId("txt_common_menu_open")
    66 #define LOC_COMMON_OPEN hbTrId("txt_common_menu_open")
    65 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete")
    67 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete")
    67 #define LOC_COMMON_DOWNLOAD hbTrId("txt_messaging_menu_download")
    69 #define LOC_COMMON_DOWNLOAD hbTrId("txt_messaging_menu_download")
    68 #define LOC_COMMON_SEND  hbTrId("txt_common_button_send") 
    70 #define LOC_COMMON_SEND  hbTrId("txt_common_button_send") 
    69 #define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
    71 #define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
    70 
    72 
    71 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
    73 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
       
    74 #define LOC_DELETE_SHARED_MESSAGE hbTrId("txt_messaging_dialog_same_message_exists_in_multip")
    72 #define LOC_SAVE_TO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
    75 #define LOC_SAVE_TO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
    73 
    76 
    74 //main menu
    77 //main menu
    75 #define LOC_ATTACH          hbTrId("txt_messaging_opt_attach")
    78 #define LOC_ATTACH          hbTrId("txt_messaging_opt_attach")
    76 #define LOC_PHOTO           hbTrId("txt_messaging_opt_attach_sub_photo")
    79 #define LOC_PHOTO           hbTrId("txt_messaging_opt_attach_sub_photo")
    78 #define LOC_VCARD           hbTrId("txt_messaging_list_business_card")
    81 #define LOC_VCARD           hbTrId("txt_messaging_list_business_card")
    79 #define LOC_ADD_RECIPIENTS  hbTrId("txt_messaging_opt_add_recipients")
    82 #define LOC_ADD_RECIPIENTS  hbTrId("txt_messaging_opt_add_recipients")
    80 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
    83 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
    81 
    84 
    82 #define LOC_MSG_SEND_FAILED hbTrId("txt_messaging_dialog_message_sending_failed")
    85 #define LOC_MSG_SEND_FAILED hbTrId("txt_messaging_dialog_message_sending_failed")
    83 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_settings_incomplete")
    86 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e")
    84 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
    87 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
       
    88 #define LOC_MMS_RETRIEVAL_FAILED hbTrId("txt_messaging_dialog_mms_retrieval_failed")
    85 
    89 
    86 
    90 
    87 const int INVALID_MSGID = -1;
    91 const int INVALID_MSGID = -1;
    88 const int INVALID_CONVID = -1;
    92 const int INVALID_CONVID = -1;
    89 const int CONTACT_INSERTION_MODE = 1;
    93 const int CONTACT_INSERTION_MODE = 1;
   101     mEditorWidget(NULL),
   105     mEditorWidget(NULL),
   102     mContactCardWidget(contactCardWidget),
   106     mContactCardWidget(contactCardWidget),
   103     mSendUtil(NULL),
   107     mSendUtil(NULL),
   104     mVkbHost(NULL),
   108     mVkbHost(NULL),
   105     mVisibleIndex(),
   109     mVisibleIndex(),
   106     mVkbopened(false),
       
   107     mModelPopulated(false),
   110     mModelPopulated(false),
   108     mViewReady(false)
   111     mViewReady(false)
   109 {
   112 {
   110     //create send utils
   113     //create send utils
   111     mSendUtil = new MsgSendUtil(this);
   114     mSendUtil = new MsgSendUtil(this);
   272 
   275 
   273 //---------------------------------------------------------------
   276 //---------------------------------------------------------------
   274 // MsgConversationView::longPressed
   277 // MsgConversationView::longPressed
   275 // @see header file
   278 // @see header file
   276 //---------------------------------------------------------------
   279 //---------------------------------------------------------------
   277 void MsgConversationView::longPressed(HbAbstractViewItem* viewItem,
   280 void MsgConversationView::longPressed(HbAbstractViewItem* viewItem, const QPointF& point)
   278     const QPointF& point)
   281 { 
   279 {    
   282     showContextMenu(viewItem,point,HbPopup::TopLeftCorner);
   280     MsgConversationViewItem* item = qgraphicsitem_cast<
       
   281             MsgConversationViewItem *> (viewItem);
       
   282 
       
   283     // Show the item-specific menu
       
   284     if (this->isVisible())
       
   285     {
       
   286         //If message is in Sending state or is Scheduled to be sent later,
       
   287         //do not allow any operations on the message
       
   288         int sendingState = item->modelIndex().data(SendingState).toInt();
       
   289         if(sendingState == ConvergedMessage::Scheduled ||
       
   290                    sendingState == ConvergedMessage::Sending ||
       
   291                    sendingState == ConvergedMessage::Waiting)
       
   292            {
       
   293                return;
       
   294            }
       
   295         // Create new menu
       
   296         HbMenu* contextMenu = new HbMenu();
       
   297         contextMenu->setAttribute(Qt::WA_DeleteOnClose);
       
   298         contextMenu->setPreferredPos(point);
       
   299         setContextMenu(item, contextMenu, sendingState);
       
   300         contextMenu->show();
       
   301 
       
   302     }
       
   303     
       
   304 }
   283 }
   305 
   284 
   306 //---------------------------------------------------------------
   285 //---------------------------------------------------------------
   307 // MsgConversationView::setContextMenu
   286 // MsgConversationView::setContextMenu
   308 // @see header
   287 // @see header
   309 //---------------------------------------------------------------
   288 //---------------------------------------------------------------
   310 
       
   311 void MsgConversationView::setContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState)
   289 void MsgConversationView::setContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState)
   312 {
   290 {
   313     addOpenItemToContextMenu(item , contextMenu,sendingState);
   291     addOpenItemToContextMenu(item , contextMenu,sendingState);
   314     addResendItemToContextMenu(item, contextMenu, sendingState);
   292     addResendItemToContextMenu(item, contextMenu, sendingState);
   315     addForwardItemToContextMenu(item, contextMenu, sendingState);
   293     addForwardItemToContextMenu(item, contextMenu, sendingState);
   316     addDownloadItemToContextMenu(item, contextMenu);
   294     addDownloadItemToContextMenu(item, contextMenu);
       
   295     addSaveItemToContextMenu(item , contextMenu,sendingState);
   317     addDeleteItemToContextMenu(item, contextMenu, sendingState);
   296     addDeleteItemToContextMenu(item, contextMenu, sendingState);
   318     addSaveItemToContextMenu(item , contextMenu,sendingState);
       
   319 }
   297 }
   320 
   298 
   321 
   299 
   322 //---------------------------------------------------------------
   300 //---------------------------------------------------------------
   323 // MsgEditorPrivate::addSaveItemToContextMenu
   301 // MsgEditorPrivate::addSaveItemToContextMenu
   356         }
   334         }
   357     if ((messageSubType == ConvergedMessage::VCard) &&
   335     if ((messageSubType == ConvergedMessage::VCard) &&
   358         (direction == ConvergedMessage::Incoming))
   336         (direction == ConvergedMessage::Incoming))
   359         {
   337         {
   360         HbAction *contextItem = contextMenu->addAction(LOC_SAVE_TO_CONTACTS);
   338         HbAction *contextItem = contextMenu->addAction(LOC_SAVE_TO_CONTACTS);
   361         connect(contextItem, SIGNAL(triggered()),this, SLOT(openItem()));
   339         connect(contextItem, SIGNAL(triggered()),this, SLOT(saveVCard()));
   362         return;
   340         return;
   363         }
   341         }
   364     if( (sendingState == ConvergedMessage::SentState ) ||
   342     if( (sendingState == ConvergedMessage::SentState &&
       
   343          messageSubType != ConvergedMessage::VCard) ||
   365         (direction == ConvergedMessage::Incoming))
   344         (direction == ConvergedMessage::Incoming))
   366     {
   345     {
   367         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_OPEN);
   346         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_OPEN);
   368         connect(contextItem, SIGNAL(triggered()),this, SLOT(openItem()));
   347         connect(contextItem, SIGNAL(triggered()),this, SLOT(openItem()));
   369     }
   348     }
   377 
   356 
   378 void MsgConversationView::addResendItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState)
   357 void MsgConversationView::addResendItemToContextMenu(MsgConversationViewItem* item, HbMenu* contextMenu, int sendingState)
   379 {
   358 {
   380     Q_UNUSED(item)
   359     Q_UNUSED(item)
   381     int direction = item->modelIndex().data(Direction).toInt();
   360     int direction = item->modelIndex().data(Direction).toInt();
   382     
   361     int messageSubType = item->modelIndex().data(MessageSubType).toInt();
   383     if( (direction == ConvergedMessage::Outgoing)&&
   362     
       
   363     
       
   364     if( ((direction == ConvergedMessage::Outgoing) &&
       
   365         (messageSubType != ConvergedMessage::VCard))&&
   384         ((sendingState == ConvergedMessage::Resend ) ||
   366         ((sendingState == ConvergedMessage::Resend ) ||
   385         (sendingState == ConvergedMessage::Suspended )||
   367         
   386         (sendingState == ConvergedMessage::Failed )))
   368         (sendingState == ConvergedMessage::Failed )))
   387     {
   369     {
   388         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_SEND);
   370         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_SEND);
   389         connect(contextItem, SIGNAL(triggered()),this, SLOT(resendMessage()));
   371         connect(contextItem, SIGNAL(triggered()),this, SLOT(resendMessage()));
   390     }
   372     }
   418     }            
   400     }            
   419 
   401 
   420     if( ((sendingState == ConvergedMessage::SentState) ||
   402     if( ((sendingState == ConvergedMessage::SentState) ||
   421         (sendingState == ConvergedMessage::Resend) ||
   403         (sendingState == ConvergedMessage::Resend) ||
   422         (sendingState == ConvergedMessage::Failed) ||
   404         (sendingState == ConvergedMessage::Failed) ||
       
   405         (sendingState == ConvergedMessage::Suspended )||
   423         (direction == ConvergedMessage::Incoming) ) &&
   406         (direction == ConvergedMessage::Incoming) ) &&
   424         canForwardMessage)
   407         canForwardMessage)
   425     {
   408     {
   426         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_FORWARD);
   409         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_FORWARD);
   427         connect(contextItem, SIGNAL(triggered()),this, SLOT(forwardMessage()));
   410         connect(contextItem, SIGNAL(triggered()),this, SLOT(forwardMessage()));
   637 // MsgConversationView::contactsFetched
   620 // MsgConversationView::contactsFetched
   638 // @see header file
   621 // @see header file
   639 //---------------------------------------------------------------
   622 //---------------------------------------------------------------
   640 void MsgConversationView::contactsFetched(const QVariant& value)
   623 void MsgConversationView::contactsFetched(const QVariant& value)
   641 {
   624 {
   642     CntServicesContactList contactList = 
   625     //switch to editor.
   643             qVariantValue<CntServicesContactList>(value);
   626     QVariantList params;
   644 	int count = contactList.count();
   627     params << MsgBaseView::ADD_RECIPIENTS;
   645 	if(count > 0)
   628     params << value;
   646     {
   629     launchUniEditor(params);
   647         QVariantList params;
       
   648         params << MsgBaseView::ADD_RECIPIENTS;
       
   649         params << value;
       
   650         launchUniEditor(params);
       
   651     }
       
   652 }
   630 }
   653 
   631 
   654 //---------------------------------------------------------------
   632 //---------------------------------------------------------------
   655 // MsgConversationView::imagesFetched()
   633 // MsgConversationView::imagesFetched()
   656 // @see header file
   634 // @see header file
   720     if(index.isValid())
   698     if(index.isValid())
   721     {
   699     {
   722         qint32 messageId = index.data(ConvergedMsgId).toLongLong();    
   700         qint32 messageId = index.data(ConvergedMsgId).toLongLong();    
   723         if(!(ConversationsEngine::instance()->resendMessage(messageId)))
   701         if(!(ConversationsEngine::instance()->resendMessage(messageId)))
   724         {
   702         {
   725             HbMessageBox::warning(LOC_MSG_SEND_FAILED);
   703             HbMessageBox::warning(LOC_MSG_SEND_FAILED, 0, 0, HbMessageBox::Ok);
   726         }
   704         }
   727     }
   705     }
   728     
   706     
   729 }
   707 }
   730 
   708 
   735 void MsgConversationView::downloadMessage()
   713 void MsgConversationView::downloadMessage()
   736 {
   714 {
   737     QModelIndex index = mConversationList->currentIndex();
   715     QModelIndex index = mConversationList->currentIndex();
   738     if(index.isValid())
   716     if(index.isValid())
   739     {
   717     {
   740         qint32 messageId = index.data(ConvergedMsgId).toLongLong();    
   718         qint32 messageId = index.data(ConvergedMsgId).toLongLong();
   741         if(ConversationsEngine::instance()->downloadMessage(messageId)!=KErrNone)
   719         if(ConversationsEngine::instance()->downloadMessage(messageId)!=KErrNone)
   742         {
   720         {
   743             HbMessageBox::warning("Message Retrieval Failed!"); //TODO: use logical str name
   721             HbMessageBox::warning(LOC_MMS_RETRIEVAL_FAILED, 0, 0, HbMessageBox::Ok);
   744         }
   722         }
   745     }
   723     }
   746     
   724     
   747 }
   725 }
   748 
   726 
   749 //---------------------------------------------------------------
   727 //---------------------------------------------------------------
   750 // MsgConversationView::deleteItem()
   728 // MsgConversationView::deleteItem()
   751 // Deletes the message
   729 // Deletes the message
   752 //---------------------------------------------------------------
   730 //---------------------------------------------------------------
   753 void MsgConversationView::deleteItem()
   731 void MsgConversationView::deleteItem()
   754     {
   732 {
   755     HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogdeleteMsg(HbAction*)),
   733     QString str = LOC_DELETE_MESSAGE;
       
   734 
       
   735     QModelIndex index = mConversationList->currentIndex();
       
   736     if(index.isValid())
       
   737     {
       
   738         int messageType = index.data(MessageType).toInt();        
       
   739         int direction = index.data(Direction).toInt();
       
   740 
       
   741         if ( direction == ConvergedMessage::Outgoing &&
       
   742             messageType == ConvergedMessage::Mms )
       
   743         {
       
   744             qint32 messageId = index.data(ConvergedMsgId).toLongLong();
       
   745 
       
   746             if(isSharedMessage(messageId))
       
   747             {
       
   748                 str = LOC_DELETE_SHARED_MESSAGE;  
       
   749             }
       
   750         }
       
   751     }
       
   752 
       
   753 
       
   754     HbMessageBox::question(str,this,SLOT(onDialogdeleteMsg(HbAction*)),
   756                            HbMessageBox::Delete | HbMessageBox::Cancel);
   755                            HbMessageBox::Delete | HbMessageBox::Cancel);
   757 }
   756 }
   758 
   757 
   759 //---------------------------------------------------------------
   758 //---------------------------------------------------------------
   760 // MsgConversationView::openItem()
   759 // MsgConversationView::openItem()
   885 //@see header
   884 //@see header
   886 //---------------------------------------------------------------
   885 //---------------------------------------------------------------
   887 void MsgConversationView::openItem(const QModelIndex & index)
   886 void MsgConversationView::openItem(const QModelIndex & index)
   888 {
   887 {
   889     // Return if invalid index.
   888     // Return if invalid index.
   890     if (!index.isValid() || mVkbopened)
   889     if (!index.isValid())
   891     {
   890     {
   892         return;
   891         return;
   893     }
   892     }
   894     
   893     
   895     int messageType = index.data(MessageType).toInt();
   894     int messageType = index.data(MessageType).toInt();
   918             }
   917             }
   919             return;
   918             return;
   920         }
   919         }
   921         else if(ConvergedMessage::VCard == messageSubType)
   920         else if(ConvergedMessage::VCard == messageSubType)
   922         {
   921         {
   923             QString filepath = index.data(Attachments).toStringList().at(0);
   922             handleShortTap();
   924             bool result = MsgContactsUtil::launchVCardViewer(filepath);
       
   925             if(result)
       
   926             {
       
   927                 
       
   928                 int messageId = index.data(ConvergedMsgId).toInt();
       
   929                 QList<int> msgIdList;
       
   930                 if(index.data(UnReadStatus).toInt())
       
   931                 {
       
   932                     msgIdList.clear();
       
   933                     msgIdList << messageId;
       
   934                     ConversationsEngine::instance()->markMessagesRead(msgIdList);
       
   935                 }
       
   936             }
       
   937             return;
   923             return;
   938         }
   924         }
   939         else if(ConvergedMessage::VCal == messageSubType)
   925         else if(ConvergedMessage::VCal == messageSubType)
   940         {
   926         {
   941             return;
   927             return;
   953             }
   939             }
   954         return;
   940         return;
   955     }
   941     }
   956     else if(ConvergedMessage::MmsNotification == messageType)
   942     else if(ConvergedMessage::MmsNotification == messageType)
   957     {
   943     {
   958         qint32 messageId = index.data(ConvergedMsgId).toLongLong();    
   944         qint32 messageId = index.data(ConvergedMsgId).toLongLong();
   959         if(!ConversationsEngine::instance()->downloadOperationSupported(messageId))           
   945         if(!ConversationsEngine::instance()->downloadOperationSupported(messageId))           
   960         {
   946         {
   961            int notificationState = index.data(NotificationStatus).toInt();
   947            int notificationState = index.data(NotificationStatus).toInt();
   962            if( notificationState == ConvergedMessage::NotifExpired)
   948            if( notificationState == ConvergedMessage::NotifExpired)
   963            {
   949            {
   985     
   971     
   986     // check whether message is in sending progress, then donot launch viewer.
   972     // check whether message is in sending progress, then donot launch viewer.
   987     int location = index.data(MessageLocation).toInt();
   973     int location = index.data(MessageLocation).toInt();
   988     int sendingState = index.data(SendingState).toInt();
   974     int sendingState = index.data(SendingState).toInt();
   989     
   975     
       
   976     // For suspended message both short tap and long tap needs to show the same
       
   977     // context menu.....
       
   978     if(direction == ConvergedMessage::Outgoing 
       
   979         	&&sendingState == ConvergedMessage::Suspended )
       
   980     {
       
   981         handleShortTap();
       
   982         return;
       
   983     }
       
   984     
   990     //If message is in any other state other than 'Sent'
   985     //If message is in any other state other than 'Sent'
   991     //do not open the message
   986     //do not open the message
   992     if(direction == ConvergedMessage::Outgoing 
   987     if(direction == ConvergedMessage::Outgoing 
   993             && sendingState != ConvergedMessage::SentState )
   988             && sendingState != ConvergedMessage::SentState )
   994            
   989            
  1007     {
  1002     {
  1008         msgIdList.clear();
  1003         msgIdList.clear();
  1009         msgIdList << messageId;
  1004         msgIdList << messageId;
  1010         ConversationsEngine::instance()->markMessagesRead(msgIdList);
  1005         ConversationsEngine::instance()->markMessagesRead(msgIdList);
  1011     }
  1006     }
  1012     
  1007 
  1013     qint32 messageProperty = index.data(MessageProperty).toInt();
       
  1014 
       
  1015     bool canForwardMessage  = true;
       
  1016     if (messageType == ConvergedMessage::Mms){
       
  1017         canForwardMessage = (messageProperty & EPreviewForward)? true:false;
       
  1018     } 
       
  1019     
       
  1020     //switch view
  1008     //switch view
  1021     QVariantList param;
  1009     QVariantList param;
  1022     param << MsgBaseView::UNIVIEWER;  // target view
  1010     param << MsgBaseView::UNIVIEWER;  // target view
  1023     param << MsgBaseView::CV; // source view
  1011     param << MsgBaseView::CV; // source view
  1024 
  1012 
  1025     param << contactId;
  1013     param << contactId;
  1026     param << messageId;
  1014     param << messageId;
  1027     param << mMessageModel->rowCount();
  1015     param << mMessageModel->rowCount();
  1028     if (canForwardMessage == true)
       
  1029     {
       
  1030       param << 1;
       
  1031     }
       
  1032     else
       
  1033    	{
       
  1034    		param << 0;
       
  1035    	}
       
  1036     emit switchView(param);
  1016     emit switchView(param);
  1037 }
  1017 }
  1038 
  1018 
  1039 //---------------------------------------------------------------
  1019 //---------------------------------------------------------------
  1040 // MsgConversationView::launchUniEditor
  1020 // MsgConversationView::launchUniEditor
  1192 // MsgConversationView::vkbOpened
  1172 // MsgConversationView::vkbOpened
  1193 // @see header file
  1173 // @see header file
  1194 //---------------------------------------------------------------
  1174 //---------------------------------------------------------------
  1195 void MsgConversationView::vkbOpened()
  1175 void MsgConversationView::vkbOpened()
  1196 {
  1176 {
  1197     mVkbopened = true;
       
  1198     
       
  1199     emit vkbOpened(true);
  1177     emit vkbOpened(true);
       
  1178     
       
  1179     scrollToBottom();
  1200     
  1180     
  1201     QRectF appRect = mVkbHost->applicationArea();    
  1181     QRectF appRect = mVkbHost->applicationArea();    
  1202     qreal spacing = 0.0;
  1182     qreal spacing = 0.0;
  1203     qreal cardHeight = 0.0;
  1183     qreal cardHeight = 0.0;
  1204     if(mContactCardWidget->isVisible())
  1184     if(mContactCardWidget->isVisible())
  1206         cardHeight = mContactCardWidget->rect().height();
  1186         cardHeight = mContactCardWidget->rect().height();
  1207         spacing = HbDeviceProfile::profile(this).unitValue();
  1187         spacing = HbDeviceProfile::profile(this).unitValue();
  1208         }
  1188         }
  1209     
  1189     
  1210     this->setMaximumHeight(appRect.height()- cardHeight - spacing);
  1190     this->setMaximumHeight(appRect.height()- cardHeight - spacing);
       
  1191     mConversationList->adjustSize();
  1211     
  1192     
  1212     disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1193     disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
       
  1194 
       
  1195 }
       
  1196 	  
       
  1197 //---------------------------------------------------------------
       
  1198 // MsgConversationView::vkbClosed
       
  1199 // @see header file
       
  1200 //---------------------------------------------------------------
       
  1201 void MsgConversationView::vkbClosed()
       
  1202 {
       
  1203     emit vkbOpened(false);
  1213     
  1204     
  1214     scrollToBottom();
  1205     scrollToBottom();
  1215 }
       
  1216 	  
       
  1217 //---------------------------------------------------------------
       
  1218 // MsgConversationView::vkbClosed
       
  1219 // @see header file
       
  1220 //---------------------------------------------------------------
       
  1221 void MsgConversationView::vkbClosed()
       
  1222 {
       
  1223     mVkbopened = false;
       
  1224     
       
  1225     emit vkbOpened(false);
       
  1226     
  1206     
  1227     this->setMaximumHeight(-1);
  1207     this->setMaximumHeight(-1);
       
  1208     mConversationList->adjustSize();    
       
  1209     
  1228     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1210     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1229     
       
  1230     scrollToBottom();
       
  1231 }
  1211 }
  1232 
  1212 
  1233 //---------------------------------------------------------------
  1213 //---------------------------------------------------------------
  1234 // MsgConversationView::serviceRequestError
  1214 // MsgConversationView::serviceRequestError
  1235 // @see header file
  1215 // @see header file
  1344 {
  1324 {
  1345     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
  1325     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
  1346     if (action == dlg->actions().at(0)) {
  1326     if (action == dlg->actions().at(0)) {
  1347         downloadMessage();
  1327         downloadMessage();
  1348     }
  1328     }
       
  1329     
       
  1330     //if message unread, mark as read now
       
  1331     QModelIndex index = mConversationList->currentIndex();
       
  1332     qint32 messageId = index.data(ConvergedMsgId).toLongLong();
       
  1333     QList<int> msgIdList;
       
  1334     if(index.data(UnReadStatus).toInt())
       
  1335     {
       
  1336         msgIdList.clear();
       
  1337         msgIdList << messageId;
       
  1338         ConversationsEngine::instance()->markMessagesRead(msgIdList);
       
  1339     }
  1349 }
  1340 }
  1350 
  1341 
  1351 //---------------------------------------------------------------
  1342 //---------------------------------------------------------------
  1352 // MsgConversationView::onDialogSaveTone
  1343 // MsgConversationView::onDialogSaveTone
  1353 // @see header file
  1344 // @see header file
  1400     disconnect(mainWindow(), SIGNAL(aboutToChangeOrientation()), mConversationList, 0);
  1391     disconnect(mainWindow(), SIGNAL(aboutToChangeOrientation()), mConversationList, 0);
  1401     disconnect(mainWindow(), SIGNAL(orientationChanged(Qt: rientation)), mConversationList, 0);
  1392     disconnect(mainWindow(), SIGNAL(orientationChanged(Qt: rientation)), mConversationList, 0);
  1402     
  1393     
  1403    fetchMoreConversations();
  1394    fetchMoreConversations();
  1404 }
  1395 }
       
  1396 
       
  1397 //---------------------------------------------------------------
       
  1398 // MsgConversationView::handleShortTap
       
  1399 // @see header file
       
  1400 //---------------------------------------------------------------
       
  1401 void MsgConversationView::handleShortTap()
       
  1402 {
       
  1403     HbAbstractViewItem* item = mConversationList->currentViewItem();
       
  1404     QRectF rc = item->rect();
       
  1405     QPointF p = item->mapToScene(rc.center());
       
  1406     
       
  1407     showContextMenu(item,p,HbPopup::TopEdgeCenter);
       
  1408 }
       
  1409 
       
  1410 //---------------------------------------------------------------
       
  1411 // MsgConversationView::handleShortTap
       
  1412 // @see header file
       
  1413 //---------------------------------------------------------------
       
  1414 void MsgConversationView::showContextMenu(HbAbstractViewItem* viewItem,const QPointF& point, int placement)
       
  1415 {    
       
  1416     MsgConversationViewItem* item = qgraphicsitem_cast<MsgConversationViewItem *>(viewItem);
       
  1417 
       
  1418     // Show the item-specific menu
       
  1419     if (this->isVisible())
       
  1420     {
       
  1421         //If message is in Sending state or is Scheduled to be sent later,
       
  1422         //do not allow any operations on the message
       
  1423         int sendingState = item->modelIndex().data(SendingState).toInt();
       
  1424         
       
  1425         if(sendingState == ConvergedMessage::Scheduled ||
       
  1426             sendingState == ConvergedMessage::Sending ||
       
  1427             sendingState == ConvergedMessage::Waiting)
       
  1428             {
       
  1429                 return;
       
  1430             }
       
  1431         // Create new menu
       
  1432         HbMenu* contextMenu = new HbMenu();
       
  1433         contextMenu->setAttribute(Qt::WA_DeleteOnClose);
       
  1434         contextMenu->setPreferredPos(point,HbPopup::Placement(placement));
       
  1435         setContextMenu(item, contextMenu, sendingState);
       
  1436         contextMenu->show();
       
  1437     }
       
  1438 }
       
  1439 
       
  1440 //---------------------------------------------------------------
       
  1441 // MsgConversationView::saveVCard
       
  1442 // @see header file
       
  1443 //---------------------------------------------------------------
       
  1444 void MsgConversationView::saveVCard()
       
  1445 {
       
  1446     QModelIndex index = mConversationList->currentIndex();
       
  1447     
       
  1448     QString filepath = index.data(Attachments).toStringList().at(0);
       
  1449     bool result = MsgContactsUtil::launchVCardViewer(filepath);
       
  1450     if(result)
       
  1451     {
       
  1452         int messageId = index.data(ConvergedMsgId).toInt();
       
  1453         QList<int> msgIdList;
       
  1454         if(index.data(UnReadStatus).toInt())
       
  1455         {
       
  1456             msgIdList.clear();
       
  1457             msgIdList << messageId;
       
  1458             ConversationsEngine::instance()->markMessagesRead(msgIdList);
       
  1459         }
       
  1460     } 
       
  1461 }
       
  1462 
       
  1463 //---------------------------------------------------------------
       
  1464 // MsgConversationView::isSharedMessage
       
  1465 // @see header file
       
  1466 //---------------------------------------------------------------
       
  1467 bool MsgConversationView::isSharedMessage(qint32 messageId)
       
  1468 {
       
  1469     bool shared = false;
       
  1470 
       
  1471     UniDataModelLoader* pluginLoader = new UniDataModelLoader();
       
  1472     
       
  1473     UniDataModelPluginInterface* pluginInterface =
       
  1474         pluginLoader->getDataModelPlugin(ConvergedMessage::Mms);
       
  1475     
       
  1476     CMsvSession* session = pluginInterface->session();
       
  1477 
       
  1478     TMsvEntry entry; 
       
  1479     TMsvId service;
       
  1480     session->GetEntry(messageId, service, entry);
       
  1481     
       
  1482     if(entry.MultipleRecipients())
       
  1483     {
       
  1484         shared = true;
       
  1485     }
       
  1486     delete pluginLoader;    
       
  1487 
       
  1488     return shared;
       
  1489 }
       
  1490 
  1405 // EOF
  1491 // EOF