messagingapp/msgui/msgapp/src/msgviewmanager.cpp
changeset 52 12db4185673b
parent 44 36f374c67aa8
child 70 a15d9966050f
equal deleted inserted replaced
44:36f374c67aa8 52:12db4185673b
   177         //switch to clv.
   177         //switch to clv.
   178         if (mServiceRequest) {
   178         if (mServiceRequest) {
   179             completeServiceRequest();
   179             completeServiceRequest();
   180         }
   180         }
   181         else {
   181         else {
   182             //switch to clv.
   182             //switch to previous view.
   183             QVariantList param;
   183             QVariantList param;
   184             param << MsgBaseView::CLV;
   184             param << mPreviousView;
   185             param << MsgBaseView::UNIEDITOR;
   185             param << MsgBaseView::UNIEDITOR;
       
   186             
       
   187             if(mPreviousView == MsgBaseView::CV) {
       
   188                 param << mConversationId;
       
   189                 }
       
   190             else if(mPreviousView == MsgBaseView::UNIVIEWER){
       
   191                 qint32 contactId = mViewerData.at(0).toLongLong();
       
   192                 qint32 messageId = mViewerData.at(1).toInt();
       
   193                 int msgCount = mViewerData.at(2).toInt();
       
   194                 
       
   195                 param << contactId;
       
   196                 param << messageId;
       
   197                 param << msgCount;
       
   198             }
       
   199             else if(mPreviousView == MsgBaseView::UNIEDITOR){
       
   200                 //TODO: Remove error handling once Audio fetcher 
       
   201                 //becomes dialog
       
   202                 param[0] = MsgBaseView::CLV;
       
   203                 }
       
   204             
   186             switchView(param);
   205             switchView(param);
   187         }
   206         }
   188 
   207 
   189         break;
   208         break;
   190     }
   209     }
   254         handleDefault(data);
   273         handleDefault(data);
   255         break;
   274         break;
   256     }
   275     }
   257     case MsgBaseView::CLV:
   276     case MsgBaseView::CLV:
   258     {
   277     {
   259             switchToClv(data);
   278          switchToClv(data);
   260             break;
   279          break;
   261         }
   280     }
   262 
   281 
   263         case MsgBaseView::CV:
   282     case MsgBaseView::CV:
   264         {
   283     {
   265 
   284          switchToCv(data);
   266             switchToCv(data);
   285          break;
   267             break;
   286     }
   268         }
       
   269 
   287 
   270     case MsgBaseView::DLV:
   288     case MsgBaseView::DLV:
   271     {
   289     {
   272         switchToDlv(data);
   290         switchToDlv(data);
   273         break;
   291         break;
   505         //wait for the back from viewer/editor
   523         //wait for the back from viewer/editor
   506         //and reset the open CV id
   524         //and reset the open CV id
   507         mConversationId = -1;
   525         mConversationId = -1;
   508         return;
   526         return;
   509     }
   527     }
   510     
   528 
   511     //delete UniEditor
   529     //delete UniEditor
   512     if (mUniEditor)
   530     if (mUniEditor)
   513     {
   531     {
   514         appendViewToBeDeleted(mUniEditor);
   532         appendViewToBeDeleted(mUniEditor);
   515         mUniEditor = NULL;
   533         mUniEditor = NULL;
   538         connect(mListView, SIGNAL(switchView(const QVariantList&)), this,
   556         connect(mListView, SIGNAL(switchView(const QVariantList&)), this,
   539             SLOT(switchView(const QVariantList&)));
   557             SLOT(switchView(const QVariantList&)));
   540         mMainWindow->addView(mListView);
   558         mMainWindow->addView(mListView);
   541     }
   559     }
   542 
   560 
   543     mMainWindow->setCurrentView(mListView);
   561     mMainWindow->setCurrentView(mListView,true,Hb::ViewSwitchSequential);
   544 }
   562 }
   545 
   563 
   546 void MsgViewManager::switchToCv(const QVariantList& data)
   564 void MsgViewManager::switchToCv(const QVariantList& data)
   547 {
   565 {
       
   566     QCRITICAL_WRITE("MsgViewManager::switchToCv start.");
       
   567     
   548     //switch to CV.
   568     //switch to CV.
   549     mCurrentView = MsgBaseView::CV;
   569     mCurrentView = MsgBaseView::CV;
   550     mPreviousView = data.at(1).toInt();
   570     mPreviousView = data.at(1).toInt();
   551 
   571 
   552     // delete case from viewer service
   572     // delete case from viewer service
   563     }
   583     }
   564 
   584 
   565     //delete UniEditor
   585     //delete UniEditor
   566     if (mUniEditor)
   586     if (mUniEditor)
   567     {
   587     {
       
   588         // Save to drafts if CV is launched via service
       
   589         if (mPreviousView == MsgBaseView::SERVICE) {
       
   590             mUniEditor->saveContentToDrafts();
       
   591         }
   568         appendViewToBeDeleted(mUniEditor);
   592         appendViewToBeDeleted(mUniEditor);
   569         mUniEditor = NULL;
   593         mUniEditor = NULL;
   570     }
   594     }
   571 
   595 
   572     //delete UniViewer
   596     //delete UniViewer
   603     }
   627     }
   604     else if (var.type() == QVariant::Invalid) {
   628     else if (var.type() == QVariant::Invalid) {
   605         // this case comes when a message is deleted from
   629         // this case comes when a message is deleted from
   606         // Unified viewer  set curent view as conversation view
   630         // Unified viewer  set curent view as conversation view
   607         // and return
   631         // and return
   608         mMainWindow->setCurrentView(mConversationView);
   632         mMainWindow->setCurrentView(mConversationView,true,Hb::ViewSwitchSequential);
   609 
   633 
   610 		// publish already opened conversation's id
   634 		// publish already opened conversation's id
   611         mConversationView->setPSCVId(true);
   635         mConversationView->setPSCVId(true);
   612         return;
   636         return;
   613     }
   637     }
   631         //clearing content of current cv.
   655         //clearing content of current cv.
   632         mConversationView->clearContent();
   656         mConversationView->clearContent();
   633     }
   657     }
   634 
   658 
   635     mConversationView->openConversation(conversationId);
   659     mConversationView->openConversation(conversationId);
   636     mMainWindow->setCurrentView(mConversationView);
   660     mMainWindow->setCurrentView(mConversationView,true,Hb::ViewSwitchSequential);
       
   661     
       
   662     QCRITICAL_WRITE("MsgViewManager::switchToCv end.");
   637 }
   663 }
   638 
   664 
   639 void MsgViewManager::switchToDlv(const QVariantList& data)
   665 void MsgViewManager::switchToDlv(const QVariantList& data)
   640 {
   666 {
       
   667     //delete UniEditor
       
   668     if (mUniEditor)
       
   669     {
       
   670         appendViewToBeDeleted(mUniEditor);
       
   671         mUniEditor = NULL;
       
   672     }
       
   673     
   641     //switch to DLV.
   674     //switch to DLV.
   642     mCurrentView = MsgBaseView::DLV;
   675     mCurrentView = MsgBaseView::DLV;
   643     mPreviousView = data.at(1).toInt();
   676     mPreviousView = data.at(1).toInt();
   644 
   677 
   645     if (!mDraftsListView) {
   678     if (!mDraftsListView) {
   648         connect(mDraftsListView, SIGNAL(switchView(const QVariantList&)), this,
   681         connect(mDraftsListView, SIGNAL(switchView(const QVariantList&)), this,
   649             SLOT(switchView(const QVariantList&)));
   682             SLOT(switchView(const QVariantList&)));
   650 
   683 
   651         mMainWindow->addView(mDraftsListView);
   684         mMainWindow->addView(mDraftsListView);
   652     }
   685     }
   653     mMainWindow->setCurrentView(mDraftsListView);
   686     mMainWindow->setCurrentView(mDraftsListView,true,Hb::ViewSwitchSequential);
   654 }
   687 }
   655 
   688 
   656 void MsgViewManager::switchToUniEditor(const QVariantList& data)
   689 void MsgViewManager::switchToUniEditor(const QVariantList& data)
   657 {
   690 {
       
   691     QCRITICAL_WRITE("MsgViewManager::switchToUniEditor start.");
       
   692     
   658     /**
   693     /**
   659      * Editor is tried to open again before exiting the previously
   694      * Editor is tried to open again before exiting the previously
   660      * opened editor. Multi taping in DLV or Forward.
   695      * opened editor. Multi taping in DLV or Forward.
   661      */
   696      */
   662     if (mUniEditor && !mAudioFetcherView)
   697     if (mUniEditor && !mAudioFetcherView)
   720         else {
   755         else {
   721             mUniEditor->populateContent(editorData);
   756             mUniEditor->populateContent(editorData);
   722         }
   757         }
   723     }
   758     }
   724 
   759 
   725     mMainWindow->setCurrentView(mUniEditor);
   760     mMainWindow->setCurrentView(mUniEditor,true,Hb::ViewSwitchSequential);
       
   761     
       
   762     QCRITICAL_WRITE("MsgViewManager::switchToUniEditor end.");
   726 }
   763 }
   727 
   764 
   728 void MsgViewManager::switchToUniViewer(const QVariantList& data)
   765 void MsgViewManager::switchToUniViewer(const QVariantList& data)
   729 {
   766 {
   730     /**
   767     /**
   733      */
   770      */
   734     if (mUniViewer) {
   771     if (mUniViewer) {
   735         return;
   772         return;
   736     }
   773     }
   737 
   774 
       
   775     if (mUniEditor)
       
   776     {
       
   777         appendViewToBeDeleted(mUniEditor);
       
   778         mUniEditor = NULL;
       
   779     }
       
   780 
       
   781     //Clear the old viewer data
       
   782     mViewerData.clear();
       
   783     
   738     mCurrentView = MsgBaseView::UNIVIEWER;
   784     mCurrentView = MsgBaseView::UNIVIEWER;
   739     mPreviousView = data.at(1).toInt();
   785     mPreviousView = data.at(1).toInt();
   740 
   786 
   741     //switch to univiewer.
   787     //switch to univiewer.
   742     if (data.length() > 2) {
   788     if (data.length() > 2) {
   743         qint32 contactId = data.at(2).toLongLong();
   789         qint32 contactId = data.at(2).toLongLong();
   744         qint32 messageId = data.at(3).toInt();
   790         qint32 messageId = data.at(3).toInt();
   745         int msgCount = data.at(4).toInt();
   791         int msgCount = data.at(4).toInt();
   746         int canForwardMessage = data.at(5).toInt();
   792 
   747 
   793         //Save the viewer data to be used when u come back from Editor
       
   794         mViewerData << contactId;
       
   795         mViewerData << messageId;
       
   796         mViewerData << msgCount;
       
   797         
   748         if (!mUniViewer) {
   798         if (!mUniViewer) {
   749             mUniViewer = new UnifiedViewer(messageId, canForwardMessage);
   799             mUniViewer = new UnifiedViewer(messageId);
   750             mUniViewer->setNavigationAction(mBackAction);
   800             mUniViewer->setNavigationAction(mBackAction);
   751             mMainWindow->addView(mUniViewer);
   801             mMainWindow->addView(mUniViewer);
   752             connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
   802             connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
   753                 SLOT(switchView(const QVariantList&)));
   803                 SLOT(switchView(const QVariantList&)));
   754         }
   804         }
   758     if(mPreviousView==MsgBaseView::CV && mConversationView)
   808     if(mPreviousView==MsgBaseView::CV && mConversationView)
   759         {
   809         {
   760         mConversationView->setPSCVId(false);
   810         mConversationView->setPSCVId(false);
   761         }
   811         }
   762 
   812 
   763     mMainWindow->setCurrentView(mUniViewer);
   813     mMainWindow->setCurrentView(mUniViewer,true,Hb::ViewSwitchSequential);
   764 }
   814 }
   765 void MsgViewManager::switchToMsgSettings(const QVariantList& data)
   815 void MsgViewManager::switchToMsgSettings(const QVariantList& data)
   766 {
   816 {
   767     mCurrentView = MsgBaseView::MSGSETTINGS;
   817     int previousView = data.at(1).toInt();
   768     mPreviousView = data.at(1).toInt();
   818     
   769 
   819     MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
   770     if (!mSettingsView) {
   820     if (previousView == MsgBaseView::UNIEDITOR || previousView
   771 
   821             == MsgBaseView::CV)
   772         MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
   822         {
   773         if (mPreviousView == MsgBaseView::UNIEDITOR || mPreviousView
   823         view = (MsgSettingsView::SettingsView)data.at(2).toInt();
   774                         == MsgBaseView::CV)
   824         }
   775                 {
   825 
   776                     view = (MsgSettingsView::SettingsView)data.at(2).toInt();
   826     //launch settings service
   777                 }
   827     QList<QVariant> args;
   778 
   828     QString serviceName("messagesettings");
   779         mSettingsView = new MsgSettingsView(view);
   829     QString interfaceName("com.nokia.symbian.IMessageSettings");
   780         mSettingsView->setNavigationAction(mBackAction);
   830     QString operation("launchSettings(int)");
   781         mMainWindow->addView(mSettingsView);
   831     XQAiwRequest* request;
   782         mMainWindow->setCurrentView(mSettingsView);
   832     XQApplicationManager appManager;
   783     }
   833     request = appManager.create(serviceName, interfaceName, operation, true); //embedded
   784     if(mPreviousView==MsgBaseView::CV && mConversationView){
   834     if ( request == NULL )
       
   835         {
       
   836         return;       
       
   837         }
       
   838  
       
   839     args <<  view;
       
   840 
       
   841     request->setArguments(args);
       
   842 
       
   843     if(previousView==MsgBaseView::CV && mConversationView){
   785         mConversationView->setPSCVId(false);
   844         mConversationView->setPSCVId(false);
       
   845         }
       
   846 
       
   847     if(!request->send())
       
   848         {
       
   849         QDEBUG_WRITE("launchSettings failed")
       
   850         }
       
   851     delete request;
       
   852 
       
   853     
       
   854     if(previousView==MsgBaseView::CV && mConversationView){
       
   855         mConversationView->setPSCVId(true);
   786         }
   856         }
   787 }
   857 }
   788 
   858 
   789 void MsgViewManager::handleDefault(const QVariantList& data)
   859 void MsgViewManager::handleDefault(const QVariantList& data)
   790 {
   860 {
   802         }
   872         }
   803         switch (mCurrentView) {
   873         switch (mCurrentView) {
   804         case MsgBaseView::CLV:
   874         case MsgBaseView::CLV:
   805         {
   875         {
   806             if (mListView)
   876             if (mListView)
   807                 mMainWindow->setCurrentView(mListView);
   877                 mMainWindow->setCurrentView(mListView,true,Hb::ViewSwitchSequential);
   808             break;
   878             break;
   809         }
   879         }
   810         case MsgBaseView::CV:
   880         case MsgBaseView::CV:
   811         {
   881         {
   812             if (mConversationView)
   882             if (mConversationView)
   813                 mMainWindow->setCurrentView(mConversationView);
   883                 mMainWindow->setCurrentView(mConversationView,true,Hb::ViewSwitchSequential);
   814             break;
   884             break;
   815         }
   885         }
   816         case MsgBaseView::DLV:
   886         case MsgBaseView::DLV:
   817         {
   887         {
   818             if (mDraftsListView)
   888             if (mDraftsListView)
   819                 mMainWindow->setCurrentView(mDraftsListView);
   889                 mMainWindow->setCurrentView(mDraftsListView,true,Hb::ViewSwitchSequential);
   820             break;
   890             break;
   821         }
   891         }
   822         case MsgBaseView::UNIEDITOR:
   892         case MsgBaseView::UNIEDITOR:
   823         {
   893         {
   824             if (mServiceRequest) {
   894             if (mServiceRequest) {
   825                 mMainWindow->setCurrentView(mUniEditor);
   895                 mMainWindow->setCurrentView(mUniEditor,true,Hb::ViewSwitchSequential);
   826             }
   896             }
   827             else {
   897             else {
   828                 mMainWindow->setCurrentView(mUniEditor);
   898                 mMainWindow->setCurrentView(mUniEditor,true,Hb::ViewSwitchSequential);
   829             }
   899             }
   830             break;
   900             break;
   831         }
   901         }
   832         }
   902         }
   833     }
   903     }
   892         connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
   962         connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
   893             SLOT(switchView(const QVariantList&)));
   963             SLOT(switchView(const QVariantList&)));
   894     }
   964     }
   895     mUniViewer->populateContent(msgId, true, -1);
   965     mUniViewer->populateContent(msgId, true, -1);
   896 
   966 
   897     mMainWindow->setCurrentView(mUniViewer);
   967     mMainWindow->setCurrentView(mUniViewer,true,Hb::ViewSwitchSequential);
   898 }
   968 }
   899 
   969 
   900 // ----------------------------------------------------------------------------
   970 // ----------------------------------------------------------------------------
   901 // MsgViewManager::handleRingtoneMsg
   971 // MsgViewManager::handleRingtoneMsg
   902 // @see header
   972 // @see header
   964 // MsgViewManager::populateEditorAfterViewReady
  1034 // MsgViewManager::populateEditorAfterViewReady
   965 // @see header
  1035 // @see header
   966 // ----------------------------------------------------------------------------
  1036 // ----------------------------------------------------------------------------
   967 void MsgViewManager::populateUniEditorAfterViewReady(const QVariantList& editorData)
  1037 void MsgViewManager::populateUniEditorAfterViewReady(const QVariantList& editorData)
   968 	{
  1038 	{
       
  1039     QCRITICAL_WRITE("MsgViewManager::populateUniEditorAfterViewReady start.");
   969 	 //Save the editor data and use it in ViewReady handler
  1040 	 //Save the editor data and use it in ViewReady handler
   970 	 mEditorData = editorData;	 
  1041 	 mEditorData = editorData;	 
   971 	 connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(populateUniEditorView()));
  1042 	 connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(populateUniEditorView()));
       
  1043 	QCRITICAL_WRITE("MsgViewManager::populateUniEditorAfterViewReady end.");
   972 	}
  1044 	}
   973 
  1045 
   974 // ----------------------------------------------------------------------------
  1046 // ----------------------------------------------------------------------------
   975 // MsgViewManager::populateUniEditorView
  1047 // MsgViewManager::populateUniEditorView
   976 // @see header
  1048 // @see header
   977 // ----------------------------------------------------------------------------
  1049 // ----------------------------------------------------------------------------
   978 void MsgViewManager::populateUniEditorView()
  1050 void MsgViewManager::populateUniEditorView()
   979     {
  1051     {
       
  1052     QCRITICAL_WRITE("MsgViewManager::populateUniEditorView start.");
   980     if (mUniEditor)
  1053     if (mUniEditor)
   981         {
  1054         {
   982         mUniEditor->openDraftsMessage(mEditorData);
  1055         mUniEditor->openDraftsMessage(mEditorData);
   983         }
  1056         }
   984     mEditorData.clear();
  1057     mEditorData.clear();
   985     
  1058     
   986     disconnect(mMainWindow, SIGNAL(viewReady()), this,
  1059     disconnect(mMainWindow, SIGNAL(viewReady()), this,
   987             SLOT(populateUniEditorView()));
  1060             SLOT(populateUniEditorView()));
       
  1061     QCRITICAL_WRITE("MsgViewManager::populateUniEditorView end.");
   988 }
  1062 }
   989 
  1063 
   990 // ----------------------------------------------------------------------------
  1064 // ----------------------------------------------------------------------------
   991 // MsgViewManager::onDialogDeleteMsg
  1065 // MsgViewManager::onDialogDeleteMsg
   992 // @see header
  1066 // @see header
  1074         {
  1148         {
  1075         mConversationView->setPSCVId(false);
  1149         mConversationView->setPSCVId(false);
  1076         }
  1150         }
  1077 
  1151 
  1078     mMainWindow->addView(mAudioFetcherView);
  1152     mMainWindow->addView(mAudioFetcherView);
  1079     mMainWindow->setCurrentView(mAudioFetcherView);
  1153     mMainWindow->setCurrentView(mAudioFetcherView,true,Hb::ViewSwitchSequential);
  1080     }
  1154     }
  1081 
  1155 
  1082 // ----------------------------------------------------------------------------
  1156 // ----------------------------------------------------------------------------
  1083 // MsgViewManager::saveContentToDraft
  1157 // MsgViewManager::saveContentToDraft
  1084 // @see header
  1158 // @see header
  1133     editorData << dataArray;
  1207     editorData << dataArray;
  1134     mUniEditor->openDraftsMessage(editorData);
  1208     mUniEditor->openDraftsMessage(editorData);
  1135     
  1209     
  1136     // set the current view
  1210     // set the current view
  1137     mCurrentView = MsgBaseView::UNIEDITOR;
  1211     mCurrentView = MsgBaseView::UNIEDITOR;
  1138     mMainWindow->setCurrentView(mUniEditor);
  1212     mPreviousView =MsgBaseView::CLV;
       
  1213     mMainWindow->setCurrentView(mUniEditor,true,Hb::ViewSwitchSequential);
  1139 }
  1214 }
  1140 
  1215 
  1141 // ----------------------------------------------------------------------------
  1216 // ----------------------------------------------------------------------------
  1142 // MsgViewManager::findContactId
  1217 // MsgViewManager::findContactId
  1143 // @see header
  1218 // @see header