messagingapp/msgui/msgapp/src/msgviewmanager.cpp
changeset 37 518b245aa84c
parent 25 84d9eb65b26f
child 41 25fe1fe642e3
--- a/messagingapp/msgui/msgapp/src/msgviewmanager.cpp	Mon May 03 12:29:07 2010 +0300
+++ b/messagingapp/msgui/msgapp/src/msgviewmanager.cpp	Fri Jun 25 15:47:40 2010 +0530
@@ -25,7 +25,8 @@
 #include <QSqlError>
 #include <HbApplication>
 #include <xqappmgr.h>
-#include <HbMessageBox.h>
+#include <hbmessagebox.h>
+#include <HbView>
 
 #include "conversationsengine.h"
 #include "msglistview.h"
@@ -38,35 +39,53 @@
 #include "ringbc.h"
 #include "unidatamodelloader.h"
 #include "unidatamodelplugininterface.h"
+#include "msgcontacthandler.h"
+#include "debugtraces.h"
+#include "msgaudiofetcherview.h"
 
 // LOCALIZATION
-#define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
-#define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
+#define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
 
 const qint64 NULL_CONVERSATIONID = -1;
 
-MsgViewManager::MsgViewManager(bool serviceRequest, HbMainWindow* mainWindow, QObject* parent) :
+MsgViewManager::MsgViewManager(bool serviceRequest, HbMainWindow* mainWindow, QObject* parent,int activityMsgId) :
     QObject(parent), mMainWindow(mainWindow), mUniEditor(0), mListView(0), mConversationView(0),
-        mUniViewer(0), mDraftsListView(0), mSettingsView(0), mBackAction(0), mServiceRequest(
-            serviceRequest), mConversationId(-1), mViewServiceRequest(false)
+        mUniViewer(0), mDraftsListView(0), mSettingsView(0), mAudioFetcherView(0), mBackAction(0),
+        mServiceRequest(serviceRequest), mConversationId(-1), mViewServiceRequest(false),mMessageId(-1)
 {
     //creating back action.
-    mBackAction = new HbAction(Hb::BackAction, this);
+    mBackAction = new HbAction(Hb::BackNaviAction, this);
     connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction()));
 
     //create clv as first view if not a service request.
     if (!mServiceRequest) {
+    
+    if(activityMsgId == NULL_CONVERSATIONID)
+        {
         QVariantList param;
         param << MsgBaseView::CLV;
         param << MsgBaseView::CLV;
         switchView(param);
+        }
+    else 
+        {
+        openUniEditorActivity(activityMsgId);
+        }
+    }
+    else
+    {
+        mDummyview = new HbView();
+        mMainWindow->addView(mDummyview);
+        mMainWindow->setCurrentView(mDummyview);
+        mViewTobeDeleted << mDummyview;
     }
 }
 
 MsgViewManager::~MsgViewManager()
 {
     // TODO Auto-generated destructor stub
+    mEditorData.clear();
 }
 
 void MsgViewManager::onBackAction()
@@ -92,12 +111,17 @@
 
     case MsgBaseView::CV:
     {
+	    mConversationId = -1; //reset the conversation view id since its closed
+		
         //Save content to drafts before switching to clv
         mConversationView->saveContentToDrafts();
 
         //marking messages as red in CV.
         mConversationView->markMessagesAsRead();
 
+        // reset the conversation id published
+        mConversationView->setPSCVId(false);
+
         //clearing content of cv.
         mConversationView->clearContent();
 
@@ -150,14 +174,6 @@
             break;
         }
 
-        //Now UE can be launched from viewer and on its back
-        //we need to clear viewer
-        if (mUniViewer) {
-            mMainWindow->removeView(mUniViewer);
-            delete mUniViewer;
-            mUniViewer = NULL;
-        }
-
         //switch to clv.
         if (mServiceRequest) {
             completeServiceRequest();
@@ -181,13 +197,20 @@
         }
         else {
             QVariantList param;
-            param << MsgBaseView::CV;
-            param << MsgBaseView::UNIVIEWER;
-            param << mConversationId;
+            if (mConversationId != -1)
+                {
+                    //this means CV is till open then just open the fresh CV
+                    param << MsgBaseView::CV;
+                    param << MsgBaseView::UNIVIEWER;
+                    param << mConversationView->conversationId();
+                }
+                else
+                {
+                    param << MsgBaseView::CLV;
+                    param << MsgBaseView::UNIVIEWER;
+                }
             switchView(param);
 
-            delete mUniViewer;
-            mUniViewer = NULL;
         }
         break;
     }
@@ -199,6 +222,19 @@
         switchView(param);
         break;
     }
+    case MsgBaseView::AUDIOFETCHER:
+    {
+        // switch back to previous view
+        QVariantList param;
+        param << mPreviousView;
+        param << MsgBaseView::AUDIOFETCHER;
+        if(mPreviousView == MsgBaseView::CV)
+        {
+            param << mConversationId;
+        }
+        switchView(param);
+        break;
+    }
     default:
     {
         break;
@@ -208,7 +244,10 @@
 
 void MsgViewManager::switchView(const QVariantList& data)
 {
+    QCRITICAL_WRITE("MsgViewManager::switchView start.");
+    
     int viewId = data.at(0).toInt();
+
     switch (viewId) {
     case MsgBaseView::DEFAULT:
     {
@@ -217,15 +256,16 @@
     }
     case MsgBaseView::CLV:
     {
-        switchToClv(data);
-        break;
-    }
+            switchToClv(data);
+            break;
+        }
 
-    case MsgBaseView::CV:
-    {
-        switchToCv(data);
-        break;
-    }
+        case MsgBaseView::CV:
+        {
+
+            switchToCv(data);
+            break;
+        }
 
     case MsgBaseView::DLV:
     {
@@ -250,9 +290,26 @@
         switchToMsgSettings(data);
         break;
     }
+    case MsgBaseView::AUDIOFETCHER:
+    {
+        switchToAudioFetcher(data);
+        break;
+    }
+    }
+    QCRITICAL_WRITE("MsgViewManager::switchView end.");
+}
+
+void MsgViewManager::deletePreviousView()
+{
+    while(mViewTobeDeleted.count())
+    {
+        HbView* v = mViewTobeDeleted.takeAt(0);
+        mMainWindow->removeView(v);
+        delete v;
     }
 }
 
+
 void MsgViewManager::send(const qint32 contactId, const QString phoneNumber,
     const QString displayName)
 {
@@ -348,6 +405,11 @@
     if (conversationId < 0) {
         param << MsgBaseView::CLV;
         param << MsgBaseView::SERVICE;
+
+        if( mCurrentView == MsgBaseView::CV && mConversationView)
+            {
+            mConversationView->setPSCVId(false);
+            }
     }
     else {
         param << MsgBaseView::CV;
@@ -423,27 +485,53 @@
 
 void MsgViewManager::switchToClv(const QVariantList& data)
 {
-    //switch to CLV.
-    mCurrentView = MsgBaseView::CLV;
     mPreviousView = data.at(1).toInt();
 
-    // delete case from viewer service  
+    // delete case from viewer service
     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
-        // quit the application 
+        // quit the application
         HbApplication::quit();
     }
 
-    //remove the settings view from main window
-    if (mSettingsView) {
-        mMainWindow->removeView(mSettingsView);
-        mSettingsView->setNavigationAction(mBackAction);
-        connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction()), Qt::UniqueConnection);
+    // this is the case when viewer/editor is opened and contacts update takes
+    // place resulting in CV close, the view should directly come to CLV 
+    // bypassing the CV
+    if ((mCurrentView == MsgBaseView::UNIVIEWER 
+            && mPreviousView != MsgBaseView::UNIVIEWER)
+            || (mCurrentView == MsgBaseView::UNIEDITOR
+                    && mPreviousView != MsgBaseView::UNIEDITOR))
+    {
+        //dont do anything
+        //wait for the back from viewer/editor
+        //and reset the open CV id
+        mConversationId = -1;
+        return;
     }
+    
+    //delete UniEditor
+    if (mUniEditor)
+    {
+        appendViewToBeDeleted(mUniEditor);
+        mUniEditor = NULL;
+    }
+
+    //delete UniViewer
+    if (mUniViewer)
+    {
+        appendViewToBeDeleted(mUniViewer);
+        mUniViewer = NULL;
+    }
+
     if (mConversationView) {
+        mConversationView->saveContentToDrafts();
         //clearing content of cv.
         mConversationView->clearContent();
+        //reset the open CV id
+        mConversationId = -1;
     }
-
+    
+    //switch to CLV.
+    mCurrentView = MsgBaseView::CLV;
     if (!mListView) {
         mListView = new MsgListView();
         mListView->setNavigationAction(mBackAction);
@@ -452,19 +540,6 @@
         mMainWindow->addView(mListView);
     }
 
-    //delete uni editor.
-    if (mUniEditor) {
-        mMainWindow->removeView(mUniEditor);
-        delete mUniEditor;
-        mUniEditor = NULL;
-    }
-
-    if (mUniViewer) {
-        mMainWindow->removeView(mUniViewer);
-        delete mUniViewer;
-        mUniViewer = NULL;
-    }
-
     mMainWindow->setCurrentView(mListView);
 }
 
@@ -476,20 +551,28 @@
 
     // delete case from viewer service
     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
-        // quit the application 
+        // quit the application
         HbApplication::quit();
     }
 
-    //delete uni editor.
-    if (mUniEditor) {
-        mMainWindow->removeView(mUniEditor);
-        delete mUniEditor;
+    // delete Audio Fetcher view
+    if(mAudioFetcherView)
+    {
+        appendViewToBeDeleted(mAudioFetcherView);
+        mAudioFetcherView = NULL;
+    }
+
+    //delete UniEditor
+    if (mUniEditor)
+    {
+        appendViewToBeDeleted(mUniEditor);
         mUniEditor = NULL;
     }
 
-    if (mUniViewer) {
-        mMainWindow->removeView(mUniViewer);
-        delete mUniViewer;
+    //delete UniViewer
+    if (mUniViewer)
+    {
+        appendViewToBeDeleted(mUniViewer);
         mUniViewer = NULL;
     }
 
@@ -497,25 +580,35 @@
     qint64 conversationId;
     if (var.type() == QVariant::String) {
         QString phoneNumber = var.toString();
-        conversationId = findConversationId(phoneNumber);
+        qint32 contactId = findContactId(phoneNumber);
+        if (contactId != -1) {
+            conversationId = ConversationsEngine::instance()->getConversationIdFromContactId(contactId);
+        }
+        else {
+            conversationId = findConversationId(phoneNumber);
+        }
 
         if (conversationId == NULL_CONVERSATIONID) {
             QVariantList param;
             param << MsgBaseView::CLV;
             param << MsgBaseView::CV;
+
+            if( mCurrentView == MsgBaseView::CV && mConversationView){
+                mConversationView->setPSCVId(false);
+                }
+
             switchView(param);
             return;
         }
     }
     else if (var.type() == QVariant::Invalid) {
-        // this case comes when a message is deleted from 
-        // Unified viewer  set curent view as conversation view 
+        // this case comes when a message is deleted from
+        // Unified viewer  set curent view as conversation view
         // and return
         mMainWindow->setCurrentView(mConversationView);
 
-        delete mUniViewer;
-        mUniViewer = NULL;
-
+		// publish already opened conversation's id
+        mConversationView->setPSCVId(true);
         return;
     }
     else {
@@ -532,15 +625,15 @@
 
         mMainWindow->addView(mConversationView);
     }
+    else if (mConversationView->conversationId() != mConversationId){
+  		//Save content to drafts before switching to different CV
+        mConversationView->saveContentToDrafts();
+        //clearing content of current cv.
+        mConversationView->clearContent();
+    }
 
     mConversationView->openConversation(conversationId);
-
-    if (mServiceRequest) {
-        mMainWindow->setCurrentView(mConversationView);
-    }
-    else {
-        mMainWindow->setCurrentView(mConversationView);
-    }
+    mMainWindow->setCurrentView(mConversationView);
 }
 
 void MsgViewManager::switchToDlv(const QVariantList& data)
@@ -549,13 +642,6 @@
     mCurrentView = MsgBaseView::DLV;
     mPreviousView = data.at(1).toInt();
 
-    //delete uni editor.
-    if (mUniEditor) {
-        mMainWindow->removeView(mUniEditor);
-        delete mUniEditor;
-        mUniEditor = NULL;
-    }
-
     if (!mDraftsListView) {
         mDraftsListView = new DraftsListView();
         mDraftsListView->setNavigationAction(mBackAction);
@@ -573,18 +659,43 @@
      * Editor is tried to open again before exiting the previously
      * opened editor. Multi taping in DLV or Forward.
      */
-    if (mUniEditor) {
+    if (mUniEditor && !mAudioFetcherView)
+    {
         return;
     }
 
     mCurrentView = MsgBaseView::UNIEDITOR;
-    mPreviousView = data.at(1).toInt();
+    if(MsgBaseView::AUDIOFETCHER != data.at(1).toInt())
+    {
+        mPreviousView = data.at(1).toInt();
+    }
 
-    if (mConversationView) {
+    // delete Audio Fetcher view
+    if(mAudioFetcherView)
+    {
+        appendViewToBeDeleted(mAudioFetcherView);
+        mAudioFetcherView = NULL;
+    }
+
+    // delete UniViewer
+	if (mUniViewer )
+	{
+	    appendViewToBeDeleted(mUniViewer);
+	    mUniViewer = NULL;
+	}
+
+    if (mConversationView)
+    {
         //clearing content of cv.
         mConversationView->clearContent();
     }
 
+    // reset conversation id published
+    if(mPreviousView == MsgBaseView::CV && mConversationView)
+    {
+        mConversationView->setPSCVId(false);
+    }
+
     //swich to unieditor.
     if (!mUniEditor) {
         mUniEditor = new MsgUnifiedEditorView();
@@ -603,19 +714,15 @@
         }
 
         if (MsgBaseView::DLV == mPreviousView) {
-            mUniEditor->openDraftsMessage(editorData);
+            //Populate editor after view ready indication 
+            populateUniEditorAfterViewReady(editorData);
         }
         else {
             mUniEditor->populateContent(editorData);
         }
     }
 
-    if (mServiceRequest) {
-        mMainWindow->setCurrentView(mUniEditor);
-    }
-    else {
-        mMainWindow->setCurrentView(mUniEditor);
-    }
+    mMainWindow->setCurrentView(mUniEditor);
 }
 
 void MsgViewManager::switchToUniViewer(const QVariantList& data)
@@ -634,23 +741,25 @@
     //switch to univiewer.
     if (data.length() > 2) {
         qint32 contactId = data.at(2).toLongLong();
-        QByteArray dataArray = data.at(3).toByteArray();
+        qint32 messageId = data.at(3).toInt();
         int msgCount = data.at(4).toInt();
+        int canForwardMessage = data.at(5).toInt();
 
-        ConvergedMessage *message = new ConvergedMessage;
-        QDataStream stream(&dataArray, QIODevice::ReadOnly);
-        message->deserialize(stream);
-        qint32 messageId = message->id()->getId();
         if (!mUniViewer) {
-            mUniViewer = new UnifiedViewer(messageId);
+            mUniViewer = new UnifiedViewer(messageId, canForwardMessage);
             mUniViewer->setNavigationAction(mBackAction);
             mMainWindow->addView(mUniViewer);
             connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
                 SLOT(switchView(const QVariantList&)));
         }
         mUniViewer->populateContent(messageId, true, msgCount);
-        delete message;
     }
+
+    if(mPreviousView==MsgBaseView::CV && mConversationView)
+        {
+        mConversationView->setPSCVId(false);
+        }
+
     mMainWindow->setCurrentView(mUniViewer);
 }
 void MsgViewManager::switchToMsgSettings(const QVariantList& data)
@@ -659,11 +768,22 @@
     mPreviousView = data.at(1).toInt();
 
     if (!mSettingsView) {
-        mSettingsView = new MsgSettingsView();
+
+        MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
+        if (mPreviousView == MsgBaseView::UNIEDITOR || mPreviousView
+                        == MsgBaseView::CV)
+                {
+                    view = (MsgSettingsView::SettingsView)data.at(2).toInt();
+                }
+
+        mSettingsView = new MsgSettingsView(view);
         mSettingsView->setNavigationAction(mBackAction);
         mMainWindow->addView(mSettingsView);
         mMainWindow->setCurrentView(mSettingsView);
     }
+    if(mPreviousView==MsgBaseView::CV && mConversationView){
+        mConversationView->setPSCVId(false);
+        }
 }
 
 void MsgViewManager::handleDefault(const QVariantList& data)
@@ -675,9 +795,9 @@
         mCurrentView = mPreviousView;
         mPreviousView = previousViewId;
         //remove the settings view from main window
-        if (mSettingsView) {
-            mMainWindow->removeView(mSettingsView);
-            delete mSettingsView;
+        if (mSettingsView)
+        {
+            appendViewToBeDeleted(mSettingsView);
             mSettingsView = NULL;
         }
         switch (mCurrentView) {
@@ -717,7 +837,7 @@
 {
     int msgType;
     int msgSubType;
-
+    mMessageId = msgId;
     qint32 messageId(msgId);
     ConversationsEngine::instance()->markAsReadAndGetType(messageId, msgType, msgSubType);
 
@@ -747,14 +867,9 @@
     default:
     {
         // for un supported message show delete option
-        bool result = HbMessageBox::question(LOC_DELETE_MESSAGE, LOC_BUTTON_DELETE,
-            LOC_BUTTON_CANCEL);
-        if (result) {
-            QList<int> msgIdList;
-            msgIdList << msgId;
-            ConversationsEngine::instance()->deleteMessages(msgIdList);
-        }
-        HbApplication::quit(); // exit after handling
+        HbMessageBox::question(LOC_DELETE_MESSAGE,this,
+                               SLOT(onDialogDeleteMsg(HbAction*)),
+                               HbMessageBox::Delete | HbMessageBox::Cancel);
         break;
     }
     }
@@ -788,29 +903,10 @@
 // ----------------------------------------------------------------------------
 void MsgViewManager::handleRingtoneMsg(int msgId)
 {
-    if (RingBc::askSaveQuery()) {
-        UniDataModelLoader* pluginLoader = new UniDataModelLoader();
-        UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin(
-            ConvergedMessage::BioMsg);
-        pluginInterface->setMessageId(msgId);
-        UniMessageInfoList attachments = pluginInterface->attachmentList();
-
-        QString attachmentPath = attachments.at(0)->path();
-
-        RingBc* ringBc = new RingBc();
-        ringBc->saveTone(attachmentPath);
-
-        // clear attachement list : its allocated at data model
-        while (!attachments.isEmpty()) {
-            delete attachments.takeFirst();
-        }
-
-        delete ringBc;
-        delete pluginLoader;
-    }
-
-    // close the application once its handled
-    HbApplication::quit();
+    mMessageId = msgId;
+    HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this,
+                           SLOT(onDialogSaveTone(HbAction*)), 
+                           HbMessageBox::Save | HbMessageBox::Cancel);
 }
 
 // ----------------------------------------------------------------------------
@@ -844,3 +940,218 @@
     // close the application once its handled
     HbApplication::quit();
 }
+
+void MsgViewManager::setViewInteractive()
+{
+    if(!mMainWindow->isInteractive())
+    {
+        mMainWindow->setInteractive(true);
+    }
+
+    disconnect(mMainWindow, SIGNAL(viewReady()),this,SLOT(setViewInteractive()));
+}
+
+void  MsgViewManager::appendViewToBeDeleted(HbView* view)
+{
+    if (view)
+    {
+        mViewTobeDeleted << view;
+        connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(deletePreviousView()), Qt::UniqueConnection);
+    }
+}
+
+// ----------------------------------------------------------------------------
+// MsgViewManager::populateEditorAfterViewReady
+// @see header
+// ----------------------------------------------------------------------------
+void MsgViewManager::populateUniEditorAfterViewReady(const QVariantList& editorData)
+	{
+	 //Save the editor data and use it in ViewReady handler
+	 mEditorData = editorData;	 
+	 connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(populateUniEditorView()));
+	}
+
+// ----------------------------------------------------------------------------
+// MsgViewManager::populateUniEditorView
+// @see header
+// ----------------------------------------------------------------------------
+void MsgViewManager::populateUniEditorView()
+    {
+    if (mUniEditor)
+        {
+        mUniEditor->openDraftsMessage(mEditorData);
+        }
+    mEditorData.clear();
+    
+    disconnect(mMainWindow, SIGNAL(viewReady()), this,
+            SLOT(populateUniEditorView()));
+}
+
+// ----------------------------------------------------------------------------
+// MsgViewManager::onDialogDeleteMsg
+// @see header
+// ----------------------------------------------------------------------------
+void MsgViewManager::onDialogDeleteMsg(HbAction* action)
+{
+    HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
+    if (action == dlg->actions().at(0)) {
+        QList<int> msgIdList;
+        msgIdList << mMessageId;
+        ConversationsEngine::instance()->deleteMessages(msgIdList);
+    }
+    HbApplication::quit(); // exit after handling
+}
+
+// ----------------------------------------------------------------------------
+// MsgViewManager::onDialogSaveTone
+// @see header
+// ----------------------------------------------------------------------------
+void MsgViewManager::onDialogSaveTone(HbAction* action)
+    {
+        HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
+        if (action == dlg->actions().at(0)) {
+            UniDataModelLoader* pluginLoader = new UniDataModelLoader();
+            UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin(
+                ConvergedMessage::BioMsg);
+            pluginInterface->setMessageId(mMessageId);
+            UniMessageInfoList attachments = pluginInterface->attachmentList();
+
+            QString attachmentPath = attachments.at(0)->path();
+
+            RingBc* ringBc = new RingBc();
+            ringBc->saveTone(attachmentPath);
+
+            // clear attachement list : its allocated at data model
+            while (!attachments.isEmpty()) {
+                delete attachments.takeFirst();
+            }
+
+            delete ringBc;
+            delete pluginLoader;
+        }
+
+        // close the application once its handled
+        HbApplication::quit();
+}
+
+// ----------------------------------------------------------------------------
+// MsgViewManager::currentView
+// @see header
+// ----------------------------------------------------------------------------
+int MsgViewManager::currentView()
+    {
+    return mCurrentView;
+    }
+
+// ----------------------------------------------------------------------------
+// MsgViewManager::switchToAudioFetcher
+// @see header
+// ----------------------------------------------------------------------------
+void MsgViewManager::switchToAudioFetcher(const QVariantList& data)
+    {
+    /**
+     * Audio Fetcher is tried to open again
+     */
+    if(mAudioFetcherView)
+        {
+        return;
+        }
+
+    //switch to Audio Fetcher view
+    mCurrentView = MsgBaseView::AUDIOFETCHER;
+    mPreviousView = data.at(1).toInt();
+    QVariantList editorData;
+    // i=2 because view manager consumed first two args
+    for (int i = 2; i < data.length(); i++) {
+        editorData << data.at(i);
+    }
+    mAudioFetcherView = new MsgAudioFetcherView(editorData);
+    mAudioFetcherView->setNavigationAction(mBackAction);
+    connect(mAudioFetcherView, SIGNAL(switchView(const QVariantList&)), this,
+            SLOT(switchView(const QVariantList&)));
+
+    if(mPreviousView==MsgBaseView::CV && mConversationView)
+        {
+        mConversationView->setPSCVId(false);
+        }
+
+    mMainWindow->addView(mAudioFetcherView);
+    mMainWindow->setCurrentView(mAudioFetcherView);
+    }
+
+// ----------------------------------------------------------------------------
+// MsgViewManager::saveContentToDraft
+// @see header
+// ----------------------------------------------------------------------------
+int MsgViewManager::saveContentToDraft()
+    {
+    int msgId = NULL_CONVERSATIONID;
+    if( mCurrentView == MsgBaseView::CV )
+        {
+        msgId = mConversationView->saveContentToDrafts();
+        }
+    else if( mCurrentView ==MsgBaseView::UNIEDITOR)
+        {
+        msgId  = mUniEditor->saveContentToDrafts();
+        }
+    return msgId;
+    }
+
+// ----------------------------------------------------------------------------
+// MsgViewManager::saveContentToDraft
+// @see header
+// ----------------------------------------------------------------------------
+void MsgViewManager::openUniEditorActivity(int activityMsgId)
+{
+    int msgType;
+    int msgSubType;
+  
+    qint32 messageId(activityMsgId);
+    // get the message type
+    ConversationsEngine::instance()->markAsReadAndGetType(messageId, msgType, msgSubType);
+    
+    if (!mUniEditor) {
+           mUniEditor = new MsgUnifiedEditorView();
+           mMainWindow->addView(mUniEditor);
+           mUniEditor->setNavigationAction(mBackAction);
+           connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this,
+               SLOT(switchView(const QVariantList&)));
+       }
+    
+    // buffer data to open the draft message
+    ConvergedMessageId convergedMsgId(activityMsgId);
+    ConvergedMessage message;
+    message.setMessageType((ConvergedMessage::MessageType) msgType);
+    message.setMessageId(convergedMsgId);
+
+    // Launch uni-editor view
+    QByteArray dataArray;
+    QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append);
+    message.serialize(messageStream);
+    
+    QVariantList editorData;
+    editorData << dataArray;
+    mUniEditor->openDraftsMessage(editorData);
+    
+    // set the current view
+    mCurrentView = MsgBaseView::UNIEDITOR;
+    mMainWindow->setCurrentView(mUniEditor);
+}
+
+// ----------------------------------------------------------------------------
+// MsgViewManager::findContactId
+// @see header
+// ----------------------------------------------------------------------------
+qint32 MsgViewManager::findContactId(QString address)
+    {
+    QString displayLabel;
+    int count;
+    int localId =
+            MsgContactHandler::resolveContactDisplayName(address,
+                                                         displayLabel,
+                                                         count);
+
+        return localId;
+    }
+
+//EOF