36 #include "msgsettingsview.h" |
37 #include "msgsettingsview.h" |
37 #include "convergedmessageid.h" |
38 #include "convergedmessageid.h" |
38 #include "ringbc.h" |
39 #include "ringbc.h" |
39 #include "unidatamodelloader.h" |
40 #include "unidatamodelloader.h" |
40 #include "unidatamodelplugininterface.h" |
41 #include "unidatamodelplugininterface.h" |
|
42 #include "msgcontacthandler.h" |
|
43 #include "debugtraces.h" |
|
44 #include "msgaudiofetcherview.h" |
41 |
45 |
42 // LOCALIZATION |
46 // LOCALIZATION |
43 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
|
44 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
|
45 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
47 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
|
48 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone") |
46 |
49 |
47 const qint64 NULL_CONVERSATIONID = -1; |
50 const qint64 NULL_CONVERSATIONID = -1; |
48 |
51 |
49 MsgViewManager::MsgViewManager(bool serviceRequest, HbMainWindow* mainWindow, QObject* parent) : |
52 MsgViewManager::MsgViewManager(bool serviceRequest, HbMainWindow* mainWindow, QObject* parent,int activityMsgId) : |
50 QObject(parent), mMainWindow(mainWindow), mUniEditor(0), mListView(0), mConversationView(0), |
53 QObject(parent), mMainWindow(mainWindow), mUniEditor(0), mListView(0), mConversationView(0), |
51 mUniViewer(0), mDraftsListView(0), mSettingsView(0), mBackAction(0), mServiceRequest( |
54 mUniViewer(0), mDraftsListView(0), mSettingsView(0), mAudioFetcherView(0), mBackAction(0), |
52 serviceRequest), mConversationId(-1), mViewServiceRequest(false) |
55 mServiceRequest(serviceRequest), mConversationId(-1), mViewServiceRequest(false),mMessageId(-1) |
53 { |
56 { |
54 //creating back action. |
57 //creating back action. |
55 mBackAction = new HbAction(Hb::BackAction, this); |
58 mBackAction = new HbAction(Hb::BackNaviAction, this); |
56 connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction())); |
59 connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction())); |
57 |
60 |
58 //create clv as first view if not a service request. |
61 //create clv as first view if not a service request. |
59 if (!mServiceRequest) { |
62 if (!mServiceRequest) { |
|
63 |
|
64 if(activityMsgId == NULL_CONVERSATIONID) |
|
65 { |
60 QVariantList param; |
66 QVariantList param; |
61 param << MsgBaseView::CLV; |
67 param << MsgBaseView::CLV; |
62 param << MsgBaseView::CLV; |
68 param << MsgBaseView::CLV; |
63 switchView(param); |
69 switchView(param); |
|
70 } |
|
71 else |
|
72 { |
|
73 openUniEditorActivity(activityMsgId); |
|
74 } |
|
75 } |
|
76 else |
|
77 { |
|
78 mDummyview = new HbView(); |
|
79 mMainWindow->addView(mDummyview); |
|
80 mMainWindow->setCurrentView(mDummyview); |
|
81 mViewTobeDeleted << mDummyview; |
64 } |
82 } |
65 } |
83 } |
66 |
84 |
67 MsgViewManager::~MsgViewManager() |
85 MsgViewManager::~MsgViewManager() |
68 { |
86 { |
69 // TODO Auto-generated destructor stub |
87 // TODO Auto-generated destructor stub |
|
88 mEditorData.clear(); |
70 } |
89 } |
71 |
90 |
72 void MsgViewManager::onBackAction() |
91 void MsgViewManager::onBackAction() |
73 { |
92 { |
74 switch (mCurrentView) { |
93 switch (mCurrentView) { |
421 switchToLastSavedView(); |
483 switchToLastSavedView(); |
422 } |
484 } |
423 |
485 |
424 void MsgViewManager::switchToClv(const QVariantList& data) |
486 void MsgViewManager::switchToClv(const QVariantList& data) |
425 { |
487 { |
|
488 mPreviousView = data.at(1).toInt(); |
|
489 |
|
490 // delete case from viewer service |
|
491 if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) { |
|
492 // quit the application |
|
493 HbApplication::quit(); |
|
494 } |
|
495 |
|
496 // this is the case when viewer/editor is opened and contacts update takes |
|
497 // place resulting in CV close, the view should directly come to CLV |
|
498 // bypassing the CV |
|
499 if ((mCurrentView == MsgBaseView::UNIVIEWER |
|
500 && mPreviousView != MsgBaseView::UNIVIEWER) |
|
501 || (mCurrentView == MsgBaseView::UNIEDITOR |
|
502 && mPreviousView != MsgBaseView::UNIEDITOR)) |
|
503 { |
|
504 //dont do anything |
|
505 //wait for the back from viewer/editor |
|
506 //and reset the open CV id |
|
507 mConversationId = -1; |
|
508 return; |
|
509 } |
|
510 |
|
511 //delete UniEditor |
|
512 if (mUniEditor) |
|
513 { |
|
514 appendViewToBeDeleted(mUniEditor); |
|
515 mUniEditor = NULL; |
|
516 } |
|
517 |
|
518 //delete UniViewer |
|
519 if (mUniViewer) |
|
520 { |
|
521 appendViewToBeDeleted(mUniViewer); |
|
522 mUniViewer = NULL; |
|
523 } |
|
524 |
|
525 if (mConversationView) { |
|
526 mConversationView->saveContentToDrafts(); |
|
527 //clearing content of cv. |
|
528 mConversationView->clearContent(); |
|
529 //reset the open CV id |
|
530 mConversationId = -1; |
|
531 } |
|
532 |
426 //switch to CLV. |
533 //switch to CLV. |
427 mCurrentView = MsgBaseView::CLV; |
534 mCurrentView = MsgBaseView::CLV; |
428 mPreviousView = data.at(1).toInt(); |
|
429 |
|
430 // delete case from viewer service |
|
431 if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) { |
|
432 // quit the application |
|
433 HbApplication::quit(); |
|
434 } |
|
435 |
|
436 //remove the settings view from main window |
|
437 if (mSettingsView) { |
|
438 mMainWindow->removeView(mSettingsView); |
|
439 mSettingsView->setNavigationAction(mBackAction); |
|
440 connect(mBackAction, SIGNAL(triggered()), this, SLOT(onBackAction()), Qt::UniqueConnection); |
|
441 } |
|
442 if (mConversationView) { |
|
443 //clearing content of cv. |
|
444 mConversationView->clearContent(); |
|
445 } |
|
446 |
|
447 if (!mListView) { |
535 if (!mListView) { |
448 mListView = new MsgListView(); |
536 mListView = new MsgListView(); |
449 mListView->setNavigationAction(mBackAction); |
537 mListView->setNavigationAction(mBackAction); |
450 connect(mListView, SIGNAL(switchView(const QVariantList&)), this, |
538 connect(mListView, SIGNAL(switchView(const QVariantList&)), this, |
451 SLOT(switchView(const QVariantList&))); |
539 SLOT(switchView(const QVariantList&))); |
452 mMainWindow->addView(mListView); |
540 mMainWindow->addView(mListView); |
453 } |
541 } |
454 |
542 |
455 //delete uni editor. |
|
456 if (mUniEditor) { |
|
457 mMainWindow->removeView(mUniEditor); |
|
458 delete mUniEditor; |
|
459 mUniEditor = NULL; |
|
460 } |
|
461 |
|
462 if (mUniViewer) { |
|
463 mMainWindow->removeView(mUniViewer); |
|
464 delete mUniViewer; |
|
465 mUniViewer = NULL; |
|
466 } |
|
467 |
|
468 mMainWindow->setCurrentView(mListView); |
543 mMainWindow->setCurrentView(mListView); |
469 } |
544 } |
470 |
545 |
471 void MsgViewManager::switchToCv(const QVariantList& data) |
546 void MsgViewManager::switchToCv(const QVariantList& data) |
472 { |
547 { |
474 mCurrentView = MsgBaseView::CV; |
549 mCurrentView = MsgBaseView::CV; |
475 mPreviousView = data.at(1).toInt(); |
550 mPreviousView = data.at(1).toInt(); |
476 |
551 |
477 // delete case from viewer service |
552 // delete case from viewer service |
478 if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) { |
553 if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) { |
479 // quit the application |
554 // quit the application |
480 HbApplication::quit(); |
555 HbApplication::quit(); |
481 } |
556 } |
482 |
557 |
483 //delete uni editor. |
558 // delete Audio Fetcher view |
484 if (mUniEditor) { |
559 if(mAudioFetcherView) |
485 mMainWindow->removeView(mUniEditor); |
560 { |
486 delete mUniEditor; |
561 appendViewToBeDeleted(mAudioFetcherView); |
|
562 mAudioFetcherView = NULL; |
|
563 } |
|
564 |
|
565 //delete UniEditor |
|
566 if (mUniEditor) |
|
567 { |
|
568 appendViewToBeDeleted(mUniEditor); |
487 mUniEditor = NULL; |
569 mUniEditor = NULL; |
488 } |
570 } |
489 |
571 |
490 if (mUniViewer) { |
572 //delete UniViewer |
491 mMainWindow->removeView(mUniViewer); |
573 if (mUniViewer) |
492 delete mUniViewer; |
574 { |
|
575 appendViewToBeDeleted(mUniViewer); |
493 mUniViewer = NULL; |
576 mUniViewer = NULL; |
494 } |
577 } |
495 |
578 |
496 QVariant var = data.at(2); |
579 QVariant var = data.at(2); |
497 qint64 conversationId; |
580 qint64 conversationId; |
498 if (var.type() == QVariant::String) { |
581 if (var.type() == QVariant::String) { |
499 QString phoneNumber = var.toString(); |
582 QString phoneNumber = var.toString(); |
500 conversationId = findConversationId(phoneNumber); |
583 qint32 contactId = findContactId(phoneNumber); |
|
584 if (contactId != -1) { |
|
585 conversationId = ConversationsEngine::instance()->getConversationIdFromContactId(contactId); |
|
586 } |
|
587 else { |
|
588 conversationId = findConversationId(phoneNumber); |
|
589 } |
501 |
590 |
502 if (conversationId == NULL_CONVERSATIONID) { |
591 if (conversationId == NULL_CONVERSATIONID) { |
503 QVariantList param; |
592 QVariantList param; |
504 param << MsgBaseView::CLV; |
593 param << MsgBaseView::CLV; |
505 param << MsgBaseView::CV; |
594 param << MsgBaseView::CV; |
|
595 |
|
596 if( mCurrentView == MsgBaseView::CV && mConversationView){ |
|
597 mConversationView->setPSCVId(false); |
|
598 } |
|
599 |
506 switchView(param); |
600 switchView(param); |
507 return; |
601 return; |
508 } |
602 } |
509 } |
603 } |
510 else if (var.type() == QVariant::Invalid) { |
604 else if (var.type() == QVariant::Invalid) { |
511 // this case comes when a message is deleted from |
605 // this case comes when a message is deleted from |
512 // Unified viewer set curent view as conversation view |
606 // Unified viewer set curent view as conversation view |
513 // and return |
607 // and return |
514 mMainWindow->setCurrentView(mConversationView); |
608 mMainWindow->setCurrentView(mConversationView); |
515 |
609 |
516 delete mUniViewer; |
610 // publish already opened conversation's id |
517 mUniViewer = NULL; |
611 mConversationView->setPSCVId(true); |
518 |
|
519 return; |
612 return; |
520 } |
613 } |
521 else { |
614 else { |
522 conversationId = var.toLongLong(); |
615 conversationId = var.toLongLong(); |
523 } |
616 } |
530 connect(mConversationView, SIGNAL(switchView(const QVariantList&)), this, |
623 connect(mConversationView, SIGNAL(switchView(const QVariantList&)), this, |
531 SLOT(switchView(const QVariantList&))); |
624 SLOT(switchView(const QVariantList&))); |
532 |
625 |
533 mMainWindow->addView(mConversationView); |
626 mMainWindow->addView(mConversationView); |
534 } |
627 } |
|
628 else if (mConversationView->conversationId() != mConversationId){ |
|
629 //Save content to drafts before switching to different CV |
|
630 mConversationView->saveContentToDrafts(); |
|
631 //clearing content of current cv. |
|
632 mConversationView->clearContent(); |
|
633 } |
535 |
634 |
536 mConversationView->openConversation(conversationId); |
635 mConversationView->openConversation(conversationId); |
537 |
636 mMainWindow->setCurrentView(mConversationView); |
538 if (mServiceRequest) { |
|
539 mMainWindow->setCurrentView(mConversationView); |
|
540 } |
|
541 else { |
|
542 mMainWindow->setCurrentView(mConversationView); |
|
543 } |
|
544 } |
637 } |
545 |
638 |
546 void MsgViewManager::switchToDlv(const QVariantList& data) |
639 void MsgViewManager::switchToDlv(const QVariantList& data) |
547 { |
640 { |
548 //switch to DLV. |
641 //switch to DLV. |
549 mCurrentView = MsgBaseView::DLV; |
642 mCurrentView = MsgBaseView::DLV; |
550 mPreviousView = data.at(1).toInt(); |
643 mPreviousView = data.at(1).toInt(); |
551 |
|
552 //delete uni editor. |
|
553 if (mUniEditor) { |
|
554 mMainWindow->removeView(mUniEditor); |
|
555 delete mUniEditor; |
|
556 mUniEditor = NULL; |
|
557 } |
|
558 |
644 |
559 if (!mDraftsListView) { |
645 if (!mDraftsListView) { |
560 mDraftsListView = new DraftsListView(); |
646 mDraftsListView = new DraftsListView(); |
561 mDraftsListView->setNavigationAction(mBackAction); |
647 mDraftsListView->setNavigationAction(mBackAction); |
562 connect(mDraftsListView, SIGNAL(switchView(const QVariantList&)), this, |
648 connect(mDraftsListView, SIGNAL(switchView(const QVariantList&)), this, |
632 mPreviousView = data.at(1).toInt(); |
739 mPreviousView = data.at(1).toInt(); |
633 |
740 |
634 //switch to univiewer. |
741 //switch to univiewer. |
635 if (data.length() > 2) { |
742 if (data.length() > 2) { |
636 qint32 contactId = data.at(2).toLongLong(); |
743 qint32 contactId = data.at(2).toLongLong(); |
637 QByteArray dataArray = data.at(3).toByteArray(); |
744 qint32 messageId = data.at(3).toInt(); |
638 int msgCount = data.at(4).toInt(); |
745 int msgCount = data.at(4).toInt(); |
639 |
746 int canForwardMessage = data.at(5).toInt(); |
640 ConvergedMessage *message = new ConvergedMessage; |
747 |
641 QDataStream stream(&dataArray, QIODevice::ReadOnly); |
|
642 message->deserialize(stream); |
|
643 qint32 messageId = message->id()->getId(); |
|
644 if (!mUniViewer) { |
748 if (!mUniViewer) { |
645 mUniViewer = new UnifiedViewer(messageId); |
749 mUniViewer = new UnifiedViewer(messageId, canForwardMessage); |
646 mUniViewer->setNavigationAction(mBackAction); |
750 mUniViewer->setNavigationAction(mBackAction); |
647 mMainWindow->addView(mUniViewer); |
751 mMainWindow->addView(mUniViewer); |
648 connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this, |
752 connect(mUniViewer, SIGNAL(switchView(const QVariantList&)), this, |
649 SLOT(switchView(const QVariantList&))); |
753 SLOT(switchView(const QVariantList&))); |
650 } |
754 } |
651 mUniViewer->populateContent(messageId, true, msgCount); |
755 mUniViewer->populateContent(messageId, true, msgCount); |
652 delete message; |
756 } |
653 } |
757 |
|
758 if(mPreviousView==MsgBaseView::CV && mConversationView) |
|
759 { |
|
760 mConversationView->setPSCVId(false); |
|
761 } |
|
762 |
654 mMainWindow->setCurrentView(mUniViewer); |
763 mMainWindow->setCurrentView(mUniViewer); |
655 } |
764 } |
656 void MsgViewManager::switchToMsgSettings(const QVariantList& data) |
765 void MsgViewManager::switchToMsgSettings(const QVariantList& data) |
657 { |
766 { |
658 mCurrentView = MsgBaseView::MSGSETTINGS; |
767 mCurrentView = MsgBaseView::MSGSETTINGS; |
659 mPreviousView = data.at(1).toInt(); |
768 mPreviousView = data.at(1).toInt(); |
660 |
769 |
661 if (!mSettingsView) { |
770 if (!mSettingsView) { |
662 mSettingsView = new MsgSettingsView(); |
771 |
|
772 MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView; |
|
773 if (mPreviousView == MsgBaseView::UNIEDITOR || mPreviousView |
|
774 == MsgBaseView::CV) |
|
775 { |
|
776 view = (MsgSettingsView::SettingsView)data.at(2).toInt(); |
|
777 } |
|
778 |
|
779 mSettingsView = new MsgSettingsView(view); |
663 mSettingsView->setNavigationAction(mBackAction); |
780 mSettingsView->setNavigationAction(mBackAction); |
664 mMainWindow->addView(mSettingsView); |
781 mMainWindow->addView(mSettingsView); |
665 mMainWindow->setCurrentView(mSettingsView); |
782 mMainWindow->setCurrentView(mSettingsView); |
666 } |
783 } |
|
784 if(mPreviousView==MsgBaseView::CV && mConversationView){ |
|
785 mConversationView->setPSCVId(false); |
|
786 } |
667 } |
787 } |
668 |
788 |
669 void MsgViewManager::handleDefault(const QVariantList& data) |
789 void MsgViewManager::handleDefault(const QVariantList& data) |
670 { |
790 { |
671 //special handling incase we switch from settings-view |
791 //special handling incase we switch from settings-view |
786 // MsgViewManager::handleRingtoneMsg |
901 // MsgViewManager::handleRingtoneMsg |
787 // @see header |
902 // @see header |
788 // ---------------------------------------------------------------------------- |
903 // ---------------------------------------------------------------------------- |
789 void MsgViewManager::handleRingtoneMsg(int msgId) |
904 void MsgViewManager::handleRingtoneMsg(int msgId) |
790 { |
905 { |
791 if (RingBc::askSaveQuery()) { |
906 mMessageId = msgId; |
792 UniDataModelLoader* pluginLoader = new UniDataModelLoader(); |
907 HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this, |
793 UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin( |
908 SLOT(onDialogSaveTone(HbAction*)), |
794 ConvergedMessage::BioMsg); |
909 HbMessageBox::Save | HbMessageBox::Cancel); |
795 pluginInterface->setMessageId(msgId); |
|
796 UniMessageInfoList attachments = pluginInterface->attachmentList(); |
|
797 |
|
798 QString attachmentPath = attachments.at(0)->path(); |
|
799 |
|
800 RingBc* ringBc = new RingBc(); |
|
801 ringBc->saveTone(attachmentPath); |
|
802 |
|
803 // clear attachement list : its allocated at data model |
|
804 while (!attachments.isEmpty()) { |
|
805 delete attachments.takeFirst(); |
|
806 } |
|
807 |
|
808 delete ringBc; |
|
809 delete pluginLoader; |
|
810 } |
|
811 |
|
812 // close the application once its handled |
|
813 HbApplication::quit(); |
|
814 } |
910 } |
815 |
911 |
816 // ---------------------------------------------------------------------------- |
912 // ---------------------------------------------------------------------------- |
817 // MsgViewManager::handleProvisoningMsg |
913 // MsgViewManager::handleProvisoningMsg |
818 // @see header |
914 // @see header |
842 delete aiwMgr; |
938 delete aiwMgr; |
843 |
939 |
844 // close the application once its handled |
940 // close the application once its handled |
845 HbApplication::quit(); |
941 HbApplication::quit(); |
846 } |
942 } |
|
943 |
|
944 void MsgViewManager::setViewInteractive() |
|
945 { |
|
946 if(!mMainWindow->isInteractive()) |
|
947 { |
|
948 mMainWindow->setInteractive(true); |
|
949 } |
|
950 |
|
951 disconnect(mMainWindow, SIGNAL(viewReady()),this,SLOT(setViewInteractive())); |
|
952 } |
|
953 |
|
954 void MsgViewManager::appendViewToBeDeleted(HbView* view) |
|
955 { |
|
956 if (view) |
|
957 { |
|
958 mViewTobeDeleted << view; |
|
959 connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(deletePreviousView()), Qt::UniqueConnection); |
|
960 } |
|
961 } |
|
962 |
|
963 // ---------------------------------------------------------------------------- |
|
964 // MsgViewManager::populateEditorAfterViewReady |
|
965 // @see header |
|
966 // ---------------------------------------------------------------------------- |
|
967 void MsgViewManager::populateUniEditorAfterViewReady(const QVariantList& editorData) |
|
968 { |
|
969 //Save the editor data and use it in ViewReady handler |
|
970 mEditorData = editorData; |
|
971 connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(populateUniEditorView())); |
|
972 } |
|
973 |
|
974 // ---------------------------------------------------------------------------- |
|
975 // MsgViewManager::populateUniEditorView |
|
976 // @see header |
|
977 // ---------------------------------------------------------------------------- |
|
978 void MsgViewManager::populateUniEditorView() |
|
979 { |
|
980 if (mUniEditor) |
|
981 { |
|
982 mUniEditor->openDraftsMessage(mEditorData); |
|
983 } |
|
984 mEditorData.clear(); |
|
985 |
|
986 disconnect(mMainWindow, SIGNAL(viewReady()), this, |
|
987 SLOT(populateUniEditorView())); |
|
988 } |
|
989 |
|
990 // ---------------------------------------------------------------------------- |
|
991 // MsgViewManager::onDialogDeleteMsg |
|
992 // @see header |
|
993 // ---------------------------------------------------------------------------- |
|
994 void MsgViewManager::onDialogDeleteMsg(HbAction* action) |
|
995 { |
|
996 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
997 if (action == dlg->actions().at(0)) { |
|
998 QList<int> msgIdList; |
|
999 msgIdList << mMessageId; |
|
1000 ConversationsEngine::instance()->deleteMessages(msgIdList); |
|
1001 } |
|
1002 HbApplication::quit(); // exit after handling |
|
1003 } |
|
1004 |
|
1005 // ---------------------------------------------------------------------------- |
|
1006 // MsgViewManager::onDialogSaveTone |
|
1007 // @see header |
|
1008 // ---------------------------------------------------------------------------- |
|
1009 void MsgViewManager::onDialogSaveTone(HbAction* action) |
|
1010 { |
|
1011 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1012 if (action == dlg->actions().at(0)) { |
|
1013 UniDataModelLoader* pluginLoader = new UniDataModelLoader(); |
|
1014 UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin( |
|
1015 ConvergedMessage::BioMsg); |
|
1016 pluginInterface->setMessageId(mMessageId); |
|
1017 UniMessageInfoList attachments = pluginInterface->attachmentList(); |
|
1018 |
|
1019 QString attachmentPath = attachments.at(0)->path(); |
|
1020 |
|
1021 RingBc* ringBc = new RingBc(); |
|
1022 ringBc->saveTone(attachmentPath); |
|
1023 |
|
1024 // clear attachement list : its allocated at data model |
|
1025 while (!attachments.isEmpty()) { |
|
1026 delete attachments.takeFirst(); |
|
1027 } |
|
1028 |
|
1029 delete ringBc; |
|
1030 delete pluginLoader; |
|
1031 } |
|
1032 |
|
1033 // close the application once its handled |
|
1034 HbApplication::quit(); |
|
1035 } |
|
1036 |
|
1037 // ---------------------------------------------------------------------------- |
|
1038 // MsgViewManager::currentView |
|
1039 // @see header |
|
1040 // ---------------------------------------------------------------------------- |
|
1041 int MsgViewManager::currentView() |
|
1042 { |
|
1043 return mCurrentView; |
|
1044 } |
|
1045 |
|
1046 // ---------------------------------------------------------------------------- |
|
1047 // MsgViewManager::switchToAudioFetcher |
|
1048 // @see header |
|
1049 // ---------------------------------------------------------------------------- |
|
1050 void MsgViewManager::switchToAudioFetcher(const QVariantList& data) |
|
1051 { |
|
1052 /** |
|
1053 * Audio Fetcher is tried to open again |
|
1054 */ |
|
1055 if(mAudioFetcherView) |
|
1056 { |
|
1057 return; |
|
1058 } |
|
1059 |
|
1060 //switch to Audio Fetcher view |
|
1061 mCurrentView = MsgBaseView::AUDIOFETCHER; |
|
1062 mPreviousView = data.at(1).toInt(); |
|
1063 QVariantList editorData; |
|
1064 // i=2 because view manager consumed first two args |
|
1065 for (int i = 2; i < data.length(); i++) { |
|
1066 editorData << data.at(i); |
|
1067 } |
|
1068 mAudioFetcherView = new MsgAudioFetcherView(editorData); |
|
1069 mAudioFetcherView->setNavigationAction(mBackAction); |
|
1070 connect(mAudioFetcherView, SIGNAL(switchView(const QVariantList&)), this, |
|
1071 SLOT(switchView(const QVariantList&))); |
|
1072 |
|
1073 if(mPreviousView==MsgBaseView::CV && mConversationView) |
|
1074 { |
|
1075 mConversationView->setPSCVId(false); |
|
1076 } |
|
1077 |
|
1078 mMainWindow->addView(mAudioFetcherView); |
|
1079 mMainWindow->setCurrentView(mAudioFetcherView); |
|
1080 } |
|
1081 |
|
1082 // ---------------------------------------------------------------------------- |
|
1083 // MsgViewManager::saveContentToDraft |
|
1084 // @see header |
|
1085 // ---------------------------------------------------------------------------- |
|
1086 int MsgViewManager::saveContentToDraft() |
|
1087 { |
|
1088 int msgId = NULL_CONVERSATIONID; |
|
1089 if( mCurrentView == MsgBaseView::CV ) |
|
1090 { |
|
1091 msgId = mConversationView->saveContentToDrafts(); |
|
1092 } |
|
1093 else if( mCurrentView ==MsgBaseView::UNIEDITOR) |
|
1094 { |
|
1095 msgId = mUniEditor->saveContentToDrafts(); |
|
1096 } |
|
1097 return msgId; |
|
1098 } |
|
1099 |
|
1100 // ---------------------------------------------------------------------------- |
|
1101 // MsgViewManager::saveContentToDraft |
|
1102 // @see header |
|
1103 // ---------------------------------------------------------------------------- |
|
1104 void MsgViewManager::openUniEditorActivity(int activityMsgId) |
|
1105 { |
|
1106 int msgType; |
|
1107 int msgSubType; |
|
1108 |
|
1109 qint32 messageId(activityMsgId); |
|
1110 // get the message type |
|
1111 ConversationsEngine::instance()->markAsReadAndGetType(messageId, msgType, msgSubType); |
|
1112 |
|
1113 if (!mUniEditor) { |
|
1114 mUniEditor = new MsgUnifiedEditorView(); |
|
1115 mMainWindow->addView(mUniEditor); |
|
1116 mUniEditor->setNavigationAction(mBackAction); |
|
1117 connect(mUniEditor, SIGNAL(switchView(const QVariantList&)), this, |
|
1118 SLOT(switchView(const QVariantList&))); |
|
1119 } |
|
1120 |
|
1121 // buffer data to open the draft message |
|
1122 ConvergedMessageId convergedMsgId(activityMsgId); |
|
1123 ConvergedMessage message; |
|
1124 message.setMessageType((ConvergedMessage::MessageType) msgType); |
|
1125 message.setMessageId(convergedMsgId); |
|
1126 |
|
1127 // Launch uni-editor view |
|
1128 QByteArray dataArray; |
|
1129 QDataStream messageStream(&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
1130 message.serialize(messageStream); |
|
1131 |
|
1132 QVariantList editorData; |
|
1133 editorData << dataArray; |
|
1134 mUniEditor->openDraftsMessage(editorData); |
|
1135 |
|
1136 // set the current view |
|
1137 mCurrentView = MsgBaseView::UNIEDITOR; |
|
1138 mMainWindow->setCurrentView(mUniEditor); |
|
1139 } |
|
1140 |
|
1141 // ---------------------------------------------------------------------------- |
|
1142 // MsgViewManager::findContactId |
|
1143 // @see header |
|
1144 // ---------------------------------------------------------------------------- |
|
1145 qint32 MsgViewManager::findContactId(QString address) |
|
1146 { |
|
1147 QString displayLabel; |
|
1148 int count; |
|
1149 int localId = |
|
1150 MsgContactHandler::resolveContactDisplayName(address, |
|
1151 displayLabel, |
|
1152 count); |
|
1153 |
|
1154 return localId; |
|
1155 } |
|
1156 |
|
1157 //EOF |