messagingapp/msgui/msgapp/src/msgviewmanager.cpp
changeset 27 e4592d119491
parent 25 84d9eb65b26f
child 47 5b14749788d7
equal deleted inserted replaced
25:84d9eb65b26f 27:e4592d119491
    24 #include <QSqlQuery>
    24 #include <QSqlQuery>
    25 #include <QSqlError>
    25 #include <QSqlError>
    26 #include <HbApplication>
    26 #include <HbApplication>
    27 #include <xqappmgr.h>
    27 #include <xqappmgr.h>
    28 #include <HbMessageBox.h>
    28 #include <HbMessageBox.h>
       
    29 #include <HbView>
    29 
    30 
    30 #include "conversationsengine.h"
    31 #include "conversationsengine.h"
    31 #include "msglistview.h"
    32 #include "msglistview.h"
    32 #include "msgunieditorview.h"
    33 #include "msgunieditorview.h"
    33 #include "msgconversationbaseview.h"
    34 #include "msgconversationbaseview.h"
    41 
    42 
    42 // LOCALIZATION
    43 // LOCALIZATION
    43 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
    44 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
    44 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
    45 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
    45 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
    46 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
       
    47 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
       
    48 #define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
    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) :
    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), mBackAction(0), mServiceRequest(
    52             serviceRequest), mConversationId(-1), mViewServiceRequest(false)
    55             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) {
    60         QVariantList param;
    63         QVariantList param;
    61         param << MsgBaseView::CLV;
    64         param << MsgBaseView::CLV;
    62         param << MsgBaseView::CLV;
    65         param << MsgBaseView::CLV;
    63         switchView(param);
    66         switchView(param);
    64     }
    67     }
       
    68     else
       
    69     {
       
    70         mDummyview = new HbView();
       
    71         mMainWindow->addView(mDummyview);
       
    72         mMainWindow->setCurrentView(mDummyview);
       
    73         mViewTobeDeleted << mDummyview;
       
    74     }
    65 }
    75 }
    66 
    76 
    67 MsgViewManager::~MsgViewManager()
    77 MsgViewManager::~MsgViewManager()
    68 {
    78 {
    69     // TODO Auto-generated destructor stub
    79     // TODO Auto-generated destructor stub
    96         mConversationView->saveContentToDrafts();
   106         mConversationView->saveContentToDrafts();
    97 
   107 
    98         //marking messages as red in CV.
   108         //marking messages as red in CV.
    99         mConversationView->markMessagesAsRead();
   109         mConversationView->markMessagesAsRead();
   100 
   110 
       
   111         // reset the conversation id published
       
   112         mConversationView->setPSCVId(false);
       
   113         
   101         //clearing content of cv.
   114         //clearing content of cv.
   102         mConversationView->clearContent();
   115         mConversationView->clearContent();
   103 
   116 
   104         // if service request for veiwer the just switch to univiewer.
   117         // if service request for veiwer the just switch to univiewer.
   105         if (mViewServiceRequest) {
   118         if (mViewServiceRequest) {
   148             mCurrentView = MsgBaseView::UNIVIEWER;
   161             mCurrentView = MsgBaseView::UNIVIEWER;
   149             mMainWindow->setCurrentView(mUniViewer);
   162             mMainWindow->setCurrentView(mUniViewer);
   150             break;
   163             break;
   151         }
   164         }
   152 
   165 
   153         //Now UE can be launched from viewer and on its back
       
   154         //we need to clear viewer
       
   155         if (mUniViewer) {
       
   156             mMainWindow->removeView(mUniViewer);
       
   157             delete mUniViewer;
       
   158             mUniViewer = NULL;
       
   159         }
       
   160 
       
   161         //switch to clv.
   166         //switch to clv.
   162         if (mServiceRequest) {
   167         if (mServiceRequest) {
   163             completeServiceRequest();
   168             completeServiceRequest();
   164         }
   169         }
   165         else {
   170         else {
   184             param << MsgBaseView::CV;
   189             param << MsgBaseView::CV;
   185             param << MsgBaseView::UNIVIEWER;
   190             param << MsgBaseView::UNIVIEWER;
   186             param << mConversationId;
   191             param << mConversationId;
   187             switchView(param);
   192             switchView(param);
   188 
   193 
   189             delete mUniViewer;
       
   190             mUniViewer = NULL;
       
   191         }
   194         }
   192         break;
   195         break;
   193     }
   196     }
   194     case MsgBaseView::MSGSETTINGS:
   197     case MsgBaseView::MSGSETTINGS:
   195     {
   198     {
   206     }
   209     }
   207 }
   210 }
   208 
   211 
   209 void MsgViewManager::switchView(const QVariantList& data)
   212 void MsgViewManager::switchView(const QVariantList& data)
   210 {
   213 {
       
   214    
       
   215     connect(mMainWindow, SIGNAL(viewReady()),this,SLOT(setViewInteractive()));
       
   216     mMainWindow->setInteractive(false);
       
   217     
   211     int viewId = data.at(0).toInt();
   218     int viewId = data.at(0).toInt();
       
   219     
   212     switch (viewId) {
   220     switch (viewId) {
   213     case MsgBaseView::DEFAULT:
   221     case MsgBaseView::DEFAULT:
   214     {
   222     {
   215         handleDefault(data);
   223         handleDefault(data);
   216         break;
   224         break;
   217     }
   225     }
   218     case MsgBaseView::CLV:
   226     case MsgBaseView::CLV:
   219     {
   227     {
   220         switchToClv(data);
   228             switchToClv(data);
   221         break;
   229             break;
   222     }
   230         }
   223 
   231 
   224     case MsgBaseView::CV:
   232         case MsgBaseView::CV:
   225     {
   233         {
   226         switchToCv(data);
   234 
   227         break;
   235             switchToCv(data);
   228     }
   236             break;
       
   237         }
   229 
   238 
   230     case MsgBaseView::DLV:
   239     case MsgBaseView::DLV:
   231     {
   240     {
   232         switchToDlv(data);
   241         switchToDlv(data);
   233         break;
   242         break;
   250         switchToMsgSettings(data);
   259         switchToMsgSettings(data);
   251         break;
   260         break;
   252     }
   261     }
   253     }
   262     }
   254 }
   263 }
       
   264 
       
   265 void MsgViewManager::deletePreviousView()
       
   266 {
       
   267     while(mViewTobeDeleted.count())
       
   268     {
       
   269         HbView* v = mViewTobeDeleted.takeAt(0);
       
   270         mMainWindow->removeView(v);
       
   271         delete v;
       
   272     }
       
   273     disconnect(mMainWindow, SIGNAL(viewReady()), this, SLOT(deletePreviousView()));
       
   274 }
       
   275 
   255 
   276 
   256 void MsgViewManager::send(const qint32 contactId, const QString phoneNumber,
   277 void MsgViewManager::send(const qint32 contactId, const QString phoneNumber,
   257     const QString displayName)
   278     const QString displayName)
   258 {
   279 {
   259     qint64 conversationId = ConversationsEngine::instance()-> getConversationIdFromContactId(
   280     qint64 conversationId = ConversationsEngine::instance()-> getConversationIdFromContactId(
   346     QVariantList param;
   367     QVariantList param;
   347 
   368 
   348     if (conversationId < 0) {
   369     if (conversationId < 0) {
   349         param << MsgBaseView::CLV;
   370         param << MsgBaseView::CLV;
   350         param << MsgBaseView::SERVICE;
   371         param << MsgBaseView::SERVICE;
       
   372         
       
   373         if( mCurrentView == MsgBaseView::CV && mConversationView)
       
   374             {
       
   375             mConversationView->setPSCVId(false);
       
   376             }
   351     }
   377     }
   352     else {
   378     else {
   353         param << MsgBaseView::CV;
   379         param << MsgBaseView::CV;
   354         param << MsgBaseView::SERVICE;
   380         param << MsgBaseView::SERVICE;
   355         param << conversationId;
   381         param << conversationId;
   431     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
   457     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
   432         // quit the application 
   458         // quit the application 
   433         HbApplication::quit();
   459         HbApplication::quit();
   434     }
   460     }
   435 
   461 
   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) {
   462     if (mConversationView) {
       
   463         mConversationView->saveContentToDrafts();
   443         //clearing content of cv.
   464         //clearing content of cv.
   444         mConversationView->clearContent();
   465         mConversationView->clearContent();
   445     }
   466     }
   446 
   467 
   447     if (!mListView) {
   468     if (!mListView) {
   450         connect(mListView, SIGNAL(switchView(const QVariantList&)), this,
   471         connect(mListView, SIGNAL(switchView(const QVariantList&)), this,
   451             SLOT(switchView(const QVariantList&)));
   472             SLOT(switchView(const QVariantList&)));
   452         mMainWindow->addView(mListView);
   473         mMainWindow->addView(mListView);
   453     }
   474     }
   454 
   475 
   455     //delete uni editor.
   476     mMainWindow->setCurrentView(mListView);
   456     if (mUniEditor) {
   477     
   457         mMainWindow->removeView(mUniEditor);
   478     //delete UniEditor
   458         delete mUniEditor;
   479     if (mUniEditor)
       
   480     {
       
   481         appendViewToBeDeleted(mUniEditor);
   459         mUniEditor = NULL;
   482         mUniEditor = NULL;
   460     }
   483     }
   461 
   484     
   462     if (mUniViewer) {
   485     //delete UniViewer
   463         mMainWindow->removeView(mUniViewer);
   486     if (mUniViewer)
   464         delete mUniViewer;
   487     {
       
   488         appendViewToBeDeleted(mUniViewer);
   465         mUniViewer = NULL;
   489         mUniViewer = NULL;
   466     }
   490     }
   467 
       
   468     mMainWindow->setCurrentView(mListView);
       
   469 }
   491 }
   470 
   492 
   471 void MsgViewManager::switchToCv(const QVariantList& data)
   493 void MsgViewManager::switchToCv(const QVariantList& data)
   472 {
   494 {
   473     //switch to CV.
   495     //switch to CV.
   476 
   498 
   477     // delete case from viewer service
   499     // delete case from viewer service
   478     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
   500     if (mViewServiceRequest && (mPreviousView == MsgBaseView::UNIVIEWER)) {
   479         // quit the application 
   501         // quit the application 
   480         HbApplication::quit();
   502         HbApplication::quit();
   481     }
       
   482 
       
   483     //delete uni editor.
       
   484     if (mUniEditor) {
       
   485         mMainWindow->removeView(mUniEditor);
       
   486         delete mUniEditor;
       
   487         mUniEditor = NULL;
       
   488     }
       
   489 
       
   490     if (mUniViewer) {
       
   491         mMainWindow->removeView(mUniViewer);
       
   492         delete mUniViewer;
       
   493         mUniViewer = NULL;
       
   494     }
   503     }
   495 
   504 
   496     QVariant var = data.at(2);
   505     QVariant var = data.at(2);
   497     qint64 conversationId;
   506     qint64 conversationId;
   498     if (var.type() == QVariant::String) {
   507     if (var.type() == QVariant::String) {
   501 
   510 
   502         if (conversationId == NULL_CONVERSATIONID) {
   511         if (conversationId == NULL_CONVERSATIONID) {
   503             QVariantList param;
   512             QVariantList param;
   504             param << MsgBaseView::CLV;
   513             param << MsgBaseView::CLV;
   505             param << MsgBaseView::CV;
   514             param << MsgBaseView::CV;
       
   515             
       
   516             if( mCurrentView == MsgBaseView::CV && mConversationView){
       
   517                 mConversationView->setPSCVId(false);
       
   518                 }
       
   519             
   506             switchView(param);
   520             switchView(param);
   507             return;
   521             return;
   508         }
   522         }
   509     }
   523     }
   510     else if (var.type() == QVariant::Invalid) {
   524     else if (var.type() == QVariant::Invalid) {
   511         // this case comes when a message is deleted from 
   525         // this case comes when a message is deleted from 
   512         // Unified viewer  set curent view as conversation view 
   526         // Unified viewer  set curent view as conversation view 
   513         // and return
   527         // and return
   514         mMainWindow->setCurrentView(mConversationView);
   528         mMainWindow->setCurrentView(mConversationView);
   515 
   529 		
   516         delete mUniViewer;
   530 		// publish already opened conversation's id
   517         mUniViewer = NULL;
   531         mConversationView->setPSCVId(true);
       
   532 		
       
   533         if (mUniViewer)
       
   534         {
       
   535             appendViewToBeDeleted(mUniViewer);
       
   536             mUniViewer = NULL;
       
   537         }
   518 
   538 
   519         return;
   539         return;
   520     }
   540     }
   521     else {
   541     else {
   522         conversationId = var.toLongLong();
   542         conversationId = var.toLongLong();
   530         connect(mConversationView, SIGNAL(switchView(const QVariantList&)), this,
   550         connect(mConversationView, SIGNAL(switchView(const QVariantList&)), this,
   531             SLOT(switchView(const QVariantList&)));
   551             SLOT(switchView(const QVariantList&)));
   532 
   552 
   533         mMainWindow->addView(mConversationView);
   553         mMainWindow->addView(mConversationView);
   534     }
   554     }
       
   555     else if (mConversationView->conversationId() != mConversationId){
       
   556   		//Save content to drafts before switching to different CV
       
   557         mConversationView->saveContentToDrafts();
       
   558         //clearing content of current cv.
       
   559         mConversationView->clearContent();
       
   560   	}	
   535 
   561 
   536     mConversationView->openConversation(conversationId);
   562     mConversationView->openConversation(conversationId);
   537 
   563 
   538     if (mServiceRequest) {
   564     if (mServiceRequest) {
   539         mMainWindow->setCurrentView(mConversationView);
   565         mMainWindow->setCurrentView(mConversationView);
   540     }
   566     }
   541     else {
   567     else {
   542         mMainWindow->setCurrentView(mConversationView);
   568         mMainWindow->setCurrentView(mConversationView);
       
   569     }
       
   570     
       
   571     //delete UniEditor
       
   572     if (mUniEditor)
       
   573     {
       
   574         appendViewToBeDeleted(mUniEditor);
       
   575         mUniEditor = NULL;
       
   576     }
       
   577     
       
   578     //delete UniViewer
       
   579     if (mUniViewer)
       
   580     {
       
   581         appendViewToBeDeleted(mUniViewer);
       
   582         mUniViewer = NULL;
   543     }
   583     }
   544 }
   584 }
   545 
   585 
   546 void MsgViewManager::switchToDlv(const QVariantList& data)
   586 void MsgViewManager::switchToDlv(const QVariantList& data)
   547 {
   587 {
   548     //switch to DLV.
   588     //switch to DLV.
   549     mCurrentView = MsgBaseView::DLV;
   589     mCurrentView = MsgBaseView::DLV;
   550     mPreviousView = data.at(1).toInt();
   590     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 
   591 
   559     if (!mDraftsListView) {
   592     if (!mDraftsListView) {
   560         mDraftsListView = new DraftsListView();
   593         mDraftsListView = new DraftsListView();
   561         mDraftsListView->setNavigationAction(mBackAction);
   594         mDraftsListView->setNavigationAction(mBackAction);
   562         connect(mDraftsListView, SIGNAL(switchView(const QVariantList&)), this,
   595         connect(mDraftsListView, SIGNAL(switchView(const QVariantList&)), this,
   583     if (mConversationView) {
   616     if (mConversationView) {
   584         //clearing content of cv.
   617         //clearing content of cv.
   585         mConversationView->clearContent();
   618         mConversationView->clearContent();
   586     }
   619     }
   587 
   620 
       
   621      // reset conversation id published
       
   622      if(mPreviousView == MsgBaseView::CV && mConversationView)
       
   623          {
       
   624          mConversationView->setPSCVId(false);
       
   625          }
       
   626      
   588     //swich to unieditor.
   627     //swich to unieditor.
   589     if (!mUniEditor) {
   628     if (!mUniEditor) {
   590         mUniEditor = new MsgUnifiedEditorView();
   629         mUniEditor = new MsgUnifiedEditorView();
   591         mMainWindow->addView(mUniEditor);
   630         mMainWindow->addView(mUniEditor);
   592         mUniEditor->setNavigationAction(mBackAction);
   631         mUniEditor->setNavigationAction(mBackAction);
   613     if (mServiceRequest) {
   652     if (mServiceRequest) {
   614         mMainWindow->setCurrentView(mUniEditor);
   653         mMainWindow->setCurrentView(mUniEditor);
   615     }
   654     }
   616     else {
   655     else {
   617         mMainWindow->setCurrentView(mUniEditor);
   656         mMainWindow->setCurrentView(mUniEditor);
       
   657     }
       
   658     //delete UniViewer
       
   659     if (mUniViewer )
       
   660     {
       
   661         appendViewToBeDeleted(mUniViewer);
       
   662         mUniViewer = NULL;
   618     }
   663     }
   619 }
   664 }
   620 
   665 
   621 void MsgViewManager::switchToUniViewer(const QVariantList& data)
   666 void MsgViewManager::switchToUniViewer(const QVariantList& data)
   622 {
   667 {
   649                 SLOT(switchView(const QVariantList&)));
   694                 SLOT(switchView(const QVariantList&)));
   650         }
   695         }
   651         mUniViewer->populateContent(messageId, true, msgCount);
   696         mUniViewer->populateContent(messageId, true, msgCount);
   652         delete message;
   697         delete message;
   653     }
   698     }
       
   699     
       
   700     if(mPreviousView==MsgBaseView::CV && mConversationView)
       
   701         {
       
   702         mConversationView->setPSCVId(false);
       
   703         }
       
   704     
   654     mMainWindow->setCurrentView(mUniViewer);
   705     mMainWindow->setCurrentView(mUniViewer);
   655 }
   706 }
   656 void MsgViewManager::switchToMsgSettings(const QVariantList& data)
   707 void MsgViewManager::switchToMsgSettings(const QVariantList& data)
   657 {
   708 {
   658     mCurrentView = MsgBaseView::MSGSETTINGS;
   709     mCurrentView = MsgBaseView::MSGSETTINGS;
   659     mPreviousView = data.at(1).toInt();
   710     mPreviousView = data.at(1).toInt();
   660 
   711 
   661     if (!mSettingsView) {
   712     if (!mSettingsView) {
   662         mSettingsView = new MsgSettingsView();
   713         
       
   714         MsgSettingsView::SettingsView view = MsgSettingsView::DefaultView;
       
   715         if (mPreviousView == MsgBaseView::UNIEDITOR || mPreviousView
       
   716                         == MsgBaseView::CV)
       
   717                 {
       
   718                     view = (MsgSettingsView::SettingsView)data.at(2).toInt();         
       
   719                 }
       
   720         
       
   721         mSettingsView = new MsgSettingsView(view);
   663         mSettingsView->setNavigationAction(mBackAction);
   722         mSettingsView->setNavigationAction(mBackAction);
   664         mMainWindow->addView(mSettingsView);
   723         mMainWindow->addView(mSettingsView);
   665         mMainWindow->setCurrentView(mSettingsView);
   724         mMainWindow->setCurrentView(mSettingsView);
   666     }
   725     }
       
   726     if(mPreviousView==MsgBaseView::CV && mConversationView){
       
   727         mConversationView->setPSCVId(false);
       
   728         }
   667 }
   729 }
   668 
   730 
   669 void MsgViewManager::handleDefault(const QVariantList& data)
   731 void MsgViewManager::handleDefault(const QVariantList& data)
   670 {
   732 {
   671     //special handling incase we switch from settings-view
   733     //special handling incase we switch from settings-view
   673     if (MsgBaseView::MSGSETTINGS == previousViewId) {
   735     if (MsgBaseView::MSGSETTINGS == previousViewId) {
   674         //switch to view, where from settings view was launched
   736         //switch to view, where from settings view was launched
   675         mCurrentView = mPreviousView;
   737         mCurrentView = mPreviousView;
   676         mPreviousView = previousViewId;
   738         mPreviousView = previousViewId;
   677         //remove the settings view from main window
   739         //remove the settings view from main window
   678         if (mSettingsView) {
   740         if (mSettingsView)
   679             mMainWindow->removeView(mSettingsView);
   741         {
   680             delete mSettingsView;
   742             appendViewToBeDeleted(mSettingsView);
   681             mSettingsView = NULL;
   743             mSettingsView = NULL;
   682         }
   744         }
   683         switch (mCurrentView) {
   745         switch (mCurrentView) {
   684         case MsgBaseView::CLV:
   746         case MsgBaseView::CLV:
   685         {
   747         {
   715 
   777 
   716 void MsgViewManager::view(int msgId)
   778 void MsgViewManager::view(int msgId)
   717 {
   779 {
   718     int msgType;
   780     int msgType;
   719     int msgSubType;
   781     int msgSubType;
   720 
   782     mMessageId = msgId;
   721     qint32 messageId(msgId);
   783     qint32 messageId(msgId);
   722     ConversationsEngine::instance()->markAsReadAndGetType(messageId, msgType, msgSubType);
   784     ConversationsEngine::instance()->markAsReadAndGetType(messageId, msgType, msgSubType);
   723 
   785 
   724     switch (msgType) {
   786     switch (msgType) {
   725     case ConvergedMessage::Sms:
   787     case ConvergedMessage::Sms:
   745         break;
   807         break;
   746     }
   808     }
   747     default:
   809     default:
   748     {
   810     {
   749         // for un supported message show delete option
   811         // for un supported message show delete option
   750         bool result = HbMessageBox::question(LOC_DELETE_MESSAGE, LOC_BUTTON_DELETE,
   812         HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogDeleteMsg(HbAction*)),
       
   813             LOC_BUTTON_DELETE,
   751             LOC_BUTTON_CANCEL);
   814             LOC_BUTTON_CANCEL);
   752         if (result) {
       
   753             QList<int> msgIdList;
       
   754             msgIdList << msgId;
       
   755             ConversationsEngine::instance()->deleteMessages(msgIdList);
       
   756         }
       
   757         HbApplication::quit(); // exit after handling
       
   758         break;
   815         break;
   759     }
   816     }
   760     }
   817     }
   761 }
   818 }
   762 
   819 
   786 // MsgViewManager::handleRingtoneMsg
   843 // MsgViewManager::handleRingtoneMsg
   787 // @see header
   844 // @see header
   788 // ----------------------------------------------------------------------------
   845 // ----------------------------------------------------------------------------
   789 void MsgViewManager::handleRingtoneMsg(int msgId)
   846 void MsgViewManager::handleRingtoneMsg(int msgId)
   790 {
   847 {
   791     if (RingBc::askSaveQuery()) {
   848     mMessageId = msgId;
   792         UniDataModelLoader* pluginLoader = new UniDataModelLoader();
   849     HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this,
   793         UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin(
   850         SLOT(onDialogSaveTone(HbAction*)), LOC_COMMON_SAVE, LOC_BUTTON_CANCEL);
   794             ConvergedMessage::BioMsg);
       
   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 }
   851 }
   815 
   852 
   816 // ----------------------------------------------------------------------------
   853 // ----------------------------------------------------------------------------
   817 // MsgViewManager::handleProvisoningMsg
   854 // MsgViewManager::handleProvisoningMsg
   818 // @see header
   855 // @see header
   842     delete aiwMgr;
   879     delete aiwMgr;
   843 
   880 
   844     // close the application once its handled
   881     // close the application once its handled
   845     HbApplication::quit();
   882     HbApplication::quit();
   846 }
   883 }
       
   884 
       
   885 void MsgViewManager::setViewInteractive()
       
   886 {
       
   887     if(!mMainWindow->isInteractive())
       
   888     {
       
   889         mMainWindow->setInteractive(true);
       
   890     }
       
   891     
       
   892     disconnect(mMainWindow, SIGNAL(viewReady()),this,SLOT(setViewInteractive()));
       
   893 }
       
   894 
       
   895 void  MsgViewManager::appendViewToBeDeleted(HbView* view)
       
   896 {
       
   897     if (view)
       
   898     {
       
   899         mViewTobeDeleted << view;
       
   900         connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(deletePreviousView()));
       
   901     }
       
   902 }
       
   903 
       
   904 // ----------------------------------------------------------------------------
       
   905 // MsgViewManager::onDialogDeleteMsg
       
   906 // @see header
       
   907 // ----------------------------------------------------------------------------
       
   908 void MsgViewManager::onDialogDeleteMsg(HbAction* action)
       
   909 {
       
   910     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
       
   911     if (action == dlg->actions().at(0)) {
       
   912         QList<int> msgIdList;
       
   913         msgIdList << mMessageId;
       
   914         ConversationsEngine::instance()->deleteMessages(msgIdList);
       
   915     }
       
   916     HbApplication::quit(); // exit after handling
       
   917 }
       
   918 
       
   919 // ----------------------------------------------------------------------------
       
   920 // MsgViewManager::onDialogSaveTone
       
   921 // @see header
       
   922 // ----------------------------------------------------------------------------
       
   923 void MsgViewManager::onDialogSaveTone(HbAction* action)
       
   924     {
       
   925         HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
       
   926         if (action == dlg->actions().at(0)) {
       
   927             UniDataModelLoader* pluginLoader = new UniDataModelLoader();
       
   928             UniDataModelPluginInterface* pluginInterface = pluginLoader->getDataModelPlugin(
       
   929                 ConvergedMessage::BioMsg);
       
   930             pluginInterface->setMessageId(mMessageId);
       
   931             UniMessageInfoList attachments = pluginInterface->attachmentList();
       
   932 
       
   933             QString attachmentPath = attachments.at(0)->path();
       
   934 
       
   935             RingBc* ringBc = new RingBc();
       
   936             ringBc->saveTone(attachmentPath);
       
   937 
       
   938             // clear attachement list : its allocated at data model
       
   939             while (!attachments.isEmpty()) {
       
   940                 delete attachments.takeFirst();
       
   941             }
       
   942 
       
   943             delete ringBc;
       
   944             delete pluginLoader;
       
   945         }
       
   946 
       
   947         // close the application once its handled
       
   948         HbApplication::quit();
       
   949 }
       
   950