messagingapp/msgui/msgapp/src/msgviewmanager.cpp
changeset 46 b1f0785c289d
parent 41 25fe1fe642e3
child 48 4f501b74aeb1
equal deleted inserted replaced
41:25fe1fe642e3 46:b1f0785c289d
   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                 int canForwardMessage = mViewerData.at(3).toInt();
       
   195                 
       
   196                 param << contactId;
       
   197                 param << messageId;
       
   198                 param << msgCount;
       
   199                 param << canForwardMessage;
       
   200             }
       
   201             else if(mPreviousView == MsgBaseView::UNIEDITOR){
       
   202                 //TODO: Remove error handling once Audio fetcher 
       
   203                 //becomes dialog
       
   204                 param[0] = MsgBaseView::CLV;
       
   205                 }
       
   206             
   186             switchView(param);
   207             switchView(param);
   187         }
   208         }
   188 
   209 
   189         break;
   210         break;
   190     }
   211     }
   254         handleDefault(data);
   275         handleDefault(data);
   255         break;
   276         break;
   256     }
   277     }
   257     case MsgBaseView::CLV:
   278     case MsgBaseView::CLV:
   258     {
   279     {
   259             switchToClv(data);
   280          switchToClv(data);
   260             break;
   281          break;
   261         }
   282     }
   262 
   283 
   263         case MsgBaseView::CV:
   284     case MsgBaseView::CV:
   264         {
   285     {
   265 
   286          switchToCv(data);
   266             switchToCv(data);
   287          break;
   267             break;
   288     }
   268         }
       
   269 
   289 
   270     case MsgBaseView::DLV:
   290     case MsgBaseView::DLV:
   271     {
   291     {
   272         switchToDlv(data);
   292         switchToDlv(data);
   273         break;
   293         break;
   543     mMainWindow->setCurrentView(mListView);
   563     mMainWindow->setCurrentView(mListView);
   544 }
   564 }
   545 
   565 
   546 void MsgViewManager::switchToCv(const QVariantList& data)
   566 void MsgViewManager::switchToCv(const QVariantList& data)
   547 {
   567 {
       
   568     QCRITICAL_WRITE("MsgViewManager::switchToCv start.");
       
   569     
   548     //switch to CV.
   570     //switch to CV.
   549     mCurrentView = MsgBaseView::CV;
   571     mCurrentView = MsgBaseView::CV;
   550     mPreviousView = data.at(1).toInt();
   572     mPreviousView = data.at(1).toInt();
   551 
   573 
   552     // delete case from viewer service
   574     // delete case from viewer service
   632         mConversationView->clearContent();
   654         mConversationView->clearContent();
   633     }
   655     }
   634 
   656 
   635     mConversationView->openConversation(conversationId);
   657     mConversationView->openConversation(conversationId);
   636     mMainWindow->setCurrentView(mConversationView);
   658     mMainWindow->setCurrentView(mConversationView);
       
   659     
       
   660     QCRITICAL_WRITE("MsgViewManager::switchToCv end.");
   637 }
   661 }
   638 
   662 
   639 void MsgViewManager::switchToDlv(const QVariantList& data)
   663 void MsgViewManager::switchToDlv(const QVariantList& data)
   640 {
   664 {
       
   665     //delete UniEditor
       
   666     if (mUniEditor)
       
   667     {
       
   668         appendViewToBeDeleted(mUniEditor);
       
   669         mUniEditor = NULL;
       
   670     }
       
   671     
   641     //switch to DLV.
   672     //switch to DLV.
   642     mCurrentView = MsgBaseView::DLV;
   673     mCurrentView = MsgBaseView::DLV;
   643     mPreviousView = data.at(1).toInt();
   674     mPreviousView = data.at(1).toInt();
   644 
   675 
   645     if (!mDraftsListView) {
   676     if (!mDraftsListView) {
   653     mMainWindow->setCurrentView(mDraftsListView);
   684     mMainWindow->setCurrentView(mDraftsListView);
   654 }
   685 }
   655 
   686 
   656 void MsgViewManager::switchToUniEditor(const QVariantList& data)
   687 void MsgViewManager::switchToUniEditor(const QVariantList& data)
   657 {
   688 {
       
   689     QCRITICAL_WRITE("MsgViewManager::switchToUniEditor start.");
       
   690     
   658     /**
   691     /**
   659      * Editor is tried to open again before exiting the previously
   692      * Editor is tried to open again before exiting the previously
   660      * opened editor. Multi taping in DLV or Forward.
   693      * opened editor. Multi taping in DLV or Forward.
   661      */
   694      */
   662     if (mUniEditor && !mAudioFetcherView)
   695     if (mUniEditor && !mAudioFetcherView)
   721             mUniEditor->populateContent(editorData);
   754             mUniEditor->populateContent(editorData);
   722         }
   755         }
   723     }
   756     }
   724 
   757 
   725     mMainWindow->setCurrentView(mUniEditor);
   758     mMainWindow->setCurrentView(mUniEditor);
       
   759     
       
   760     QCRITICAL_WRITE("MsgViewManager::switchToUniEditor end.");
   726 }
   761 }
   727 
   762 
   728 void MsgViewManager::switchToUniViewer(const QVariantList& data)
   763 void MsgViewManager::switchToUniViewer(const QVariantList& data)
   729 {
   764 {
   730     /**
   765     /**
   733      */
   768      */
   734     if (mUniViewer) {
   769     if (mUniViewer) {
   735         return;
   770         return;
   736     }
   771     }
   737 
   772 
       
   773     //Clear the old viewer data
       
   774     mViewerData.clear();
       
   775     
   738     mCurrentView = MsgBaseView::UNIVIEWER;
   776     mCurrentView = MsgBaseView::UNIVIEWER;
   739     mPreviousView = data.at(1).toInt();
   777     mPreviousView = data.at(1).toInt();
   740 
   778 
   741     //switch to univiewer.
   779     //switch to univiewer.
   742     if (data.length() > 2) {
   780     if (data.length() > 2) {
   743         qint32 contactId = data.at(2).toLongLong();
   781         qint32 contactId = data.at(2).toLongLong();
   744         qint32 messageId = data.at(3).toInt();
   782         qint32 messageId = data.at(3).toInt();
   745         int msgCount = data.at(4).toInt();
   783         int msgCount = data.at(4).toInt();
   746         int canForwardMessage = data.at(5).toInt();
   784         int canForwardMessage = data.at(5).toInt();
   747 
   785 
       
   786         //Save the viewer data to be used when u come back from Editor
       
   787         mViewerData << contactId;
       
   788         mViewerData << messageId;
       
   789         mViewerData << msgCount;
       
   790         mViewerData << canForwardMessage;
       
   791         
   748         if (!mUniViewer) {
   792         if (!mUniViewer) {
   749             mUniViewer = new UnifiedViewer(messageId, canForwardMessage);
   793             mUniViewer = new UnifiedViewer(messageId, canForwardMessage);
   750             mUniViewer->setNavigationAction(mBackAction);
   794             mUniViewer->setNavigationAction(mBackAction);
   751             mMainWindow->addView(mUniViewer);
   795             mMainWindow->addView(mUniViewer);
   752             connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
   796             connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this,
   762 
   806 
   763     mMainWindow->setCurrentView(mUniViewer);
   807     mMainWindow->setCurrentView(mUniViewer);
   764 }
   808 }
   765 void MsgViewManager::switchToMsgSettings(const QVariantList& data)
   809 void MsgViewManager::switchToMsgSettings(const QVariantList& data)
   766 {
   810 {
   767     mCurrentView = MsgBaseView::MSGSETTINGS;
   811     int previousView = data.at(1).toInt();
   768     mPreviousView = data.at(1).toInt();
   812     
   769 
   813     MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
   770     if (!mSettingsView) {
   814     if (previousView == MsgBaseView::UNIEDITOR || previousView
   771 
   815             == MsgBaseView::CV)
   772         MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
   816         {
   773         if (mPreviousView == MsgBaseView::UNIEDITOR || mPreviousView
   817         view = (MsgSettingsView::SettingsView)data.at(2).toInt();
   774                         == MsgBaseView::CV)
   818         }
   775                 {
   819 
   776                     view = (MsgSettingsView::SettingsView)data.at(2).toInt();
   820     //launch settings service
   777                 }
   821     QList<QVariant> args;
   778 
   822     QString serviceName("messagesettings");
   779         mSettingsView = new MsgSettingsView(view);
   823     QString interfaceName("com.nokia.symbian.IMessageSettings");
   780         mSettingsView->setNavigationAction(mBackAction);
   824     QString operation("launchSettings(int)");
   781         mMainWindow->addView(mSettingsView);
   825     XQAiwRequest* request;
   782         
   826     XQApplicationManager appManager;
   783         if(view != MsgSettingsView::SMSView)
   827     request = appManager.create(serviceName, interfaceName, operation, true); //embedded
   784         {
   828     if ( request == NULL )
   785             mMainWindow->setCurrentView(mSettingsView);
   829         {
   786         }
   830         return;       
   787     }
   831         }
   788     if(mPreviousView==MsgBaseView::CV && mConversationView){
   832  
       
   833     args <<  view;
       
   834 
       
   835     request->setArguments(args);
       
   836 
       
   837     if(previousView==MsgBaseView::CV && mConversationView){
   789         mConversationView->setPSCVId(false);
   838         mConversationView->setPSCVId(false);
       
   839         }
       
   840 
       
   841     if(!request->send())
       
   842         {
       
   843         QDEBUG_WRITE("launchSettings failed")
       
   844         }
       
   845     delete request;
       
   846 
       
   847     
       
   848     if(previousView==MsgBaseView::CV && mConversationView){
       
   849         mConversationView->setPSCVId(true);
   790         }
   850         }
   791 }
   851 }
   792 
   852 
   793 void MsgViewManager::handleDefault(const QVariantList& data)
   853 void MsgViewManager::handleDefault(const QVariantList& data)
   794 {
   854 {
   968 // MsgViewManager::populateEditorAfterViewReady
  1028 // MsgViewManager::populateEditorAfterViewReady
   969 // @see header
  1029 // @see header
   970 // ----------------------------------------------------------------------------
  1030 // ----------------------------------------------------------------------------
   971 void MsgViewManager::populateUniEditorAfterViewReady(const QVariantList& editorData)
  1031 void MsgViewManager::populateUniEditorAfterViewReady(const QVariantList& editorData)
   972 	{
  1032 	{
       
  1033     QCRITICAL_WRITE("MsgViewManager::populateUniEditorAfterViewReady start.");
   973 	 //Save the editor data and use it in ViewReady handler
  1034 	 //Save the editor data and use it in ViewReady handler
   974 	 mEditorData = editorData;	 
  1035 	 mEditorData = editorData;	 
   975 	 connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(populateUniEditorView()));
  1036 	 connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(populateUniEditorView()));
       
  1037 	QCRITICAL_WRITE("MsgViewManager::populateUniEditorAfterViewReady end.");
   976 	}
  1038 	}
   977 
  1039 
   978 // ----------------------------------------------------------------------------
  1040 // ----------------------------------------------------------------------------
   979 // MsgViewManager::populateUniEditorView
  1041 // MsgViewManager::populateUniEditorView
   980 // @see header
  1042 // @see header
   981 // ----------------------------------------------------------------------------
  1043 // ----------------------------------------------------------------------------
   982 void MsgViewManager::populateUniEditorView()
  1044 void MsgViewManager::populateUniEditorView()
   983     {
  1045     {
       
  1046     QCRITICAL_WRITE("MsgViewManager::populateUniEditorView start.");
   984     if (mUniEditor)
  1047     if (mUniEditor)
   985         {
  1048         {
   986         mUniEditor->openDraftsMessage(mEditorData);
  1049         mUniEditor->openDraftsMessage(mEditorData);
   987         }
  1050         }
   988     mEditorData.clear();
  1051     mEditorData.clear();
   989     
  1052     
   990     disconnect(mMainWindow, SIGNAL(viewReady()), this,
  1053     disconnect(mMainWindow, SIGNAL(viewReady()), this,
   991             SLOT(populateUniEditorView()));
  1054             SLOT(populateUniEditorView()));
       
  1055     QCRITICAL_WRITE("MsgViewManager::populateUniEditorView end.");
   992 }
  1056 }
   993 
  1057 
   994 // ----------------------------------------------------------------------------
  1058 // ----------------------------------------------------------------------------
   995 // MsgViewManager::onDialogDeleteMsg
  1059 // MsgViewManager::onDialogDeleteMsg
   996 // @see header
  1060 // @see header