messagingapp/msgui/conversationview/src/msgconversationview.cpp
branchGCC_SURGE
changeset 47 5b14749788d7
parent 27 e4592d119491
parent 44 36f374c67aa8
equal deleted inserted replaced
35:a32b19fb291e 47:5b14749788d7
    22 #include <HbAction>
    22 #include <HbAction>
    23 #include <HbListView>
    23 #include <HbListView>
    24 #include <HbMessageBox>
    24 #include <HbMessageBox>
    25 #include <HbNotificationDialog>
    25 #include <HbNotificationDialog>
    26 #include <HbFrameBackground>
    26 #include <HbFrameBackground>
    27 #include <XQServiceRequest.h>
    27 #include <xqservicerequest.h>
    28 #include <HbStaticVkbHost>
    28 #include <HbStaticVkbHost>
    29 #include <HbStyleLoader>
    29 #include <HbStyleLoader>
    30 #include <xqaiwrequest.h>
    30 #include <xqaiwrequest.h>
    31 #include <xqappmgr.h>
    31 #include <xqappmgr.h>
       
    32 #include <HbMainWindow>
    32 
    33 
    33 #include <QDir>
    34 #include <QDir>
    34 #include <QDateTime>
    35 #include <QDateTime>
    35 #include <QGraphicsLinearLayout>
    36 #include <QGraphicsLinearLayout>
    36 #include <QStandardItemModel>
    37 #include <QStandardItemModel>
    39 #include <ccsdefs.h>
    40 #include <ccsdefs.h>
    40 #include <centralrepository.h>
    41 #include <centralrepository.h>
    41 #include <MmsEngineDomainCRKeys.h>
    42 #include <MmsEngineDomainCRKeys.h>
    42 
    43 
    43 // USER INCLUDES
    44 // USER INCLUDES
       
    45 #include "msgcontactsutil.h"
    44 #include "msgsendutil.h"
    46 #include "msgsendutil.h"
    45 #include "msgconversationviewitem.h"
    47 #include "msgconversationviewitem.h"
    46 #include "conversationsengine.h"
    48 #include "conversationsengine.h"
    47 #include "convergedmessageid.h"
    49 #include "convergedmessageid.h"
    48 #include "conversationsenginedefines.h"
    50 #include "conversationsenginedefines.h"
    53 #include "unidatamodelloader.h"
    55 #include "unidatamodelloader.h"
    54 #include "unidatamodelplugininterface.h"
    56 #include "unidatamodelplugininterface.h"
    55 #include "ringbc.h"
    57 #include "ringbc.h"
    56 #include "mmsconformancecheck.h"
    58 #include "mmsconformancecheck.h"
    57 #include "msgsettingsview.h"
    59 #include "msgsettingsview.h"
       
    60 #include "msgaudiofetcherview.h"
    58 
    61 
    59 //Item specific menu.
    62 //Item specific menu.
    60 
    63 
    61 #define LOC_COMMON_OPEN hbTrId("txt_common_menu_open")
    64 #define LOC_COMMON_OPEN hbTrId("txt_common_menu_open")
    62 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete")
    65 #define LOC_COMMON_DELETE hbTrId("txt_common_menu_delete")
    63 #define LOC_COMMON_FORWARD hbTrId("txt_common_menu_forward")
    66 #define LOC_COMMON_FORWARD hbTrId("txt_common_menu_forward")
    64 #define LOC_COMMON_DOWNLOAD hbTrId("txt_messaging_menu_download")
    67 #define LOC_COMMON_DOWNLOAD hbTrId("txt_messaging_menu_download")
    65 #define LOC_COMMON_SEND  hbTrId("txt_common_menu_send") 
    68 #define LOC_COMMON_SEND  hbTrId("txt_common_button_send") 
    66 #define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
    69 #define LOC_COMMON_SAVE  hbTrId("txt_common_menu_save")
    67 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete")
       
    68 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel")
       
    69 #define LOC_BUTTON_OK hbTrId("txt_common_button_ok")
       
    70 
    70 
    71 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
    71 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
       
    72 #define LOC_SAVE_TO_CONTACTS hbTrId("txt_messaging_menu_save_to_contacts")
    72 
    73 
    73 //main menu
    74 //main menu
    74 #define LOC_ATTACH          hbTrId("txt_messaging_opt_attach")
    75 #define LOC_ATTACH          hbTrId("txt_messaging_opt_attach")
    75 #define LOC_PHOTO           hbTrId("txt_messaging_opt_attach_sub_photo")
    76 #define LOC_PHOTO           hbTrId("txt_messaging_opt_attach_sub_photo")
    76 #define LOC_SOUND           hbTrId("txt_messaging_opt_attach_sub_sound")
    77 #define LOC_SOUND           hbTrId("txt_messaging_opt_attach_sub_sound")
    77 #define LOC_VCARD           hbTrId("txt_messaging_list_business_card")
    78 #define LOC_VCARD           hbTrId("txt_messaging_list_business_card")
    78 #define LOC_ADD_RECIPIENTS  hbTrId("txt_messaging_opt_add_recipients")
    79 #define LOC_ADD_RECIPIENTS  hbTrId("txt_messaging_opt_add_recipients")
    79 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
    80 #define LOC_ADD_SUBJECT     hbTrId("txt_messaging_opt_add_subject")
    80 
    81 
    81 #define LOC_MSG_SEND_FAILED hbTrId("txt_messaging_dpopinfo_sending_failed")
    82 #define LOC_MSG_SEND_FAILED hbTrId("txt_messaging_dialog_message_sending_failed")
    82 
       
    83 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_settings_incomplete")
    83 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_settings_incomplete")
    84 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
    84 #define LOC_DIALOG_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
    85 
       
    86 
    85 
    87 
    86 
    88 const int INVALID_MSGID = -1;
    87 const int INVALID_MSGID = -1;
    89 const int INVALID_CONVID = -1;
    88 const int INVALID_CONVID = -1;
    90 const int CONTACT_INSERTION_MODE = 1;
    89 const int CONTACT_INSERTION_MODE = 1;
   100     mConversationList(NULL),
    99     mConversationList(NULL),
   101     mMessageModel(NULL),
   100     mMessageModel(NULL),
   102     mEditorWidget(NULL),
   101     mEditorWidget(NULL),
   103     mContactCardWidget(contactCardWidget),
   102     mContactCardWidget(contactCardWidget),
   104     mSendUtil(NULL),
   103     mSendUtil(NULL),
   105     mItemLongPressed(false),
       
   106     mVkbHost(NULL),
   104     mVkbHost(NULL),
   107     mVkbopened(false)
   105     mVisibleIndex(),
       
   106     mVkbopened(false),
       
   107     mModelPopulated(false),
       
   108     mViewReady(false)
   108 {
   109 {
   109     //create send utils
   110     //create send utils
   110     mSendUtil = new MsgSendUtil(this);
   111     mSendUtil = new MsgSendUtil(this);
   111     //initialize view
   112     //initialize view
   112     setupView();
   113     setupView();
   113     setupMenu();
   114     setupMenu();
       
   115     
       
   116     connect(ConversationsEngine::instance(), 
       
   117                      SIGNAL(conversationModelUpdated()),
       
   118                      this, 
       
   119                      SLOT(scrollToBottom()));
       
   120 
       
   121     connect(ConversationsEngine::instance(), 
       
   122                          SIGNAL(conversationViewEmpty()),
       
   123                          this, 
       
   124                          SLOT(onConversationViewEmpty()));
   114 }
   125 }
   115 
   126 
   116 //---------------------------------------------------------------
   127 //---------------------------------------------------------------
   117 // MsgConversationView::~MsgConversationView
   128 // MsgConversationView::~MsgConversationView
   118 // @see header file
   129 // @see header file
   150             this, 
   161             this, 
   151             SLOT(populateConversationsView()));
   162             SLOT(populateConversationsView()));
   152     
   163     
   153     connect(mConversationList, SIGNAL(activated(QModelIndex)),
   164     connect(mConversationList, SIGNAL(activated(QModelIndex)),
   154             this, SLOT(openItem(QModelIndex)));
   165             this, SLOT(openItem(QModelIndex)));
       
   166     connect(this->mainWindow(), SIGNAL(aboutToChangeOrientation()),
       
   167                 this, SLOT(onOrientationAboutToBeChanged()));
       
   168     
       
   169     connect(this->mainWindow(), SIGNAL(orientationChanged(Qt::Orientation)),
       
   170                     this, SLOT(onOrientationChanged(Qt::Orientation)));
   155 
   171 
   156     // Long tap list item
   172     // Long tap list item
   157     connect(mConversationList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)),
   173     connect(mConversationList, SIGNAL(longPressed(HbAbstractViewItem*, QPointF)),
   158             this, SLOT(longPressed(HbAbstractViewItem*, QPointF)));
   174             this, SLOT(longPressed(HbAbstractViewItem*, QPointF)));
   159 
   175 
   196     // Just create dummy menu.
   212     // Just create dummy menu.
   197     // Actual menu will be created in menuAboutToShow()
   213     // Actual menu will be created in menuAboutToShow()
   198     HbMenu *mainMenu = this->menu();
   214     HbMenu *mainMenu = this->menu();
   199     HbAction* clearConversation = mainMenu->addAction(QString());
   215     HbAction* clearConversation = mainMenu->addAction(QString());
   200     connect(mainMenu, SIGNAL(aboutToShow()), this, SLOT(menuAboutToShow()));
   216     connect(mainMenu, SIGNAL(aboutToShow()), this, SLOT(menuAboutToShow()));
       
   217 }
       
   218 
       
   219 //---------------------------------------------------------------
       
   220 // MsgConversationView::fetchMoreConversations
       
   221 // @see header file
       
   222 //---------------------------------------------------------------
       
   223 void MsgConversationView::fetchMoreConversations()
       
   224 {
       
   225     if (mViewReady && mModelPopulated) {
       
   226         ConversationsEngine::instance()->fetchMoreConversations();
       
   227         mViewReady = mModelPopulated = false;
       
   228     }
   201 }
   229 }
   202 
   230 
   203 //---------------------------------------------------------------
   231 //---------------------------------------------------------------
   204 // MsgConversationView::refreshView()
   232 // MsgConversationView::refreshView()
   205 // @see header file
   233 // @see header file
   232     const int rowCnt = mMessageModel->rowCount();
   260     const int rowCnt = mMessageModel->rowCount();
   233     mConversationList->scrollTo(
   261     mConversationList->scrollTo(
   234             mMessageModel->index(rowCnt - 1, 0));
   262             mMessageModel->index(rowCnt - 1, 0));
   235 }
   263 }
   236 
   264 
       
   265 void MsgConversationView::onConversationViewEmpty()
       
   266 {
       
   267     QVariantList param;
       
   268     param << MsgBaseView::CLV; // target view
       
   269     param << MsgBaseView::CV; // source view
       
   270     emit switchView(param);
       
   271 }
       
   272 
   237 //---------------------------------------------------------------
   273 //---------------------------------------------------------------
   238 // MsgConversationView::longPressed
   274 // MsgConversationView::longPressed
   239 // @see header file
   275 // @see header file
   240 //---------------------------------------------------------------
   276 //---------------------------------------------------------------
   241 void MsgConversationView::longPressed(HbAbstractViewItem* viewItem,
   277 void MsgConversationView::longPressed(HbAbstractViewItem* viewItem,
   242     const QPointF& point)
   278     const QPointF& point)
   243 {    
   279 {    
   244     mItemLongPressed = true;
       
   245     
       
   246     MsgConversationViewItem* item = qgraphicsitem_cast<
   280     MsgConversationViewItem* item = qgraphicsitem_cast<
   247             MsgConversationViewItem *> (viewItem);
   281             MsgConversationViewItem *> (viewItem);
   248 
   282 
   249     // Show the item-specific menu
   283     // Show the item-specific menu
   250     if (this->isVisible())
   284     if (this->isVisible())
   264         contextMenu->setPreferredPos(point);
   298         contextMenu->setPreferredPos(point);
   265         setContextMenu(item, contextMenu, sendingState);
   299         setContextMenu(item, contextMenu, sendingState);
   266         contextMenu->show();
   300         contextMenu->show();
   267 
   301 
   268     }
   302     }
   269     else
   303     
   270     {
       
   271         // For cases where the long tap check failed
       
   272         mItemLongPressed = false;
       
   273     }
       
   274 }
   304 }
   275 
   305 
   276 //---------------------------------------------------------------
   306 //---------------------------------------------------------------
   277 // MsgConversationView::setContextMenu
   307 // MsgConversationView::setContextMenu
   278 // @see header
   308 // @see header
   294 // @see header
   324 // @see header
   295 //---------------------------------------------------------------
   325 //---------------------------------------------------------------
   296 void MsgConversationView::addSaveItemToContextMenu(MsgConversationViewItem* item,
   326 void MsgConversationView::addSaveItemToContextMenu(MsgConversationViewItem* item,
   297     HbMenu* contextMenu, int sendingState)
   327     HbMenu* contextMenu, int sendingState)
   298 {
   328 {
       
   329     Q_UNUSED(sendingState)
       
   330 
   299     int messageSubType = item->modelIndex().data(MessageSubType).toInt();
   331     int messageSubType = item->modelIndex().data(MessageSubType).toInt();
   300     int direction =  item->modelIndex().data(Direction).toInt();
   332     int direction =  item->modelIndex().data(Direction).toInt();
   301     if ((messageSubType == ConvergedMessage::RingingTone) && 
   333     if ((messageSubType == ConvergedMessage::RingingTone) && 
   302         (direction == ConvergedMessage::Incoming)) {
   334         (direction == ConvergedMessage::Incoming)) {
   303         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_SAVE);
   335         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_SAVE);
   320         (messageSubType == ConvergedMessage::RingingTone) ||
   352         (messageSubType == ConvergedMessage::RingingTone) ||
   321         (messageType == ConvergedMessage::MmsNotification))
   353         (messageType == ConvergedMessage::MmsNotification))
   322         {
   354         {
   323         return;
   355         return;
   324         }
   356         }
   325     
   357     if ((messageSubType == ConvergedMessage::VCard) &&
       
   358         (direction == ConvergedMessage::Incoming))
       
   359         {
       
   360         HbAction *contextItem = contextMenu->addAction(LOC_SAVE_TO_CONTACTS);
       
   361         connect(contextItem, SIGNAL(triggered()),this, SLOT(openItem()));
       
   362         return;
       
   363         }
   326     if( (sendingState == ConvergedMessage::SentState ) ||
   364     if( (sendingState == ConvergedMessage::SentState ) ||
   327         (sendingState == ConvergedMessage::Resend ) ||
       
   328         (sendingState == ConvergedMessage::Failed ) ||
       
   329         (direction == ConvergedMessage::Incoming))
   365         (direction == ConvergedMessage::Incoming))
   330     {
   366     {
   331         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_OPEN);
   367         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_OPEN);
   332         connect(contextItem, SIGNAL(triggered()),this, SLOT(openItem()));
   368         connect(contextItem, SIGNAL(triggered()),this, SLOT(openItem()));
   333     }
   369     }
   372     {
   408     {
   373         return;
   409         return;
   374     }
   410     }
   375     
   411     
   376     qint32 messageId = item->modelIndex().data(ConvergedMsgId).toInt();
   412     qint32 messageId = item->modelIndex().data(ConvergedMsgId).toInt();
       
   413     qint32 messageProperty = item->modelIndex().data(MessageProperty).toInt();
       
   414     
       
   415     bool canForwardMessage  = true;
       
   416     if (messageType == ConvergedMessage::Mms){
       
   417         canForwardMessage = (messageProperty & EPreviewForward)? true:false;
       
   418     }            
   377 
   419 
   378     if( ((sendingState == ConvergedMessage::SentState) ||
   420     if( ((sendingState == ConvergedMessage::SentState) ||
   379         (sendingState == ConvergedMessage::Resend) ||
   421         (sendingState == ConvergedMessage::Resend) ||
   380         (sendingState == ConvergedMessage::Failed) ||
   422         (sendingState == ConvergedMessage::Failed) ||
   381         (direction == ConvergedMessage::Incoming) ) &&
   423         (direction == ConvergedMessage::Incoming) ) &&
   382         (validateMsgForForward(messageType,messageId))	)
   424         canForwardMessage)
   383     {
   425     {
   384         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_FORWARD);
   426         HbAction *contextItem = contextMenu->addAction(LOC_COMMON_FORWARD);
   385         connect(contextItem, SIGNAL(triggered()),this, SLOT(forwardMessage()));
   427         connect(contextItem, SIGNAL(triggered()),this, SLOT(forwardMessage()));
   386     }
   428     }
   387 
   429 
   460         }
   502         }
   461     }
   503     }
   462     deactivateInputBlocker();
   504     deactivateInputBlocker();
   463     if( sendResult == KErrNotFound)
   505     if( sendResult == KErrNotFound)
   464     {
   506     {
   465     HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, this, SLOT(onDialogSettingsLaunch(HbAction*)), LOC_BUTTON_OK, LOC_BUTTON_CANCEL);
   507     HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, this,
       
   508                            SLOT(onDialogSettingsLaunch(HbAction*)), 
       
   509                            HbMessageBox::Ok | HbMessageBox::Cancel);
   466     }
   510     }
   467 }
   511 }
   468 
   512 
   469 //---------------------------------------------------------------
   513 //---------------------------------------------------------------
   470 // MsgConversationView::contactsFetchedForVCards
   514 // MsgConversationView::contactsFetchedForVCards
   534 // MsgConversationView::fetchImages
   578 // MsgConversationView::fetchImages
   535 // @see header file
   579 // @see header file
   536 //---------------------------------------------------------------
   580 //---------------------------------------------------------------
   537 void MsgConversationView::fetchImages()
   581 void MsgConversationView::fetchImages()
   538 {
   582 {
   539     QString interface("Image");
   583     QString service("photos");
   540     QString operation("fetch(QVariantMap,QVariant)");
   584     QString interface("com.nokia.symbian.IImageFetch");
       
   585     QString operation("fetch()");
   541     XQAiwRequest* request = NULL;
   586     XQAiwRequest* request = NULL;
   542     XQApplicationManager appManager;
   587     XQApplicationManager appManager;
   543     request = appManager.create(interface, operation, true); // embedded
   588     request = appManager.create(service,interface, operation, true); // embedded
   544     request->setSynchronous(true); // synchronous
   589     request->setSynchronous(true); // synchronous
   545     if(!request)
   590     if(!request)
   546     {
   591     {
   547         QDEBUG_WRITE("AIW-ERROR: NULL request");
   592         QDEBUG_WRITE("AIW-ERROR: NULL request");
   548         return;
   593         return;
   551     connect(request, SIGNAL(requestOk(const QVariant&)),
   596     connect(request, SIGNAL(requestOk(const QVariant&)),
   552         this, SLOT(imagesFetched(const QVariant&)));
   597         this, SLOT(imagesFetched(const QVariant&)));
   553     connect(request, SIGNAL(requestError(int,const QString&)),
   598     connect(request, SIGNAL(requestError(int,const QString&)),
   554         this, SLOT(serviceRequestError(int,const QString&)));
   599         this, SLOT(serviceRequestError(int,const QString&)));
   555 
   600 
   556     // Set arguments for request
       
   557     QList<QVariant> args;
       
   558     args << QVariantMap();
       
   559     args << QVariant();
       
   560     request->setArguments(args);
       
   561     // Make the request
   601     // Make the request
   562     if (!request->send())
   602     if (!request->send())
   563     {
   603     {
   564         QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError());
   604         QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError());
   565     }  
   605     }  
   570 // MsgConversationView::fetchAudio
   610 // MsgConversationView::fetchAudio
   571 // @see header file
   611 // @see header file
   572 //---------------------------------------------------------------
   612 //---------------------------------------------------------------
   573 void MsgConversationView::fetchAudio()
   613 void MsgConversationView::fetchAudio()
   574 {
   614 {
   575     QString service("musicplayer");
   615     // Launch Audio fetcher view
   576     QString interface("com.nokia.symbian.IMusicFetch");
   616     QVariantList params;
   577     QString operation("fetch()");
   617     QByteArray dataArray;
   578     XQAiwRequest* request = NULL;
   618     QDataStream messageStream
   579     XQApplicationManager appManager;
   619     (&dataArray, QIODevice::WriteOnly | QIODevice::Append);
   580     request = appManager.create(service, interface, operation, true); //embedded
   620 
   581     request->setSynchronous(true); // synchronous
   621     ConvergedMessage message;
   582     if(!request)
   622     message.setBodyText(mEditorWidget->content());
   583     {
   623     // add address from contact-card to to-field
   584         QDEBUG_WRITE("AIW-ERROR: NULL request");
   624     ConvergedMessageAddress address;
   585         return;
   625     address.setAlias(mContactCardWidget->address().at(0)->alias());
   586     }
   626     address.setAddress(mContactCardWidget->address().at(0)->address());
   587 
   627     message.addToRecipient(address);
   588     connect(request, SIGNAL(requestOk(const QVariant&)),
   628     message.serialize(messageStream);
   589         this, SLOT(audiosFetched(const QVariant&)));
   629 
   590     connect(request, SIGNAL(requestError(int,const QString&)),
   630     params << MsgBaseView::AUDIOFETCHER; // target view
   591         this, SLOT(serviceRequestError(int,const QString&)));
   631     params << MsgBaseView::CV; // source view
   592 
   632     params << dataArray;
   593     // Make the request
   633     emit switchView(params);
   594     if (!request->send())
       
   595     {
       
   596         QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed  ",request->lastError());
       
   597     }
       
   598     delete request;
       
   599 }
   634 }
   600 
   635 
   601 //---------------------------------------------------------------
   636 //---------------------------------------------------------------
   602 // MsgConversationView::contactsFetched
   637 // MsgConversationView::contactsFetched
   603 // @see header file
   638 // @see header file
   628         if ( fileList.size()>0 )
   663         if ( fileList.size()>0 )
   629         {
   664         {
   630             QString filepath(QDir::toNativeSeparators(fileList.at(0)));
   665             QString filepath(QDir::toNativeSeparators(fileList.at(0)));
   631             QVariantList params;
   666             QVariantList params;
   632             params << MsgBaseView::ADD_PHOTO;
   667             params << MsgBaseView::ADD_PHOTO;
   633             params << filepath;
       
   634             launchUniEditor(params);
       
   635         }
       
   636     }
       
   637 }
       
   638 
       
   639 //---------------------------------------------------------------
       
   640 // MsgConversationView::audiosFetched()
       
   641 // @see header file
       
   642 //---------------------------------------------------------------
       
   643 void MsgConversationView::audiosFetched(const QVariant& result )
       
   644 {
       
   645     if(result.canConvert<QStringList>())
       
   646     {
       
   647         QStringList fileList = result.value<QStringList>();
       
   648         if ( fileList.size()>0 && !fileList.at(0).isEmpty())
       
   649         {
       
   650             QString filepath(QDir::toNativeSeparators(fileList.at(0)));
       
   651             QVariantList params;
       
   652             params << MsgBaseView::ADD_AUDIO;
       
   653             params << filepath;
   668             params << filepath;
   654             launchUniEditor(params);
   669             launchUniEditor(params);
   655         }
   670         }
   656     }
   671     }
   657 }
   672 }
   736 // Deletes the message
   751 // Deletes the message
   737 //---------------------------------------------------------------
   752 //---------------------------------------------------------------
   738 void MsgConversationView::deleteItem()
   753 void MsgConversationView::deleteItem()
   739     {
   754     {
   740     HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogdeleteMsg(HbAction*)),
   755     HbMessageBox::question(LOC_DELETE_MESSAGE,this,SLOT(onDialogdeleteMsg(HbAction*)),
   741                              LOC_BUTTON_DELETE,
   756                            HbMessageBox::Delete | HbMessageBox::Cancel);
   742                              LOC_BUTTON_CANCEL);
       
   743 }
   757 }
   744 
   758 
   745 //---------------------------------------------------------------
   759 //---------------------------------------------------------------
   746 // MsgConversationView::openItem()
   760 // MsgConversationView::openItem()
   747 // Opens the message
   761 // Opens the message
   765 
   779 
   766 //---------------------------------------------------------------
   780 //---------------------------------------------------------------
   767 // MsgConversationView::saveContentToDrafts()
   781 // MsgConversationView::saveContentToDrafts()
   768 // @See header
   782 // @See header
   769 //---------------------------------------------------------------
   783 //---------------------------------------------------------------
   770 bool MsgConversationView::saveContentToDrafts()
   784 int MsgConversationView::saveContentToDrafts()
   771 {
   785 {
   772     int msgId = INVALID_MSGID;
   786     int msgId = INVALID_MSGID;
   773     if(!mEditorWidget->content().isEmpty())
   787     if(!mEditorWidget->content().isEmpty())
   774     {
   788     {
   775         activateInputBlocker();
   789         activateInputBlocker();
   788                      
   802                      
   789             mEditorWidget->clear();
   803             mEditorWidget->clear();
   790         }
   804         }
   791         deactivateInputBlocker();
   805         deactivateInputBlocker();
   792     }
   806     }
   793     return ((msgId > INVALID_MSGID)? true : false);
   807     return msgId;
   794 }
   808 }
   795 
   809 
   796 //---------------------------------------------------------------
   810 //---------------------------------------------------------------
   797 //MsgConversationView::populateForSending()
   811 //MsgConversationView::populateForSending()
   798 //@see header
   812 //@see header
   812 //---------------------------------------------------------------
   826 //---------------------------------------------------------------
   813 void MsgConversationView::launchBtDisplayService(const QModelIndex & index)
   827 void MsgConversationView::launchBtDisplayService(const QModelIndex & index)
   814 {
   828 {
   815     qint32 messageId = index.data(ConvergedMsgId).toLongLong();
   829     qint32 messageId = index.data(ConvergedMsgId).toLongLong();
   816 
   830 
   817     QString interface("com.nokia.services.btmsgdispservices.displaymsg");
   831     QList<QVariant> args;
       
   832     QString serviceName("com.nokia.services.btmsgdispservices");
   818     QString operation("displaymsg(int)");
   833     QString operation("displaymsg(int)");
   819 
   834     XQAiwRequest* request;
   820     XQServiceRequest request(interface, operation, false);
   835     XQApplicationManager appManager;
   821 
   836     request = appManager.create(serviceName, "displaymsg", operation, false); // embedded
   822     request << messageId;
   837     
   823 
   838     if ( request == NULL )
   824     bool result = request.send();
   839         {
       
   840         return;
       
   841         }
       
   842 
       
   843     args << QVariant(messageId);
       
   844     request->setSynchronous(true);
       
   845     
       
   846     request->setArguments(args);
       
   847     request->send();
       
   848     delete request;    
   825 }
   849 }
   826 
   850 
   827 //---------------------------------------------------------------
   851 //---------------------------------------------------------------
   828 // MsgConversationView::menuAboutToShow()
   852 // MsgConversationView::menuAboutToShow()
   829 // @See header
   853 // @See header
   859 //---------------------------------------------------------------
   883 //---------------------------------------------------------------
   860 //MsgConversationView::openItem
   884 //MsgConversationView::openItem
   861 //@see header
   885 //@see header
   862 //---------------------------------------------------------------
   886 //---------------------------------------------------------------
   863 void MsgConversationView::openItem(const QModelIndex & index)
   887 void MsgConversationView::openItem(const QModelIndex & index)
   864     {
   888 {
   865     // Return if invalid index.
   889     // Return if invalid index.
   866     if (!index.isValid() || mVkbopened)
   890     if (!index.isValid() || mVkbopened)
   867         {
   891     {
   868         return;
   892         return;
   869         }
   893     }
   870 
       
   871     if(mItemLongPressed)
       
   872         {
       
   873         //reset the flag
       
   874         mItemLongPressed = false;
       
   875         return;
       
   876         }
       
   877     
   894     
   878     int messageType = index.data(MessageType).toInt();
   895     int messageType = index.data(MessageType).toInt();
   879     int messageSubType = index.data(MessageSubType).toInt();
   896     int messageSubType = index.data(MessageSubType).toInt();
   880     
   897     int messageId = index.data(ConvergedMsgId).toInt();
   881     if (ConvergedMessage::BioMsg == messageType) {
   898     
   882         if (ConvergedMessage::RingingTone == messageSubType) {
   899     if (ConvergedMessage::BioMsg == messageType)
       
   900     {
       
   901         if (ConvergedMessage::RingingTone == messageSubType)
       
   902         {
   883             HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this,
   903             HbMessageBox::question(LOC_DIALOG_SAVE_RINGTONE, this,
   884                     SLOT(onDialogSaveTone(HbAction*)), LOC_COMMON_SAVE, LOC_BUTTON_CANCEL);
   904                                    SLOT(onDialogSaveTone(HbAction*)), 
       
   905                                    HbMessageBox::Save | HbMessageBox::Cancel);
   885             return;
   906             return;
   886         }
   907         }
   887         else if(ConvergedMessage::Provisioning == messageSubType)
   908         else if(ConvergedMessage::Provisioning == messageSubType)
   888             {
   909         {
   889             int messageId = index.data(ConvergedMsgId).toInt();
   910             int messageId = index.data(ConvergedMsgId).toInt();
   890             handleProvisoningMsg(messageId);
   911             handleProvisoningMsg(messageId);
   891             QList<int> msgIdList;
   912             QList<int> msgIdList;
   892             if(index.data(UnReadStatus).toInt())
   913             if(index.data(UnReadStatus).toInt())
   893                 {
   914             {
   894                 msgIdList.clear();
   915                 msgIdList.clear();
   895                 msgIdList << messageId;
   916                 msgIdList << messageId;
   896                 ConversationsEngine::instance()->markMessagesRead(msgIdList);
   917                 ConversationsEngine::instance()->markMessagesRead(msgIdList);
       
   918             }
       
   919             return;
       
   920         }
       
   921         else if(ConvergedMessage::VCard == messageSubType)
       
   922         {
       
   923             QString filepath = index.data(Attachments).toStringList().at(0);
       
   924             bool result = MsgContactsUtil::launchVCardViewer(filepath);
       
   925             if(result)
       
   926             {
       
   927                 
       
   928                 int messageId = index.data(ConvergedMsgId).toInt();
       
   929                 QList<int> msgIdList;
       
   930                 if(index.data(UnReadStatus).toInt())
       
   931                 {
       
   932                     msgIdList.clear();
       
   933                     msgIdList << messageId;
       
   934                     ConversationsEngine::instance()->markMessagesRead(msgIdList);
   897                 }
   935                 }
       
   936             }
   898             return;
   937             return;
       
   938         }
       
   939         else if(ConvergedMessage::VCal == messageSubType)
       
   940         {
       
   941             return;
       
   942         }
       
   943     }
       
   944     else if (ConvergedMessage::BT == messageType)
       
   945     {
       
   946         launchBtDisplayService(index);
       
   947         QList<int> msgIdList;
       
   948         if(index.data(UnReadStatus).toInt())
       
   949             {
       
   950             msgIdList.clear();
       
   951             msgIdList << messageId;
       
   952             ConversationsEngine::instance()->markMessagesRead(msgIdList);
   899             }
   953             }
   900         // Unsupported messages
       
   901         else if (ConvergedMessage::VCard == messageSubType
       
   902             || ConvergedMessage::VCal == messageSubType) {
       
   903             return;
       
   904         }
       
   905     }
       
   906     else if (ConvergedMessage::BT == messageType) {
       
   907         launchBtDisplayService(index);
       
   908         return;
   954         return;
   909     }
   955     }
   910     else if(ConvergedMessage::MmsNotification == messageType)
   956     else if(ConvergedMessage::MmsNotification == messageType)
   911     {
   957     {
   912         qint32 messageId = index.data(ConvergedMsgId).toLongLong();    
   958         qint32 messageId = index.data(ConvergedMsgId).toLongLong();    
   920            return;
   966            return;
   921         }
   967         }
   922         else
   968         else
   923         {
   969         {
   924             //TODO: use logical str name
   970             //TODO: use logical str name
   925             HbMessageBox::question("Download Message?",this,SLOT(onDialogDownLoadMsg(HbAction*)),
   971             HbMessageBox::question("Download Message?",this,
   926                 LOC_COMMON_DOWNLOAD,
   972                                    SLOT(onDialogDownLoadMsg(HbAction*)),
   927                 LOC_BUTTON_CANCEL);
   973                                    HbMessageBox::Yes | HbMessageBox::Cancel);
   928             return;
   974             return;
   929         }
   975         }
   930     }
   976     }
   931 
   977 
   932     ConvergedMessage message;
   978     int direction = index.data(Direction).toInt();
       
   979 
       
   980     if (direction == ConvergedMessage::Outgoing && ConvergedMessage::Sms == messageType
       
   981         && ConversationsEngine::instance()->getMsgSubType(messageId)== ConvergedMessage::NokiaService)
       
   982     {
       
   983         return;
       
   984     }
       
   985     
   933     // check whether message is in sending progress, then donot launch viewer.
   986     // check whether message is in sending progress, then donot launch viewer.
   934     int location = index.data(MessageLocation).toInt();
   987     int location = index.data(MessageLocation).toInt();
   935     int sendingState = index.data(SendingState).toInt();
   988     int sendingState = index.data(SendingState).toInt();
   936     
   989     
   937     //If message is in Sending state or is Scheduled to be sent later,
   990     //If message is in any other state other than 'Sent'
   938     //do not open the message
   991     //do not open the message
   939     if(sendingState == ConvergedMessage::Suspended ||
   992     if(direction == ConvergedMessage::Outgoing 
   940             sendingState == ConvergedMessage::Scheduled ||
   993             && sendingState != ConvergedMessage::SentState )
   941             sendingState == ConvergedMessage::Sending ||
   994            
   942             sendingState == ConvergedMessage::Waiting)
       
   943     {
   995     {
   944         return;
   996         return;
   945     }
   997     }
   946 
   998 
   947     //TODO: sendingState check should be removed once msg
   999    
   948     // movement lock issue is resolved from mw
  1000     
   949     if( !((location == ConvergedMessage::Inbox) ||
  1001     // contact Id
   950         (location == ConvergedMessage::Sent) ||
  1002     qint32 contactId = index.data(ContactId).toLongLong();  
   951         (sendingState == ConvergedMessage::SentState)||
  1003 	    
   952         (sendingState == ConvergedMessage::Failed) ||
  1004     //if message unread, mark as read before opening view
   953         (sendingState == ConvergedMessage::Resend)))
  1005     QList<int> msgIdList;
   954         {// do not launch viewer, show a note
  1006     if(index.data(UnReadStatus).toInt())
   955         HbNotificationDialog* dlg = new HbNotificationDialog();
  1007     {
   956         dlg->setFocusPolicy(Qt::NoFocus);
       
   957         QString text(tr("Message Locked"));
       
   958         dlg->setText(text);
       
   959         dlg->setDismissPolicy(HbPopup::TapAnywhere);
       
   960         dlg->setAttribute(Qt::WA_DeleteOnClose, true);
       
   961         dlg->show();
       
   962         return;
       
   963 		}
       
   964 
       
   965         // message id
       
   966         qint32 messageId = index.data(ConvergedMsgId).toLongLong();
       
   967         ConvergedMessageId msgId(messageId);
       
   968         message.setMessageId(msgId);
       
   969 
       
   970         // contact Id
       
   971         qint32 contactId = index.data(ContactId).toLongLong();
       
   972 
       
   973         // message type
       
   974 
       
   975         message.setMessageType((ConvergedMessage::MessageType) messageType);
       
   976         message.setMessageSubType((ConvergedMessage::MessageSubType) messageSubType);
       
   977 
       
   978         if (messageType == ConvergedMessage::Mms)
       
   979         {
       
   980             message.setSubject(index.data(Subject).toString());
       
   981             message.setPriority((ConvergedMessage::Priority) index.data(
       
   982                 MessagePriority).toInt());
       
   983         }
       
   984         else if (messageType == ConvergedMessage::IM)
       
   985         {
       
   986             // add body text and send to the message for IM case
       
   987             message.setBodyText(index.data(BodyText).toString());
       
   988         }
       
   989 
       
   990         // time stamp
       
   991         message.setTimeStamp(index.data(TimeStamp).toLongLong());
       
   992 
       
   993         //Message direction
       
   994         message.setDirection((ConvergedMessage::Direction)index.data(Direction).toInt());
       
   995 
       
   996         // conatct name as address
       
   997         ConvergedMessageAddress address;
       
   998         address.setAlias(mContactCardWidget->address().at(0)->alias());
       
   999         address.setAddress(mContactCardWidget->address().at(0)->address());
       
  1000         message.addToRecipient(address);
       
  1001 
       
  1002         // Mark this message as read if its unread
       
  1003         QByteArray dataArray;
       
  1004         QDataStream messageStream
       
  1005         (&dataArray, QIODevice::WriteOnly | QIODevice::Append);
       
  1006         message.serialize(messageStream);
       
  1007         //if message unread, mark as read before opening view
       
  1008         QList<int> msgIdList;
       
  1009         if(index.data(UnReadStatus).toInt())
       
  1010             {
       
  1011         msgIdList.clear();
  1008         msgIdList.clear();
  1012         msgIdList << messageId;
  1009         msgIdList << messageId;
  1013         ConversationsEngine::instance()->markMessagesRead(msgIdList);
  1010         ConversationsEngine::instance()->markMessagesRead(msgIdList);
  1014         }
  1011     }
  1015 
  1012     
  1016         //switch view
  1013     qint32 messageProperty = index.data(MessageProperty).toInt();
  1017         QVariantList param;
  1014 
  1018         param << MsgBaseView::UNIVIEWER;  // target view
  1015     bool canForwardMessage  = true;
  1019         param << MsgBaseView::CV; // source view
  1016     if (messageType == ConvergedMessage::Mms){
  1020 
  1017         canForwardMessage = (messageProperty & EPreviewForward)? true:false;
  1021         param << contactId;
  1018     } 
  1022         param << dataArray;
  1019     
  1023         param << mMessageModel->rowCount();
  1020     //switch view
  1024 
  1021     QVariantList param;
  1025         emit switchView(param);
  1022     param << MsgBaseView::UNIVIEWER;  // target view
       
  1023     param << MsgBaseView::CV; // source view
       
  1024 
       
  1025     param << contactId;
       
  1026     param << messageId;
       
  1027     param << mMessageModel->rowCount();
       
  1028     if (canForwardMessage == true)
       
  1029     {
       
  1030       param << 1;
       
  1031     }
       
  1032     else
       
  1033    	{
       
  1034    		param << 0;
       
  1035    	}
       
  1036     emit switchView(param);
  1026 }
  1037 }
  1027 
  1038 
  1028 //---------------------------------------------------------------
  1039 //---------------------------------------------------------------
  1029 // MsgConversationView::launchUniEditor
  1040 // MsgConversationView::launchUniEditor
  1030 // @see header file
  1041 // @see header file
  1082             // now add fetched contacts from contact selection dialog
  1093             // now add fetched contacts from contact selection dialog
  1083             for(int i = 0; i < contactList.count(); i++ )
  1094             for(int i = 0; i < contactList.count(); i++ )
  1084             {
  1095             {
  1085                 ConvergedMessageAddress* address = new ConvergedMessageAddress;
  1096                 ConvergedMessageAddress* address = new ConvergedMessageAddress;
  1086                 address->setAlias(contactList[i].mDisplayName);
  1097                 address->setAlias(contactList[i].mDisplayName);
  1087                 address->setAddress(contactList[i].mPhoneNumber);
  1098                 if(!contactList[i].mPhoneNumber.isEmpty())
       
  1099                 {
       
  1100                     address->setAddress(contactList[i].mPhoneNumber);
       
  1101                 }
       
  1102                 else
       
  1103                 {
       
  1104                     address->setAddress(contactList[i].mEmailAddress);
       
  1105                 }
  1088                 addresses.append(address);
  1106                 addresses.append(address);
  1089             }
  1107             }
  1090             message.addToRecipients(addresses);
  1108             message.addToRecipients(addresses);
  1091         }
  1109         }
  1092     }
  1110     }
  1114 //---------------------------------------------------------------
  1132 //---------------------------------------------------------------
  1115 // MsgConversationView::populateConversationsView
  1133 // MsgConversationView::populateConversationsView
  1116 // @see header file
  1134 // @see header file
  1117 //---------------------------------------------------------------
  1135 //---------------------------------------------------------------
  1118 void MsgConversationView::populateConversationsView()
  1136 void MsgConversationView::populateConversationsView()
  1119 {
  1137 {    
  1120     bool b = connect(ConversationsEngine::instance(), 
  1138     mModelPopulated = true;
  1121                      SIGNAL(conversationModelUpdated()),
       
  1122                      this, 
       
  1123                      SLOT(scrollToBottom()));
       
  1124 
       
  1125     mConversationList->setModel(mMessageModel);
  1139     mConversationList->setModel(mMessageModel);
  1126     
  1140     
  1127     refreshView();
  1141     refreshView();
  1128     scrollToBottom();
  1142     scrollToBottom();
       
  1143     fetchMoreConversations();
  1129 }
  1144 }
  1130 
  1145 
  1131 //---------------------------------------------------------------
  1146 //---------------------------------------------------------------
  1132 // MsgConversationView::saveRingingTone
  1147 // MsgConversationView::saveRingingTone
  1133 // @see header file
  1148 // @see header file
  1172     params << MsgBaseView::ADD_OTHERS;
  1187     params << MsgBaseView::ADD_OTHERS;
  1173     launchUniEditor(params);   
  1188     launchUniEditor(params);   
  1174 }
  1189 }
  1175 
  1190 
  1176 //---------------------------------------------------------------
  1191 //---------------------------------------------------------------
  1177 // MsgConversationView::validateMsgForForward
       
  1178 // @see header file
       
  1179 //---------------------------------------------------------------
       
  1180 bool MsgConversationView::validateMsgForForward(int &messageType,
       
  1181     qint32 &messageId)
       
  1182 {
       
  1183     bool retValue = true;
       
  1184     if (messageType == ConvergedMessage::Mms)
       
  1185     {
       
  1186         //Validate if the mms msg can be forwarded or not
       
  1187         MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck;
       
  1188         retValue = mmsConformanceCheck->validateMsgForForward(messageId);
       
  1189         
       
  1190         delete mmsConformanceCheck;
       
  1191     }
       
  1192 
       
  1193     return retValue;
       
  1194 }
       
  1195 
       
  1196 //---------------------------------------------------------------
       
  1197 // MsgConversationView::vkbOpened
  1192 // MsgConversationView::vkbOpened
  1198 // @see header file
  1193 // @see header file
  1199 //---------------------------------------------------------------
  1194 //---------------------------------------------------------------
  1200 void MsgConversationView::vkbOpened()
  1195 void MsgConversationView::vkbOpened()
  1201 {
  1196 {
  1202     mVkbopened = true;
  1197     mVkbopened = true;
  1203     
  1198     
  1204     mContactCardWidget->connectSignals(false);
  1199     emit vkbOpened(true);
  1205     
       
  1206     emit hideChrome(true);
       
  1207     
  1200     
  1208     QRectF appRect = mVkbHost->applicationArea();    
  1201     QRectF appRect = mVkbHost->applicationArea();    
  1209     qreal spacing = 0.0;
  1202     qreal spacing = 0.0;
  1210     qreal cardHeight = 0.0;
  1203     qreal cardHeight = 0.0;
  1211     if(mContactCardWidget->isVisible())
  1204     if(mContactCardWidget->isVisible())
  1227 //---------------------------------------------------------------
  1220 //---------------------------------------------------------------
  1228 void MsgConversationView::vkbClosed()
  1221 void MsgConversationView::vkbClosed()
  1229 {
  1222 {
  1230     mVkbopened = false;
  1223     mVkbopened = false;
  1231     
  1224     
  1232     mContactCardWidget->connectSignals(true);
  1225     emit vkbOpened(false);
  1233     
       
  1234     emit hideChrome(false);
       
  1235     
  1226     
  1236     this->setMaximumHeight(-1);
  1227     this->setMaximumHeight(-1);
  1237     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1228     connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened()));
  1238     
  1229     
  1239     scrollToBottom();
  1230     scrollToBottom();
  1249 }
  1240 }
  1250 
  1241 
  1251 //---------------------------------------------------------------
  1242 //---------------------------------------------------------------
  1252 // MsgConversationView::activateInputBlocker
  1243 // MsgConversationView::activateInputBlocker
  1253 // @see header file
  1244 // @see header file
  1254 //--------------------------------------------------------------
  1245 //---------------------------------------------------------------
  1255 void MsgConversationView::activateInputBlocker()
  1246 void MsgConversationView::activateInputBlocker()
  1256     {
  1247 {
  1257         this->grabMouse();
  1248     mainWindow()->setInteractive(false);
  1258         this->grabKeyboard();
  1249 }
  1259     }
       
  1260 
  1250 
  1261 //---------------------------------------------------------------
  1251 //---------------------------------------------------------------
  1262 // MsgConversationView::deactivateInputBlocker
  1252 // MsgConversationView::deactivateInputBlocker
  1263 // @see header file
  1253 // @see header file
  1264 //--------------------------------------------------------------
  1254 //---------------------------------------------------------------
  1265 void MsgConversationView::deactivateInputBlocker()
  1255 void MsgConversationView::deactivateInputBlocker()
  1266     {    
  1256 {
  1267         this->ungrabKeyboard();
  1257     mainWindow()->setInteractive(true);
  1268         this->ungrabMouse();
  1258 }
  1269     }
       
  1270 
  1259 
  1271 //---------------------------------------------------------------
  1260 //---------------------------------------------------------------
  1272 // MsgConversationView::handleProvisoningMsg
  1261 // MsgConversationView::handleProvisoningMsg
  1273 // @see header file
  1262 // @see header file
  1274 //--------------------------------------------------------------
  1263 //---------------------------------------------------------------
  1275 void MsgConversationView::handleProvisoningMsg(int msgId)
  1264 void MsgConversationView::handleProvisoningMsg(int msgId)
  1276 	{
  1265 	{
  1277 		QString messageId;
  1266 		QString messageId;
  1278     messageId.setNum(msgId);
  1267     messageId.setNum(msgId);
  1279 
  1268 
  1299 	}
  1288 	}
  1300 
  1289 
  1301 //---------------------------------------------------------------
  1290 //---------------------------------------------------------------
  1302 // MsgConversationView::onDialogSettingsLaunch
  1291 // MsgConversationView::onDialogSettingsLaunch
  1303 // @see header file
  1292 // @see header file
  1304 //--------------------------------------------------------------
  1293 //---------------------------------------------------------------
  1305 void MsgConversationView::onDialogSettingsLaunch(HbAction* action)
  1294 void MsgConversationView::onDialogSettingsLaunch(HbAction* action)
  1306 {
  1295 {
  1307     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
  1296     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
  1308     if (action == dlg->actions().at(0)) {
  1297     if (action == dlg->actions().at(0)) {
  1309         //switch to settings view
  1298         //switch to settings view
  1317 }
  1306 }
  1318 
  1307 
  1319 //---------------------------------------------------------------
  1308 //---------------------------------------------------------------
  1320 // MsgConversationView::onDialogdeleteMsg
  1309 // MsgConversationView::onDialogdeleteMsg
  1321 // @see header file
  1310 // @see header file
  1322 //--------------------------------------------------------------
  1311 //---------------------------------------------------------------
  1323 void MsgConversationView::onDialogdeleteMsg(HbAction* action)
  1312 void MsgConversationView::onDialogdeleteMsg(HbAction* action)
  1324 {
  1313 {
  1325     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
  1314     HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender());
  1326     if (action == dlg->actions().at(0)) {
  1315     if (action == dlg->actions().at(0)) {
  1327         QModelIndex index = mConversationList->currentIndex();
  1316         QModelIndex index = mConversationList->currentIndex();
  1369     if (action == dlg->actions().at(0)) {
  1358     if (action == dlg->actions().at(0)) {
  1370         saveRingingTone();
  1359         saveRingingTone();
  1371     }
  1360     }
  1372 }
  1361 }
  1373 
  1362 
       
  1363 //---------------------------------------------------------------
       
  1364 // MsgConversationView::onOrientationChanged
       
  1365 // @see header file
       
  1366 //---------------------------------------------------------------
       
  1367 void MsgConversationView::onOrientationChanged(Qt::Orientation newOrientation)
       
  1368 {
       
  1369     Q_UNUSED(newOrientation)
       
  1370 
       
  1371     // On orientation change always make the preserved index(last visible item) to be visible
       
  1372     if(mVisibleIndex.isValid())
       
  1373     {
       
  1374     mConversationList->scrollTo(mVisibleIndex, HbAbstractItemView::PositionAtBottom);
       
  1375     mVisibleIndex = QModelIndex();
       
  1376     }
       
  1377 }
       
  1378 
       
  1379 //---------------------------------------------------------------
       
  1380 // MsgConversationView::onOrientationAboutToBeChanged
       
  1381 // @see header file
       
  1382 //---------------------------------------------------------------
       
  1383 void MsgConversationView::onOrientationAboutToBeChanged()
       
  1384 {
       
  1385     // Preserve the model index of the last visible item to be scrolled on orientation change
       
  1386     QList<HbAbstractViewItem *>items = mConversationList->visibleItems();
       
  1387     if (items.count() > 0) {
       
  1388         mVisibleIndex = items.last()->modelIndex();
       
  1389     }
       
  1390 }
       
  1391 
       
  1392 //---------------------------------------------------------------
       
  1393 // MsgConversationView::onViewReady
       
  1394 // @see header file
       
  1395 //---------------------------------------------------------------
       
  1396 void MsgConversationView::onViewReady()
       
  1397 {
       
  1398     mViewReady = true;
       
  1399     //Disconnect list View's signals, for avoiding execution of the default implementaion
       
  1400     disconnect(mainWindow(), SIGNAL(aboutToChangeOrientation()), mConversationList, 0);
       
  1401     disconnect(mainWindow(), SIGNAL(orientationChanged(Qt: rientation)), mConversationList, 0);
       
  1402     
       
  1403    fetchMoreConversations();
       
  1404 }
  1374 // EOF
  1405 // EOF