messagingapp/msgui/msgapp/src/msgviewmanager.cpp
changeset 43 35b64624a9e7
parent 34 84197e66a4bd
child 44 36f374c67aa8
equal deleted inserted replaced
34:84197e66a4bd 43:35b64624a9e7
    37 #include "msgsettingsview.h"
    37 #include "msgsettingsview.h"
    38 #include "convergedmessageid.h"
    38 #include "convergedmessageid.h"
    39 #include "ringbc.h"
    39 #include "ringbc.h"
    40 #include "unidatamodelloader.h"
    40 #include "unidatamodelloader.h"
    41 #include "unidatamodelplugininterface.h"
    41 #include "unidatamodelplugininterface.h"
       
    42 #include "msgcontacthandler.h"
       
    43 #include "debugtraces.h"
       
    44 #include "msgaudiofetcherview.h"
    42 
    45 
    43 // LOCALIZATION
    46 // LOCALIZATION
    44 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
    47 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
    45 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
    48 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
    46 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
    49 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
    47 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
    50 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
    48 #define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
    51 #define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
    49 
    52 
    50 const qint64 NULL_CONVERSATIONID = -1;
    53 const qint64 NULL_CONVERSATIONID = -1;
    51 
    54 
    52 MsgViewManager::MsgViewManager(bool serviceRequest, HbMainWindow* mainWindow, QObject* parent) :
    55 MsgViewManager::MsgViewManager(bool serviceRequest, HbMainWindow* mainWindow, QObject* parent,int activityMsgId) :
    53     QObject(parent), mMainWindow(mainWindow), mUniEditor(0), mListView(0), mConversationView(0),
    56     QObject(parent), mMainWindow(mainWindow), mUniEditor(0), mListView(0), mConversationView(0),
    54         mUniViewer(0), mDraftsListView(0), mSettingsView(0), mBackAction(0), mServiceRequest(
    57         mUniViewer(0), mDraftsListView(0), mSettingsView(0), mAudioFetcherView(0), mBackAction(0),
    55             serviceRequest), mConversationId(-1), mViewServiceRequest(false),mMessageId(-1)
    58         mServiceRequest(serviceRequest), mConversationId(-1), mViewServiceRequest(false),mMessageId(-1)
    56 {
    59 {
    57     //creating back action.
    60     //creating back action.
    58     mBackAction = new HbAction(Hb::BackNaviAction, this);
    61     mBackAction = new HbAction(Hb::BackNaviAction, this);
    59     connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction()));
    62     connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction()));
    60 
    63 
    61     //create clv as first view if not a service request.
    64     //create clv as first view if not a service request.
    62     if (!mServiceRequest) {
    65     if (!mServiceRequest) {
       
    66     
       
    67     if(activityMsgId == NULL_CONVERSATIONID)
       
    68         {
    63         QVariantList param;
    69         QVariantList param;
    64         param << MsgBaseView::CLV;
    70         param << MsgBaseView::CLV;
    65         param << MsgBaseView::CLV;
    71         param << MsgBaseView::CLV;
    66         switchView(param);
    72         switchView(param);
       
    73         }
       
    74     else 
       
    75         {
       
    76         openUniEditorActivity(activityMsgId);
       
    77         }
    67     }
    78     }
    68     else
    79     else
    69     {
    80     {
    70         mDummyview = new HbView();
    81         mDummyview = new HbView();
    71         mMainWindow->addView(mDummyview);
    82         mMainWindow->addView(mDummyview);
    75 }
    86 }
    76 
    87 
    77 MsgViewManager::~MsgViewManager()
    88 MsgViewManager::~MsgViewManager()
    78 {
    89 {
    79     // TODO Auto-generated destructor stub
    90     // TODO Auto-generated destructor stub
       
    91     mEditorData.clear();
    80 }
    92 }
    81 
    93 
    82 void MsgViewManager::onBackAction()
    94 void MsgViewManager::onBackAction()
    83 {
    95 {
    84     switch (mCurrentView) {
    96     switch (mCurrentView) {
   108         //marking messages as red in CV.
   120         //marking messages as red in CV.
   109         mConversationView->markMessagesAsRead();
   121         mConversationView->markMessagesAsRead();
   110 
   122 
   111         // reset the conversation id published
   123         // reset the conversation id published
   112         mConversationView->setPSCVId(false);
   124         mConversationView->setPSCVId(false);
   113         
   125 
   114         //clearing content of cv.
   126         //clearing content of cv.
   115         mConversationView->clearContent();
   127         mConversationView->clearContent();
   116 
   128 
   117         // if service request for veiwer the just switch to univiewer.
   129         // if service request for veiwer the just switch to univiewer.
   118         if (mViewServiceRequest) {
   130         if (mViewServiceRequest) {
   200         param << MsgBaseView::DEFAULT;
   212         param << MsgBaseView::DEFAULT;
   201         param << MsgBaseView::MSGSETTINGS;
   213         param << MsgBaseView::MSGSETTINGS;
   202         switchView(param);
   214         switchView(param);
   203         break;
   215         break;
   204     }
   216     }
       
   217     case MsgBaseView::AUDIOFETCHER:
       
   218     {
       
   219         // switch to CV.
       
   220         QVariantList param;
       
   221         param << mPreviousView;
       
   222         param << MsgBaseView::AUDIOFETCHER;
       
   223         if(mPreviousView == MsgBaseView::CV)
       
   224         {
       
   225             param << mConversationId;
       
   226         }
       
   227         switchView(param);
       
   228     }
   205     default:
   229     default:
   206     {
   230     {
   207         break;
   231         break;
   208     }
   232     }
   209     }
   233     }
   210 }
   234 }
   211 
   235 
   212 void MsgViewManager::switchView(const QVariantList& data)
   236 void MsgViewManager::switchView(const QVariantList& data)
   213 {
   237 {
       
   238     QCRITICAL_WRITE("MsgViewManager::switchView start.");
   214     
   239     
   215     int viewId = data.at(0).toInt();
   240     int viewId = data.at(0).toInt();
   216     
   241 
   217     switch (viewId) {
   242     switch (viewId) {
   218     case MsgBaseView::DEFAULT:
   243     case MsgBaseView::DEFAULT:
   219     {
   244     {
   220         handleDefault(data);
   245         handleDefault(data);
   221         break;
   246         break;
   254     case MsgBaseView::MSGSETTINGS:
   279     case MsgBaseView::MSGSETTINGS:
   255     {
   280     {
   256         switchToMsgSettings(data);
   281         switchToMsgSettings(data);
   257         break;
   282         break;
   258     }
   283     }
   259     }
   284     case MsgBaseView::AUDIOFETCHER:
       
   285     {
       
   286         switchToAudioFetcher(data);
       
   287         break;
       
   288     }
       
   289     }
       
   290     QCRITICAL_WRITE("MsgViewManager::switchView end.");
   260 }
   291 }
   261 
   292 
   262 void MsgViewManager::deletePreviousView()
   293 void MsgViewManager::deletePreviousView()
   263 {
   294 {
   264     while(mViewTobeDeleted.count())
   295     while(mViewTobeDeleted.count())
   265     {
   296     {
   266         HbView* v = mViewTobeDeleted.takeAt(0);
   297         HbView* v = mViewTobeDeleted.takeAt(0);
   267         mMainWindow->removeView(v);
   298         mMainWindow->removeView(v);
   268         delete v;
   299         delete v;
   269     }
   300     }
   270     disconnect(mMainWindow, SIGNAL(viewReady()), this, SLOT(deletePreviousView()));
       
   271 }
   301 }
   272 
   302 
   273 
   303 
   274 void MsgViewManager::send(const qint32 contactId, const QString phoneNumber,
   304 void MsgViewManager::send(const qint32 contactId, const QString phoneNumber,
   275     const QString displayName)
   305     const QString displayName)
   364     QVariantList param;
   394     QVariantList param;
   365 
   395 
   366     if (conversationId < 0) {
   396     if (conversationId < 0) {
   367         param << MsgBaseView::CLV;
   397         param << MsgBaseView::CLV;
   368         param << MsgBaseView::SERVICE;
   398         param << MsgBaseView::SERVICE;
   369         
   399 
   370         if( mCurrentView == MsgBaseView::CV && mConversationView)
   400         if( mCurrentView == MsgBaseView::CV && mConversationView)
   371             {
   401             {
   372             mConversationView->setPSCVId(false);
   402             mConversationView->setPSCVId(false);
   373             }
   403             }
   374     }
   404     }
   448 {
   478 {
   449     //switch to CLV.
   479     //switch to CLV.
   450     mCurrentView = MsgBaseView::CLV;
   480     mCurrentView = MsgBaseView::CLV;
   451     mPreviousView = data.at(1).toInt();
   481     mPreviousView = data.at(1).toInt();
   452 
   482 
   453     // delete case from viewer service  
   483     // delete case from viewer service
   454     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
   484     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
   455         // quit the application 
   485         // quit the application
   456         HbApplication::quit();
   486         HbApplication::quit();
       
   487     }
       
   488 
       
   489     //delete UniEditor
       
   490     if (mUniEditor)
       
   491     {
       
   492         appendViewToBeDeleted(mUniEditor);
       
   493         mUniEditor = NULL;
       
   494     }
       
   495 
       
   496     //delete UniViewer
       
   497     if (mUniViewer)
       
   498     {
       
   499         appendViewToBeDeleted(mUniViewer);
       
   500         mUniViewer = NULL;
   457     }
   501     }
   458 
   502 
   459     if (mConversationView) {
   503     if (mConversationView) {
   460         mConversationView->saveContentToDrafts();
   504         mConversationView->saveContentToDrafts();
   461         //clearing content of cv.
   505         //clearing content of cv.
   469             SLOT(switchView(const QVariantList&)));
   513             SLOT(switchView(const QVariantList&)));
   470         mMainWindow->addView(mListView);
   514         mMainWindow->addView(mListView);
   471     }
   515     }
   472 
   516 
   473     mMainWindow->setCurrentView(mListView);
   517     mMainWindow->setCurrentView(mListView);
   474     
       
   475     //delete UniEditor
       
   476     if (mUniEditor)
       
   477     {
       
   478         appendViewToBeDeleted(mUniEditor);
       
   479         mUniEditor = NULL;
       
   480     }
       
   481     
       
   482     //delete UniViewer
       
   483     if (mUniViewer)
       
   484     {
       
   485         appendViewToBeDeleted(mUniViewer);
       
   486         mUniViewer = NULL;
       
   487     }
       
   488 }
   518 }
   489 
   519 
   490 void MsgViewManager::switchToCv(const QVariantList& data)
   520 void MsgViewManager::switchToCv(const QVariantList& data)
   491 {
   521 {
   492     //switch to CV.
   522     //switch to CV.
   493     mCurrentView = MsgBaseView::CV;
   523     mCurrentView = MsgBaseView::CV;
   494     mPreviousView = data.at(1).toInt();
   524     mPreviousView = data.at(1).toInt();
   495 
   525 
   496     // delete case from viewer service
   526     // delete case from viewer service
   497     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
   527     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
   498         // quit the application 
   528         // quit the application
   499         HbApplication::quit();
   529         HbApplication::quit();
       
   530     }
       
   531 
       
   532     // delete Audio Fetcher view
       
   533     if(mAudioFetcherView)
       
   534     {
       
   535         appendViewToBeDeleted(mAudioFetcherView);
       
   536         mAudioFetcherView = NULL;
       
   537     }
       
   538 
       
   539     //delete UniEditor
       
   540     if (mUniEditor)
       
   541     {
       
   542         appendViewToBeDeleted(mUniEditor);
       
   543         mUniEditor = NULL;
       
   544     }
       
   545 
       
   546     //delete UniViewer
       
   547     if (mUniViewer)
       
   548     {
       
   549         appendViewToBeDeleted(mUniViewer);
       
   550         mUniViewer = NULL;
   500     }
   551     }
   501 
   552 
   502     QVariant var = data.at(2);
   553     QVariant var = data.at(2);
   503     qint64 conversationId;
   554     qint64 conversationId;
   504     if (var.type() == QVariant::String) {
   555     if (var.type() == QVariant::String) {
   505         QString phoneNumber = var.toString();
   556         QString phoneNumber = var.toString();
   506         conversationId = findConversationId(phoneNumber);
   557         qint32 contactId = findContactId(phoneNumber);
       
   558         if (contactId != -1) {
       
   559             conversationId = ConversationsEngine::instance()->getConversationIdFromContactId(contactId);
       
   560         }
       
   561         else {
       
   562             conversationId = findConversationId(phoneNumber);
       
   563         }
   507 
   564 
   508         if (conversationId == NULL_CONVERSATIONID) {
   565         if (conversationId == NULL_CONVERSATIONID) {
   509             QVariantList param;
   566             QVariantList param;
   510             param << MsgBaseView::CLV;
   567             param << MsgBaseView::CLV;
   511             param << MsgBaseView::CV;
   568             param << MsgBaseView::CV;
   512             
   569 
   513             if( mCurrentView == MsgBaseView::CV && mConversationView){
   570             if( mCurrentView == MsgBaseView::CV && mConversationView){
   514                 mConversationView->setPSCVId(false);
   571                 mConversationView->setPSCVId(false);
   515                 }
   572                 }
   516             
   573 
   517             switchView(param);
   574             switchView(param);
   518             return;
   575             return;
   519         }
   576         }
   520     }
   577     }
   521     else if (var.type() == QVariant::Invalid) {
   578     else if (var.type() == QVariant::Invalid) {
   522         // this case comes when a message is deleted from 
   579         // this case comes when a message is deleted from
   523         // Unified viewer  set curent view as conversation view 
   580         // Unified viewer  set curent view as conversation view
   524         // and return
   581         // and return
   525         mMainWindow->setCurrentView(mConversationView);
   582         mMainWindow->setCurrentView(mConversationView);
   526 		
   583 
   527 		// publish already opened conversation's id
   584 		// publish already opened conversation's id
   528         mConversationView->setPSCVId(true);
   585         mConversationView->setPSCVId(true);
   529 		
       
   530         if (mUniViewer)
       
   531         {
       
   532             appendViewToBeDeleted(mUniViewer);
       
   533             mUniViewer = NULL;
       
   534         }
       
   535 
       
   536         return;
   586         return;
   537     }
   587     }
   538     else {
   588     else {
   539         conversationId = var.toLongLong();
   589         conversationId = var.toLongLong();
   540     }
   590     }
   552     else if (mConversationView->conversationId() != mConversationId){
   602     else if (mConversationView->conversationId() != mConversationId){
   553   		//Save content to drafts before switching to different CV
   603   		//Save content to drafts before switching to different CV
   554         mConversationView->saveContentToDrafts();
   604         mConversationView->saveContentToDrafts();
   555         //clearing content of current cv.
   605         //clearing content of current cv.
   556         mConversationView->clearContent();
   606         mConversationView->clearContent();
   557   	}	
   607     }
   558 
   608 
   559     mConversationView->openConversation(conversationId);
   609     mConversationView->openConversation(conversationId);
   560 
   610     mMainWindow->setCurrentView(mConversationView);
   561     if (mServiceRequest) {
       
   562         mMainWindow->setCurrentView(mConversationView);
       
   563     }
       
   564     else {
       
   565         mMainWindow->setCurrentView(mConversationView);
       
   566     }
       
   567     
       
   568     //delete UniEditor
       
   569     if (mUniEditor)
       
   570     {
       
   571         appendViewToBeDeleted(mUniEditor);
       
   572         mUniEditor = NULL;
       
   573     }
       
   574     
       
   575     //delete UniViewer
       
   576     if (mUniViewer)
       
   577     {
       
   578         appendViewToBeDeleted(mUniViewer);
       
   579         mUniViewer = NULL;
       
   580     }
       
   581 }
   611 }
   582 
   612 
   583 void MsgViewManager::switchToDlv(const QVariantList& data)
   613 void MsgViewManager::switchToDlv(const QVariantList& data)
   584 {
   614 {
   585     //switch to DLV.
   615     //switch to DLV.
   601 {
   631 {
   602     /**
   632     /**
   603      * Editor is tried to open again before exiting the previously
   633      * Editor is tried to open again before exiting the previously
   604      * opened editor. Multi taping in DLV or Forward.
   634      * opened editor. Multi taping in DLV or Forward.
   605      */
   635      */
   606     if (mUniEditor) {
   636     if (mUniEditor && !mAudioFetcherView)
       
   637     {
   607         return;
   638         return;
   608     }
   639     }
   609 
   640 
   610     mCurrentView = MsgBaseView::UNIEDITOR;
   641     mCurrentView = MsgBaseView::UNIEDITOR;
   611     mPreviousView = data.at(1).toInt();
   642     mPreviousView = data.at(1).toInt();
   612 
   643 
   613     if (mConversationView) {
   644     // delete Audio Fetcher view
       
   645     if(mAudioFetcherView)
       
   646     {
       
   647         appendViewToBeDeleted(mAudioFetcherView);
       
   648         mAudioFetcherView = NULL;
       
   649     }
       
   650 
       
   651     // delete UniViewer
       
   652 	if (mUniViewer )
       
   653 	{
       
   654 	    appendViewToBeDeleted(mUniViewer);
       
   655 	    mUniViewer = NULL;
       
   656 	}
       
   657 
       
   658     if (mConversationView)
       
   659     {
   614         //clearing content of cv.
   660         //clearing content of cv.
   615         mConversationView->clearContent();
   661         mConversationView->clearContent();
   616     }
   662     }
   617 
   663 
   618      // reset conversation id published
   664     // reset conversation id published
   619      if(mPreviousView == MsgBaseView::CV && mConversationView)
   665     if(mPreviousView == MsgBaseView::CV && mConversationView)
   620          {
   666     {
   621          mConversationView->setPSCVId(false);
   667         mConversationView->setPSCVId(false);
   622          }
   668     }
   623      
   669 
   624     //swich to unieditor.
   670     //swich to unieditor.
   625     if (!mUniEditor) {
   671     if (!mUniEditor) {
   626         mUniEditor = new MsgUnifiedEditorView();
   672         mUniEditor = new MsgUnifiedEditorView();
   627         mMainWindow->addView(mUniEditor);
   673         mMainWindow->addView(mUniEditor);
   628         mUniEditor->setNavigationAction(mBackAction);
   674         mUniEditor->setNavigationAction(mBackAction);
   637         for (int i = 2; i < data.length(); i++) {
   683         for (int i = 2; i < data.length(); i++) {
   638             editorData << data.at(i);
   684             editorData << data.at(i);
   639         }
   685         }
   640 
   686 
   641         if (MsgBaseView::DLV == mPreviousView) {
   687         if (MsgBaseView::DLV == mPreviousView) {
   642             mUniEditor->openDraftsMessage(editorData);
   688             //Populate editor after view ready indication 
       
   689             populateUniEditorAfterViewReady(editorData);
   643         }
   690         }
   644         else {
   691         else {
   645             mUniEditor->populateContent(editorData);
   692             mUniEditor->populateContent(editorData);
   646         }
   693         }
   647     }
   694     }
   648 
   695 
   649     if (mServiceRequest) {
   696     mMainWindow->setCurrentView(mUniEditor);
   650         mMainWindow->setCurrentView(mUniEditor);
       
   651     }
       
   652     else {
       
   653         mMainWindow->setCurrentView(mUniEditor);
       
   654     }
       
   655     //delete UniViewer
       
   656     if (mUniViewer )
       
   657     {
       
   658         appendViewToBeDeleted(mUniViewer);
       
   659         mUniViewer = NULL;
       
   660     }
       
   661 }
   697 }
   662 
   698 
   663 void MsgViewManager::switchToUniViewer(const QVariantList& data)
   699 void MsgViewManager::switchToUniViewer(const QVariantList& data)
   664 {
   700 {
   665     /**
   701     /**
   677     if (data.length() > 2) {
   713     if (data.length() > 2) {
   678         qint32 contactId = data.at(2).toLongLong();
   714         qint32 contactId = data.at(2).toLongLong();
   679         qint32 messageId = data.at(3).toInt();
   715         qint32 messageId = data.at(3).toInt();
   680         int msgCount = data.at(4).toInt();
   716         int msgCount = data.at(4).toInt();
   681         int canForwardMessage = data.at(5).toInt();
   717         int canForwardMessage = data.at(5).toInt();
   682         
   718 
   683         if (!mUniViewer) {
   719         if (!mUniViewer) {
   684             mUniViewer = new UnifiedViewer(messageId, canForwardMessage);
   720             mUniViewer = new UnifiedViewer(messageId, canForwardMessage);
   685             mUniViewer->setNavigationAction(mBackAction);
   721             mUniViewer->setNavigationAction(mBackAction);
   686             mMainWindow->addView(mUniViewer);
   722             mMainWindow->addView(mUniViewer);
   687             connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
   723             connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
   688                 SLOT(switchView(const QVariantList&)));
   724                 SLOT(switchView(const QVariantList&)));
   689         }
   725         }
   690         mUniViewer->populateContent(messageId, true, msgCount);        
   726         mUniViewer->populateContent(messageId, true, msgCount);
   691     }
   727     }
   692     
   728 
   693     if(mPreviousView==MsgBaseView::CV && mConversationView)
   729     if(mPreviousView==MsgBaseView::CV && mConversationView)
   694         {
   730         {
   695         mConversationView->setPSCVId(false);
   731         mConversationView->setPSCVId(false);
   696         }
   732         }
   697     
   733 
   698     mMainWindow->setCurrentView(mUniViewer);
   734     mMainWindow->setCurrentView(mUniViewer);
   699 }
   735 }
   700 void MsgViewManager::switchToMsgSettings(const QVariantList& data)
   736 void MsgViewManager::switchToMsgSettings(const QVariantList& data)
   701 {
   737 {
   702     mCurrentView = MsgBaseView::MSGSETTINGS;
   738     mCurrentView = MsgBaseView::MSGSETTINGS;
   703     mPreviousView = data.at(1).toInt();
   739     mPreviousView = data.at(1).toInt();
   704 
   740 
   705     if (!mSettingsView) {
   741     if (!mSettingsView) {
   706         
   742 
   707         MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
   743         MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
   708         if (mPreviousView == MsgBaseView::UNIEDITOR || mPreviousView
   744         if (mPreviousView == MsgBaseView::UNIEDITOR || mPreviousView
   709                         == MsgBaseView::CV)
   745                         == MsgBaseView::CV)
   710                 {
   746                 {
   711                     view = (MsgSettingsView::SettingsView)data.at(2).toInt();         
   747                     view = (MsgSettingsView::SettingsView)data.at(2).toInt();
   712                 }
   748                 }
   713         
   749 
   714         mSettingsView = new MsgSettingsView(view);
   750         mSettingsView = new MsgSettingsView(view);
   715         mSettingsView->setNavigationAction(mBackAction);
   751         mSettingsView->setNavigationAction(mBackAction);
   716         mMainWindow->addView(mSettingsView);
   752         mMainWindow->addView(mSettingsView);
   717         mMainWindow->setCurrentView(mSettingsView);
   753         mMainWindow->setCurrentView(mSettingsView);
   718     }
   754     }
   879 {
   915 {
   880     if(!mMainWindow->isInteractive())
   916     if(!mMainWindow->isInteractive())
   881     {
   917     {
   882         mMainWindow->setInteractive(true);
   918         mMainWindow->setInteractive(true);
   883     }
   919     }
       
   920 
       
   921     disconnect(mMainWindow, SIGNAL(viewReady()),this,SLOT(setViewInteractive()));
       
   922 }
       
   923 
       
   924 void  MsgViewManager::appendViewToBeDeleted(HbView* view)
       
   925 {
       
   926     if (view)
       
   927     {
       
   928         mViewTobeDeleted << view;
       
   929         connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(deletePreviousView()), Qt::UniqueConnection);
       
   930     }
       
   931 }
       
   932 
       
   933 // ----------------------------------------------------------------------------
       
   934 // MsgViewManager::populateEditorAfterViewReady
       
   935 // @see header
       
   936 // ----------------------------------------------------------------------------
       
   937 void MsgViewManager::populateUniEditorAfterViewReady(const QVariantList& editorData)
       
   938 	{
       
   939 	 //Save the editor data and use it in ViewReady handler
       
   940 	 mEditorData = editorData;	 
       
   941 	 connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(populateUniEditorView()));
       
   942 	}
       
   943 
       
   944 // ----------------------------------------------------------------------------
       
   945 // MsgViewManager::populateUniEditorView
       
   946 // @see header
       
   947 // ----------------------------------------------------------------------------
       
   948 void MsgViewManager::populateUniEditorView()
       
   949     {
       
   950     if (mUniEditor)
       
   951         {
       
   952         mUniEditor->openDraftsMessage(mEditorData);
       
   953         }
       
   954     mEditorData.clear();
   884     
   955     
   885     disconnect(mMainWindow, SIGNAL(viewReady()),this,SLOT(setViewInteractive()));
   956     disconnect(mMainWindow, SIGNAL(viewReady()), this,
   886 }
   957             SLOT(populateUniEditorView()));
   887 
       
   888 void  MsgViewManager::appendViewToBeDeleted(HbView* view)
       
   889 {
       
   890     if (view)
       
   891     {
       
   892         mViewTobeDeleted << view;
       
   893         connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(deletePreviousView()));
       
   894     }
       
   895 }
   958 }
   896 
   959 
   897 // ----------------------------------------------------------------------------
   960 // ----------------------------------------------------------------------------
   898 // MsgViewManager::onDialogDeleteMsg
   961 // MsgViewManager::onDialogDeleteMsg
   899 // @see header
   962 // @see header
   947 // ----------------------------------------------------------------------------
  1010 // ----------------------------------------------------------------------------
   948 int MsgViewManager::currentView()
  1011 int MsgViewManager::currentView()
   949     {
  1012     {
   950     return mCurrentView;
  1013     return mCurrentView;
   951     }
  1014     }
       
  1015 
       
  1016 // ----------------------------------------------------------------------------
       
  1017 // MsgViewManager::switchToAudioFetcher
       
  1018 // @see header
       
  1019 // ----------------------------------------------------------------------------
       
  1020 void MsgViewManager::switchToAudioFetcher(const QVariantList& data)
       
  1021     {
       
  1022     /**
       
  1023      * Audio Fetcher is tried to open again before exiting
       
  1024      * opened editor.
       
  1025      */
       
  1026     if(mAudioFetcherView)
       
  1027         {
       
  1028         return;
       
  1029         }
       
  1030 
       
  1031     //switch to Audio Fetcher view
       
  1032     mCurrentView = MsgBaseView::AUDIOFETCHER;
       
  1033     mPreviousView = data.at(1).toInt();
       
  1034 
       
  1035     mAudioFetcherView = new MsgAudioFetcherView();
       
  1036     mAudioFetcherView->setNavigationAction(mBackAction);
       
  1037     connect(mAudioFetcherView, SIGNAL(switchView(const QVariantList&)), this,
       
  1038             SLOT(switchView(const QVariantList&)));
       
  1039 
       
  1040     if(mPreviousView==MsgBaseView::CV && mConversationView)
       
  1041         {
       
  1042         mConversationView->setPSCVId(false);
       
  1043         }
       
  1044 
       
  1045     mMainWindow->addView(mAudioFetcherView);
       
  1046     mMainWindow->setCurrentView(mAudioFetcherView);
       
  1047     }
       
  1048 
       
  1049 // ----------------------------------------------------------------------------
       
  1050 // MsgViewManager::saveContentToDraft
       
  1051 // @see header
       
  1052 // ----------------------------------------------------------------------------
       
  1053 int MsgViewManager::saveContentToDraft()
       
  1054     {
       
  1055     int msgId = NULL_CONVERSATIONID;
       
  1056     if( mCurrentView == MsgBaseView::CV )
       
  1057         {
       
  1058         msgId = mConversationView->saveContentToDrafts();
       
  1059         }
       
  1060     else if( mCurrentView ==MsgBaseView::UNIEDITOR)
       
  1061         {
       
  1062         msgId  = mUniEditor->saveContentToDrafts();
       
  1063         }
       
  1064     return msgId;
       
  1065     }
       
  1066 
       
  1067 // ----------------------------------------------------------------------------
       
  1068 // MsgViewManager::saveContentToDraft
       
  1069 // @see header
       
  1070 // ----------------------------------------------------------------------------
       
  1071 void MsgViewManager::openUniEditorActivity(int activityMsgId)
       
  1072 {
       
  1073     int msgType;
       
  1074     int msgSubType;
       
  1075   
       
  1076     qint32 messageId(activityMsgId);
       
  1077     // get the message type
       
  1078     ConversationsEngine::instance()->markAsReadAndGetType(messageId, msgType, msgSubType);
       
  1079     
       
  1080     if (!mUniEditor) {
       
  1081            mUniEditor = new MsgUnifiedEditorView();
       
  1082            mMainWindow->addView(mUniEditor);
       
  1083            mUniEditor->setNavigationAction(mBackAction);
       
  1084            connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this,
       
  1085                SLOT(switchView(const QVariantList&)));
       
  1086        }
       
  1087     
       
  1088     // buffer data to open the draft message
       
  1089     ConvergedMessageId convergedMsgId(activityMsgId);
       
  1090     ConvergedMessage message;
       
  1091     message.setMessageType((ConvergedMessage::MessageType) msgType);
       
  1092     message.setMessageId(convergedMsgId);
       
  1093 
       
  1094     // Launch uni-editor view
       
  1095     QByteArray dataArray;
       
  1096     QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append);
       
  1097     message.serialize(messageStream);
       
  1098     
       
  1099     QVariantList editorData;
       
  1100     editorData << dataArray;
       
  1101     mUniEditor->openDraftsMessage(editorData);
       
  1102     
       
  1103     // set the current view
       
  1104     mCurrentView = MsgBaseView::UNIEDITOR;
       
  1105     mMainWindow->setCurrentView(mUniEditor);
       
  1106 }
       
  1107 
       
  1108 // ----------------------------------------------------------------------------
       
  1109 // MsgViewManager::findContactId
       
  1110 // @see header
       
  1111 // ----------------------------------------------------------------------------
       
  1112 qint32 MsgViewManager::findContactId(QString address)
       
  1113     {
       
  1114     QString displayLabel;
       
  1115     int count;
       
  1116     int localId =
       
  1117             MsgContactHandler::resolveContactDisplayName(address,
       
  1118                                                          displayLabel,
       
  1119                                                          count);
       
  1120 
       
  1121         return localId;
       
  1122     }