messagingapp/msgui/conversationview/src/msgconversationview.cpp
branchGCC_SURGE
changeset 47 5b14749788d7
parent 27 e4592d119491
parent 44 36f374c67aa8
--- a/messagingapp/msgui/conversationview/src/msgconversationview.cpp	Thu Jun 17 09:57:06 2010 +0100
+++ b/messagingapp/msgui/conversationview/src/msgconversationview.cpp	Thu Jul 22 16:32:06 2010 +0100
@@ -24,11 +24,12 @@
 #include <HbMessageBox>
 #include <HbNotificationDialog>
 #include <HbFrameBackground>
-#include <XQServiceRequest.h>
+#include <xqservicerequest.h>
 #include <HbStaticVkbHost>
 #include <HbStyleLoader>
 #include <xqaiwrequest.h>
 #include <xqappmgr.h>
+#include <HbMainWindow>
 
 #include <QDir>
 #include <QDateTime>
@@ -41,6 +42,7 @@
 #include <MmsEngineDomainCRKeys.h>
 
 // USER INCLUDES
+#include "msgcontactsutil.h"
 #include "msgsendutil.h"
 #include "msgconversationviewitem.h"
 #include "conversationsengine.h"
@@ -55,6 +57,7 @@
 #include "ringbc.h"
 #include "mmsconformancecheck.h"
 #include "msgsettingsview.h"
+#include "msgaudiofetcherview.h"
 
 //Item specific menu.
 
@@ -62,13 +65,11 @@
 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete")
 #define LOC_COMMON_FORWARD hbTrId("txt_common_menu_forward")
 #define LOC_COMMON_DOWNLOAD hbTrId("txt_messaging_menu_download")
-#define LOC_COMMON_SEND  hbTrId("txt_common_menu_send") 
+#define LOC_COMMON_SEND  hbTrId("txt_common_button_send") 
 #define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
-#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
-#define LOC_BUTTON_OK hbTrId("txt_common_button_ok")
 
 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
+#define LOC_SAVE_TO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
 
 //main menu
 #define LOC_ATTACH          hbTrId("txt_messaging_opt_attach")
@@ -78,13 +79,11 @@
 #define LOC_ADD_RECIPIENTS  hbTrId("txt_messaging_opt_add_recipients")
 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
 
-#define LOC_MSG_SEND_FAILED hbTrId("txt_messaging_dpopinfo_sending_failed")
-
+#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_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
 
 
-
 const int INVALID_MSGID = -1;
 const int INVALID_CONVID = -1;
 const int CONTACT_INSERTION_MODE = 1;
@@ -102,15 +101,27 @@
     mEditorWidget(NULL),
     mContactCardWidget(contactCardWidget),
     mSendUtil(NULL),
-    mItemLongPressed(false),
     mVkbHost(NULL),
-    mVkbopened(false)
+    mVisibleIndex(),
+    mVkbopened(false),
+    mModelPopulated(false),
+    mViewReady(false)
 {
     //create send utils
     mSendUtil = new MsgSendUtil(this);
     //initialize view
     setupView();
     setupMenu();
+    
+    connect(ConversationsEngine::instance(), 
+                     SIGNAL(conversationModelUpdated()),
+                     this, 
+                     SLOT(scrollToBottom()));
+
+    connect(ConversationsEngine::instance(), 
+                         SIGNAL(conversationViewEmpty()),
+                         this, 
+                         SLOT(onConversationViewEmpty()));
 }
 
 //---------------------------------------------------------------
@@ -152,6 +163,11 @@
     
     connect(mConversationList, SIGNAL(activated(QModelIndex)),
             this, SLOT(openItem(QModelIndex)));
+    connect(this->mainWindow(), SIGNAL(aboutToChangeOrientation()),
+                this, SLOT(onOrientationAboutToBeChanged()));
+    
+    connect(this->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
+                    this, SLOT(onOrientationChanged(Qt::Orientation)));
 
     // Long tap list item
     connect(mConversationList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)),
@@ -201,6 +217,18 @@
 }
 
 //---------------------------------------------------------------
+// MsgConversationView::fetchMoreConversations
+// @see header file
+//---------------------------------------------------------------
+void MsgConversationView::fetchMoreConversations()
+{
+    if (mViewReady && mModelPopulated) {
+        ConversationsEngine::instance()->fetchMoreConversations();
+        mViewReady = mModelPopulated = false;
+    }
+}
+
+//---------------------------------------------------------------
 // MsgConversationView::refreshView()
 // @see header file
 //---------------------------------------------------------------
@@ -234,6 +262,14 @@
             mMessageModel->index(rowCnt - 1, 0));
 }
 
+void MsgConversationView::onConversationViewEmpty()
+{
+    QVariantList param;
+    param << MsgBaseView::CLV; // target view
+    param << MsgBaseView::CV; // source view
+    emit switchView(param);
+}
+
 //---------------------------------------------------------------
 // MsgConversationView::longPressed
 // @see header file
@@ -241,8 +277,6 @@
 void MsgConversationView::longPressed(HbAbstractViewItem* viewItem,
     const QPointF& point)
 {    
-    mItemLongPressed = true;
-    
     MsgConversationViewItem* item = qgraphicsitem_cast<
             MsgConversationViewItem *> (viewItem);
 
@@ -266,11 +300,7 @@
         contextMenu->show();
 
     }
-    else
-    {
-        // For cases where the long tap check failed
-        mItemLongPressed = false;
-    }
+    
 }
 
 //---------------------------------------------------------------
@@ -296,6 +326,8 @@
 void MsgConversationView::addSaveItemToContextMenu(MsgConversationViewItem* item,
     HbMenu* contextMenu, int sendingState)
 {
+    Q_UNUSED(sendingState)
+
     int messageSubType = item->modelIndex().data(MessageSubType).toInt();
     int direction =  item->modelIndex().data(Direction).toInt();
     if ((messageSubType == ConvergedMessage::RingingTone) && 
@@ -322,10 +354,14 @@
         {
         return;
         }
-    
+    if ((messageSubType == ConvergedMessage::VCard) &&
+        (direction == ConvergedMessage::Incoming))
+        {
+        HbAction *contextItem = contextMenu->addAction(LOC_SAVE_TO_CONTACTS);
+        connect(contextItem, SIGNAL(triggered()),this, SLOT(openItem()));
+        return;
+        }
     if( (sendingState == ConvergedMessage::SentState ) ||
-        (sendingState == ConvergedMessage::Resend ) ||
-        (sendingState == ConvergedMessage::Failed ) ||
         (direction == ConvergedMessage::Incoming))
     {
         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_OPEN);
@@ -374,12 +410,18 @@
     }
     
     qint32 messageId = item->modelIndex().data(ConvergedMsgId).toInt();
+    qint32 messageProperty = item->modelIndex().data(MessageProperty).toInt();
+    
+    bool canForwardMessage  = true;
+    if (messageType == ConvergedMessage::Mms){
+        canForwardMessage = (messageProperty & EPreviewForward)? true:false;
+    }            
 
     if( ((sendingState == ConvergedMessage::SentState) ||
         (sendingState == ConvergedMessage::Resend) ||
         (sendingState == ConvergedMessage::Failed) ||
         (direction == ConvergedMessage::Incoming) ) &&
-        (validateMsgForForward(messageType,messageId))	)
+        canForwardMessage)
     {
         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_FORWARD);
         connect(contextItem, SIGNAL(triggered()),this, SLOT(forwardMessage()));
@@ -462,7 +504,9 @@
     deactivateInputBlocker();
     if( sendResult == KErrNotFound)
     {
-    HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, this, SLOT(onDialogSettingsLaunch(HbAction*)), LOC_BUTTON_OK, LOC_BUTTON_CANCEL);
+    HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, this,
+                           SLOT(onDialogSettingsLaunch(HbAction*)), 
+                           HbMessageBox::Ok | HbMessageBox::Cancel);
     }
 }
 
@@ -536,11 +580,12 @@
 //---------------------------------------------------------------
 void MsgConversationView::fetchImages()
 {
-    QString interface("Image");
-    QString operation("fetch(QVariantMap,QVariant)");
+    QString service("photos");
+    QString interface("com.nokia.symbian.IImageFetch");
+    QString operation("fetch()");
     XQAiwRequest* request = NULL;
     XQApplicationManager appManager;
-    request = appManager.create(interface, operation, true); // embedded
+    request = appManager.create(service,interface, operation, true); // embedded
     request->setSynchronous(true); // synchronous
     if(!request)
     {
@@ -553,11 +598,6 @@
     connect(request, SIGNAL(requestError(int,const QString&)),
         this, SLOT(serviceRequestError(int,const QString&)));
 
-    // Set arguments for request
-    QList<QVariant> args;
-    args << QVariantMap();
-    args << QVariant();
-    request->setArguments(args);
     // Make the request
     if (!request->send())
     {
@@ -572,30 +612,25 @@
 //---------------------------------------------------------------
 void MsgConversationView::fetchAudio()
 {
-    QString service("musicplayer");
-    QString interface("com.nokia.symbian.IMusicFetch");
-    QString operation("fetch()");
-    XQAiwRequest* request = NULL;
-    XQApplicationManager appManager;
-    request = appManager.create(service, interface, operation, true); //embedded
-    request->setSynchronous(true); // synchronous
-    if(!request)
-    {
-        QDEBUG_WRITE("AIW-ERROR: NULL request");
-        return;
-    }
+    // Launch Audio fetcher view
+    QVariantList params;
+    QByteArray dataArray;
+    QDataStream messageStream
+    (&dataArray, QIODevice::WriteOnly | QIODevice::Append);
 
-    connect(request, SIGNAL(requestOk(const QVariant&)),
-        this, SLOT(audiosFetched(const QVariant&)));
-    connect(request, SIGNAL(requestError(int,const QString&)),
-        this, SLOT(serviceRequestError(int,const QString&)));
+    ConvergedMessage message;
+    message.setBodyText(mEditorWidget->content());
+    // add address from contact-card to to-field
+    ConvergedMessageAddress address;
+    address.setAlias(mContactCardWidget->address().at(0)->alias());
+    address.setAddress(mContactCardWidget->address().at(0)->address());
+    message.addToRecipient(address);
+    message.serialize(messageStream);
 
-    // Make the request
-    if (!request->send())
-    {
-        QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed  ",request->lastError());
-    }
-    delete request;
+    params << MsgBaseView::AUDIOFETCHER; // target view
+    params << MsgBaseView::CV; // source view
+    params << dataArray;
+    emit switchView(params);
 }
 
 //---------------------------------------------------------------
@@ -637,26 +672,6 @@
 }
 
 //---------------------------------------------------------------
-// MsgConversationView::audiosFetched()
-// @see header file
-//---------------------------------------------------------------
-void MsgConversationView::audiosFetched(const QVariant& result )
-{
-    if(result.canConvert<QStringList>())
-    {
-        QStringList fileList = result.value<QStringList>();
-        if ( fileList.size()>0 && !fileList.at(0).isEmpty())
-        {
-            QString filepath(QDir::toNativeSeparators(fileList.at(0)));
-            QVariantList params;
-            params << MsgBaseView::ADD_AUDIO;
-            params << filepath;
-            launchUniEditor(params);
-        }
-    }
-}
-
-//---------------------------------------------------------------
 // MsgConversationView::addSubject()
 // @see header file
 //---------------------------------------------------------------
@@ -738,8 +753,7 @@
 void MsgConversationView::deleteItem()
     {
     HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogdeleteMsg(HbAction*)),
-                             LOC_BUTTON_DELETE,
-                             LOC_BUTTON_CANCEL);
+                           HbMessageBox::Delete | HbMessageBox::Cancel);
 }
 
 //---------------------------------------------------------------
@@ -767,7 +781,7 @@
 // MsgConversationView::saveContentToDrafts()
 // @See header
 //---------------------------------------------------------------
-bool MsgConversationView::saveContentToDrafts()
+int MsgConversationView::saveContentToDrafts()
 {
     int msgId = INVALID_MSGID;
     if(!mEditorWidget->content().isEmpty())
@@ -790,7 +804,7 @@
         }
         deactivateInputBlocker();
     }
-    return ((msgId > INVALID_MSGID)? true : false);
+    return msgId;
 }
 
 //---------------------------------------------------------------
@@ -814,14 +828,24 @@
 {
     qint32 messageId = index.data(ConvergedMsgId).toLongLong();
 
-    QString interface("com.nokia.services.btmsgdispservices.displaymsg");
+    QList<QVariant> args;
+    QString serviceName("com.nokia.services.btmsgdispservices");
     QString operation("displaymsg(int)");
+    XQAiwRequest* request;
+    XQApplicationManager appManager;
+    request = appManager.create(serviceName, "displaymsg", operation, false); // embedded
+    
+    if ( request == NULL )
+        {
+        return;
+        }
 
-    XQServiceRequest request(interface, operation, false);
-
-    request << messageId;
-
-    bool result = request.send();
+    args << QVariant(messageId);
+    request->setSynchronous(true);
+    
+    request->setArguments(args);
+    request->send();
+    delete request;    
 }
 
 //---------------------------------------------------------------
@@ -861,50 +885,72 @@
 //@see header
 //---------------------------------------------------------------
 void MsgConversationView::openItem(const QModelIndex & index)
-    {
+{
     // Return if invalid index.
     if (!index.isValid() || mVkbopened)
-        {
+    {
         return;
-        }
-
-    if(mItemLongPressed)
-        {
-        //reset the flag
-        mItemLongPressed = false;
-        return;
-        }
+    }
     
     int messageType = index.data(MessageType).toInt();
     int messageSubType = index.data(MessageSubType).toInt();
+    int messageId = index.data(ConvergedMsgId).toInt();
     
-    if (ConvergedMessage::BioMsg == messageType) {
-        if (ConvergedMessage::RingingTone == messageSubType) {
+    if (ConvergedMessage::BioMsg == messageType)
+    {
+        if (ConvergedMessage::RingingTone == messageSubType)
+        {
             HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this,
-                    SLOT(onDialogSaveTone(HbAction*)), LOC_COMMON_SAVE, LOC_BUTTON_CANCEL);
+                                   SLOT(onDialogSaveTone(HbAction*)), 
+                                   HbMessageBox::Save | HbMessageBox::Cancel);
             return;
         }
         else if(ConvergedMessage::Provisioning == messageSubType)
-            {
+        {
             int messageId = index.data(ConvergedMsgId).toInt();
             handleProvisoningMsg(messageId);
             QList<int> msgIdList;
             if(index.data(UnReadStatus).toInt())
-                {
+            {
                 msgIdList.clear();
                 msgIdList << messageId;
                 ConversationsEngine::instance()->markMessagesRead(msgIdList);
-                }
-            return;
             }
-        // Unsupported messages
-        else if (ConvergedMessage::VCard == messageSubType
-            || ConvergedMessage::VCal == messageSubType) {
+            return;
+        }
+        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);
+                }
+            }
+            return;
+        }
+        else if(ConvergedMessage::VCal == messageSubType)
+        {
             return;
         }
     }
-    else if (ConvergedMessage::BT == messageType) {
+    else if (ConvergedMessage::BT == messageType)
+    {
         launchBtDisplayService(index);
+        QList<int> msgIdList;
+        if(index.data(UnReadStatus).toInt())
+            {
+            msgIdList.clear();
+            msgIdList << messageId;
+            ConversationsEngine::instance()->markMessagesRead(msgIdList);
+            }
         return;
     }
     else if(ConvergedMessage::MmsNotification == messageType)
@@ -922,107 +968,72 @@
         else
         {
             //TODO: use logical str name
-            HbMessageBox::question("Download Message?",this,SLOT(onDialogDownLoadMsg(HbAction*)),
-                LOC_COMMON_DOWNLOAD,
-                LOC_BUTTON_CANCEL);
+            HbMessageBox::question("Download Message?",this,
+                                   SLOT(onDialogDownLoadMsg(HbAction*)),
+                                   HbMessageBox::Yes | HbMessageBox::Cancel);
             return;
         }
     }
 
-    ConvergedMessage message;
+    int direction = index.data(Direction).toInt();
+
+    if (direction == ConvergedMessage::Outgoing && ConvergedMessage::Sms == messageType
+        && ConversationsEngine::instance()->getMsgSubType(messageId)== ConvergedMessage::NokiaService)
+    {
+        return;
+    }
+    
     // check whether message is in sending progress, then donot launch viewer.
     int location = index.data(MessageLocation).toInt();
     int sendingState = index.data(SendingState).toInt();
     
-    //If message is in Sending state or is Scheduled to be sent later,
+    //If message is in any other state other than 'Sent'
     //do not open the message
-    if(sendingState == ConvergedMessage::Suspended ||
-            sendingState == ConvergedMessage::Scheduled ||
-            sendingState == ConvergedMessage::Sending ||
-            sendingState == ConvergedMessage::Waiting)
+    if(direction == ConvergedMessage::Outgoing 
+            && sendingState != ConvergedMessage::SentState )
+           
     {
         return;
     }
 
-    //TODO: sendingState check should be removed once msg
-    // movement lock issue is resolved from mw
-    if( !((location == ConvergedMessage::Inbox) ||
-        (location == ConvergedMessage::Sent) ||
-        (sendingState == ConvergedMessage::SentState)||
-        (sendingState == ConvergedMessage::Failed) ||
-        (sendingState == ConvergedMessage::Resend)))
-        {// do not launch viewer, show a note
-        HbNotificationDialog* dlg = new HbNotificationDialog();
-        dlg->setFocusPolicy(Qt::NoFocus);
-        QString text(tr("Message Locked"));
-        dlg->setText(text);
-        dlg->setDismissPolicy(HbPopup::TapAnywhere);
-        dlg->setAttribute(Qt::WA_DeleteOnClose, true);
-        dlg->show();
-        return;
-		}
-
-        // message id
-        qint32 messageId = index.data(ConvergedMsgId).toLongLong();
-        ConvergedMessageId msgId(messageId);
-        message.setMessageId(msgId);
-
-        // contact Id
-        qint32 contactId = index.data(ContactId).toLongLong();
-
-        // message type
-
-        message.setMessageType((ConvergedMessage::MessageType) messageType);
-        message.setMessageSubType((ConvergedMessage::MessageSubType) messageSubType);
-
-        if (messageType == ConvergedMessage::Mms)
-        {
-            message.setSubject(index.data(Subject).toString());
-            message.setPriority((ConvergedMessage::Priority) index.data(
-                MessagePriority).toInt());
-        }
-        else if (messageType == ConvergedMessage::IM)
-        {
-            // add body text and send to the message for IM case
-            message.setBodyText(index.data(BodyText).toString());
-        }
-
-        // time stamp
-        message.setTimeStamp(index.data(TimeStamp).toLongLong());
-
-        //Message direction
-        message.setDirection((ConvergedMessage::Direction)index.data(Direction).toInt());
-
-        // conatct name as address
-        ConvergedMessageAddress address;
-        address.setAlias(mContactCardWidget->address().at(0)->alias());
-        address.setAddress(mContactCardWidget->address().at(0)->address());
-        message.addToRecipient(address);
-
-        // Mark this message as read if its unread
-        QByteArray dataArray;
-        QDataStream messageStream
-        (&dataArray, QIODevice::WriteOnly | QIODevice::Append);
-        message.serialize(messageStream);
-        //if message unread, mark as read before opening view
-        QList<int> msgIdList;
-        if(index.data(UnReadStatus).toInt())
-            {
+   
+    
+    // contact Id
+    qint32 contactId = index.data(ContactId).toLongLong();  
+	    
+    //if message unread, mark as read before opening view
+    QList<int> msgIdList;
+    if(index.data(UnReadStatus).toInt())
+    {
         msgIdList.clear();
         msgIdList << messageId;
         ConversationsEngine::instance()->markMessagesRead(msgIdList);
-        }
+    }
+    
+    qint32 messageProperty = index.data(MessageProperty).toInt();
 
-        //switch view
-        QVariantList param;
-        param << MsgBaseView::UNIVIEWER;  // target view
-        param << MsgBaseView::CV; // source view
+    bool canForwardMessage  = true;
+    if (messageType == ConvergedMessage::Mms){
+        canForwardMessage = (messageProperty & EPreviewForward)? true:false;
+    } 
+    
+    //switch view
+    QVariantList param;
+    param << MsgBaseView::UNIVIEWER;  // target view
+    param << MsgBaseView::CV; // source view
 
-        param << contactId;
-        param << dataArray;
-        param << mMessageModel->rowCount();
-
-        emit switchView(param);
+    param << contactId;
+    param << messageId;
+    param << mMessageModel->rowCount();
+    if (canForwardMessage == true)
+    {
+      param << 1;
+    }
+    else
+   	{
+   		param << 0;
+   	}
+    emit switchView(param);
 }
 
 //---------------------------------------------------------------
@@ -1084,7 +1095,14 @@
             {
                 ConvergedMessageAddress* address = new ConvergedMessageAddress;
                 address->setAlias(contactList[i].mDisplayName);
-                address->setAddress(contactList[i].mPhoneNumber);
+                if(!contactList[i].mPhoneNumber.isEmpty())
+                {
+                    address->setAddress(contactList[i].mPhoneNumber);
+                }
+                else
+                {
+                    address->setAddress(contactList[i].mEmailAddress);
+                }
                 addresses.append(address);
             }
             message.addToRecipients(addresses);
@@ -1116,16 +1134,13 @@
 // @see header file
 //---------------------------------------------------------------
 void MsgConversationView::populateConversationsView()
-{
-    bool b = connect(ConversationsEngine::instance(), 
-                     SIGNAL(conversationModelUpdated()),
-                     this, 
-                     SLOT(scrollToBottom()));
-
+{    
+    mModelPopulated = true;
     mConversationList->setModel(mMessageModel);
     
     refreshView();
     scrollToBottom();
+    fetchMoreConversations();
 }
 
 //---------------------------------------------------------------
@@ -1174,26 +1189,6 @@
 }
 
 //---------------------------------------------------------------
-// MsgConversationView::validateMsgForForward
-// @see header file
-//---------------------------------------------------------------
-bool MsgConversationView::validateMsgForForward(int &messageType,
-    qint32 &messageId)
-{
-    bool retValue = true;
-    if (messageType == ConvergedMessage::Mms)
-    {
-        //Validate if the mms msg can be forwarded or not
-        MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck;
-        retValue = mmsConformanceCheck->validateMsgForForward(messageId);
-        
-        delete mmsConformanceCheck;
-    }
-
-    return retValue;
-}
-
-//---------------------------------------------------------------
 // MsgConversationView::vkbOpened
 // @see header file
 //---------------------------------------------------------------
@@ -1201,9 +1196,7 @@
 {
     mVkbopened = true;
     
-    mContactCardWidget->connectSignals(false);
-    
-    emit hideChrome(true);
+    emit vkbOpened(true);
     
     QRectF appRect = mVkbHost->applicationArea();    
     qreal spacing = 0.0;
@@ -1229,9 +1222,7 @@
 {
     mVkbopened = false;
     
-    mContactCardWidget->connectSignals(true);
-    
-    emit hideChrome(false);
+    emit vkbOpened(false);
     
     this->setMaximumHeight(-1);
     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
@@ -1251,27 +1242,25 @@
 //---------------------------------------------------------------
 // MsgConversationView::activateInputBlocker
 // @see header file
-//--------------------------------------------------------------
+//---------------------------------------------------------------
 void MsgConversationView::activateInputBlocker()
-    {
-        this->grabMouse();
-        this->grabKeyboard();
-    }
+{
+    mainWindow()->setInteractive(false);
+}
 
 //---------------------------------------------------------------
 // MsgConversationView::deactivateInputBlocker
 // @see header file
-//--------------------------------------------------------------
+//---------------------------------------------------------------
 void MsgConversationView::deactivateInputBlocker()
-    {    
-        this->ungrabKeyboard();
-        this->ungrabMouse();
-    }
+{
+    mainWindow()->setInteractive(true);
+}
 
 //---------------------------------------------------------------
 // MsgConversationView::handleProvisoningMsg
 // @see header file
-//--------------------------------------------------------------
+//---------------------------------------------------------------
 void MsgConversationView::handleProvisoningMsg(int msgId)
 	{
 		QString messageId;
@@ -1301,7 +1290,7 @@
 //---------------------------------------------------------------
 // MsgConversationView::onDialogSettingsLaunch
 // @see header file
-//--------------------------------------------------------------
+//---------------------------------------------------------------
 void MsgConversationView::onDialogSettingsLaunch(HbAction* action)
 {
     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
@@ -1319,7 +1308,7 @@
 //---------------------------------------------------------------
 // MsgConversationView::onDialogdeleteMsg
 // @see header file
-//--------------------------------------------------------------
+//---------------------------------------------------------------
 void MsgConversationView::onDialogdeleteMsg(HbAction* action)
 {
     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
@@ -1371,4 +1360,46 @@
     }
 }
 
+//---------------------------------------------------------------
+// MsgConversationView::onOrientationChanged
+// @see header file
+//---------------------------------------------------------------
+void MsgConversationView::onOrientationChanged(Qt::Orientation newOrientation)
+{
+    Q_UNUSED(newOrientation)
+
+    // On orientation change always make the preserved index(last visible item) to be visible
+    if(mVisibleIndex.isValid())
+    {
+    mConversationList->scrollTo(mVisibleIndex, HbAbstractItemView::PositionAtBottom);
+    mVisibleIndex = QModelIndex();
+    }
+}
+
+//---------------------------------------------------------------
+// MsgConversationView::onOrientationAboutToBeChanged
+// @see header file
+//---------------------------------------------------------------
+void MsgConversationView::onOrientationAboutToBeChanged()
+{
+    // Preserve the model index of the last visible item to be scrolled on orientation change
+    QList<HbAbstractViewItem *>items = mConversationList->visibleItems();
+    if (items.count() > 0) {
+        mVisibleIndex = items.last()->modelIndex();
+    }
+}
+
+//---------------------------------------------------------------
+// MsgConversationView::onViewReady
+// @see header file
+//---------------------------------------------------------------
+void MsgConversationView::onViewReady()
+{
+    mViewReady = true;
+    //Disconnect list View's signals, for avoiding execution of the default implementaion
+    disconnect(mainWindow(), SIGNAL(aboutToChangeOrientation()), mConversationList, 0);
+    disconnect(mainWindow(), SIGNAL(orientationChanged(Qt: rientation)), mConversationList, 0);
+    
+   fetchMoreConversations();
+}
 // EOF