messagingapp/msgservices/msgserviceapp/src/msgserviceviewmanager.cpp
changeset 73 ecf6a73a9186
parent 67 fc91263aee62
child 76 60a8a215b0ec
equal deleted inserted replaced
68:e8a69c93c830 73:ecf6a73a9186
    28 #include <HbDeviceMessageBox>
    28 #include <HbDeviceMessageBox>
    29 #include <HbSplashScreen>
    29 #include <HbSplashScreen>
    30 
    30 
    31 #include <xqserviceutil.h>
    31 #include <xqserviceutil.h>
    32 #include <xqappmgr.h>
    32 #include <xqappmgr.h>
       
    33 #include <xqaiwdecl.h>
    33 
    34 
    34 #include "msgunieditorview.h"
    35 #include "msgunieditorview.h"
    35 #include "unifiedviewer.h"
    36 #include "unifiedviewer.h"
    36 #include "msgstorehandler.h"
    37 #include "msgstorehandler.h"
    37 #include "msgsettingsview.h"
    38 #include "msgsettingsview.h"
    38 #include "convergedmessageid.h"
    39 #include "convergedmessageid.h"
    39 #include "ringbc.h"
    40 #include "ringbc.h"
    40 #include "unidatamodelloader.h"
    41 #include "unidatamodelloader.h"
    41 #include "unidatamodelplugininterface.h"
    42 #include "unidatamodelplugininterface.h"
    42 #include "msgcontacthandler.h"
       
    43 
    43 
    44 // CONSTANTS
    44 // CONSTANTS
    45 static const char SEND_EFFECT[] = "sendeffect";
    45 static const char SEND_EFFECT[] = "sendeffect";
    46 static const char SEND_EFFECT_FILE[] = ":/effects/sendeffect.fxml";
    46 static const char SEND_EFFECT_FILE[] = ":/effects/sendeffect.fxml";
    47 
    47 
    48 // LOCALIZATION
    48 // LOCALIZATION
    49 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message")
    49 #define LOC_DELETED_MESSAGE hbTrId("txt_messages_dialog_message_has_been_deleted")
    50 // TODO: LOC
    50 #define LOC_CANNOT_OPEN_MESSAGE hbTrId("txt_messages_dialog_message_is_outgoingcannot_be")
    51 #define LOC_DELETED_MESSAGE "Message is deleted"
    51 #define LOC_UNKNOWN_MSG_TYPE hbTrId("txt_messages_dialog_unsupported_message_type")
    52 #define LOC_CANNOT_OPEN_MESSAGE "Message in outbox. Cannot be opened"
    52 #define LOC_SAVE_RINGTONE hbTrId("txt_conversations_dialog_save_ringing_tone")
    53 #define LOC_UNKNOWN_MSG_TYPE "Unknown Message Type"
       
    54 
    53 
    55 //----------------------------------------------------------------------------
    54 //----------------------------------------------------------------------------
    56 // MsgViewInterface::MsgViewInterface
    55 // MsgViewInterface::MsgViewInterface
    57 // @see header
    56 // @see header
    58 //----------------------------------------------------------------------------
    57 //----------------------------------------------------------------------------
   463     }
   462     }
   464     return eventHandled;
   463     return eventHandled;
   465 }
   464 }
   466 
   465 
   467 // ----------------------------------------------------------------------------
   466 // ----------------------------------------------------------------------------
       
   467 // MsgServiceViewManager::saveContentToDraft
       
   468 // @see header
       
   469 // ----------------------------------------------------------------------------
       
   470 void MsgServiceViewManager::saveContentToDraft()
       
   471 {
       
   472     if(mUniEditor)
       
   473     {
       
   474       mUniEditor->saveContentToDrafts();
       
   475     }
       
   476 }
       
   477 
       
   478 // ----------------------------------------------------------------------------
   468 // MsgServiceViewManager::handleDraftMsg
   479 // MsgServiceViewManager::handleDraftMsg
   469 // @see header
   480 // @see header
   470 // ----------------------------------------------------------------------------
   481 // ----------------------------------------------------------------------------
   471 void MsgServiceViewManager::handleDraftMsg(int msgId, int msgType)
   482 void MsgServiceViewManager::handleDraftMsg(int msgId, int msgType)
   472 {
   483 {
   473     // show the splash-screen
   484     // show the splash-screen
   474     // TODO: This causes cancellation of view switching effects
   485     // Note: This causes cancellation of view switching effects
   475 //    HbSplashScreen::start();
   486 //    HbSplashScreen::start();
   476     connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
   487     connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
   477     mCurrentView = MsgBaseView::UNIEDITOR;
   488     mCurrentView = MsgBaseView::UNIEDITOR;
   478 
   489 
   479     // construct editor instance (keep it minimal)
   490     // construct editor instance (keep it minimal)
   527     {
   538     {
   528         delete attachmentInfo;
   539         delete attachmentInfo;
   529     }
   540     }
   530     delete pluginLoader;
   541     delete pluginLoader;
   531 
   542 
   532     // Get vCard display name
       
   533     QString displayName = MsgContactHandler::getVCardDisplayName(filepath);
       
   534     // TODO: use displayname to create a localized string to show in dialog
       
   535     QString loc_str = QString("Save to contacts: ").append(displayName);
       
   536     bool viewVCard = HbDeviceMessageBox::question(loc_str,
       
   537                          HbMessageBox::Ok|HbMessageBox::Cancel);
       
   538     if(!viewVCard)
       
   539     {
       
   540         HbApplication::quit();
       
   541         return;
       
   542     }
       
   543 
       
   544     // copy private-vCard file to public location for contacts access
   543     // copy private-vCard file to public location for contacts access
   545     QDir tempDir;
   544     QDir tempDir;
   546     QString sharedFilePath(QDir::toNativeSeparators(tempDir.tempPath()));
   545     QString sharedFilePath(QDir::toNativeSeparators(tempDir.tempPath()));
   547     sharedFilePath.append(QDir::separator());
   546     sharedFilePath.append(QDir::separator());
   548     QFileInfo fInfo(filepath);
   547     QFileInfo fInfo(filepath);
   549     sharedFilePath.append(fInfo.fileName());
   548     sharedFilePath.append(fInfo.fileName());
   550     QFile::copy(filepath, sharedFilePath);
   549     QFile::copy(filepath, sharedFilePath);
   551 
   550 
   552     // Launch vCard viewer service
   551     // Launch vCard viewer service
   553     QString service("phonebookservices");
       
   554     QString interface("com.nokia.symbian.IContactsEdit");
       
   555     QString operation("editCreateNewFromVCard(QString)");
       
   556     XQApplicationManager appManager;
   552     XQApplicationManager appManager;
   557     // embedded launch
   553     XQAiwRequest* request = appManager.create(XQI_CONTACTS_EDIT,
   558     XQAiwRequest* request = 
   554                                 XQOP_CONTACTS_EDIT_CREATE_NEW_VCARD, 
   559             appManager.create(service, interface, operation, true);
   555                                 true); //embedded
   560     if(request)
   556     if(request)
   561     {
   557     {
   562         QList<QVariant> args;
   558         QList<QVariant> args;
   563         args << sharedFilePath;
   559         args << sharedFilePath;
   564         request->setArguments(args);
   560         request->setArguments(args);
   577 // @see header
   573 // @see header
   578 // ----------------------------------------------------------------------------
   574 // ----------------------------------------------------------------------------
   579 void MsgServiceViewManager::handleSmsMmsMsg(int msgId)
   575 void MsgServiceViewManager::handleSmsMmsMsg(int msgId)
   580 {
   576 {
   581     // show the splash-screen
   577     // show the splash-screen
   582     // TODO: This causes cancellation of view switching effects
   578     // Note: This causes cancellation of view switching effects
   583 //    HbSplashScreen::start();
   579 //    HbSplashScreen::start();
   584     connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
   580     connect(mMainWindow, SIGNAL(viewReady()), this, SLOT(showOnViewReady()));
   585     mCurrentView = MsgBaseView::UNIVIEWER;
   581     mCurrentView = MsgBaseView::UNIVIEWER;
   586 
   582 
   587     // construct viewer instance (keep it minimal)
   583     // construct viewer instance (keep it minimal)
   610     {
   606     {
   611         return;
   607         return;
   612     }
   608     }
   613 
   609 
   614     // notification state e.g. waiting, retrieving etc
   610     // notification state e.g. waiting, retrieving etc
       
   611     QString displayTxt;
   615     QString statusStr;
   612     QString statusStr;
   616     int status;
   613     int status;
   617     mStoreHandler->notificationStatus(status, statusStr);
   614     mStoreHandler->notificationStatus(status, statusStr);
   618 
       
   619     QString displayTxt;
       
   620     displayTxt.append(mStoreHandler->notificationSubject());
       
   621     displayTxt.append(QChar::LineSeparator);
       
   622     displayTxt.append(mStoreHandler->notificationMsgSize());
       
   623     displayTxt.append(QChar::LineSeparator);
       
   624     displayTxt.append(mStoreHandler->notificationClass());
       
   625     displayTxt.append(QChar::LineSeparator);
       
   626     displayTxt.append(mStoreHandler->notificationExpiryDate());
       
   627     if(!statusStr.isEmpty())
   615     if(!statusStr.isEmpty())
   628     {
   616     {
   629         displayTxt.append(QChar::LineSeparator);
   617         displayTxt.append(statusStr).append(QChar::LineSeparator);
   630         displayTxt.append(statusStr);
   618     }
   631     }    
   619     
   632     HbDeviceMessageBox::information(displayTxt);
   620     QString sender = mStoreHandler->notificationSender();
       
   621     if(!sender.isEmpty())
       
   622     {
       
   623         displayTxt.append(sender).append(QChar::LineSeparator);
       
   624     }
       
   625     
       
   626     QString timestamp = mStoreHandler->notificationTimeStamp();
       
   627     if(!timestamp.isEmpty())
       
   628     {
       
   629         displayTxt.append(timestamp).append(QChar::LineSeparator);
       
   630     }
       
   631 
       
   632     QString subject = mStoreHandler->notificationSubject();
       
   633     if(!subject.isEmpty())
       
   634     {
       
   635         displayTxt.append(subject).append(QChar::LineSeparator);
       
   636     }
       
   637 
       
   638     QString msgSize = mStoreHandler->notificationMsgSize();
       
   639     if(!msgSize.isEmpty())
       
   640     {
       
   641         displayTxt.append(msgSize).append(QChar::LineSeparator);
       
   642     }
       
   643 
       
   644     QString msgClass = mStoreHandler->notificationClass();
       
   645     if(!msgClass.isEmpty())
       
   646     {
       
   647         displayTxt.append(msgClass).append(QChar::LineSeparator);
       
   648     }
       
   649 
       
   650     QString exprDate = mStoreHandler->notificationExpiryDate();
       
   651     if(!exprDate.isEmpty())
       
   652     {
       
   653         displayTxt.append(exprDate);
       
   654     }
       
   655 
       
   656     HbDeviceMessageBox msgbox;
       
   657     msgbox.setText(displayTxt);
       
   658     msgbox.setDismissPolicy(HbPopup::NoDismiss);
       
   659     msgbox.setTimeout(HbPopup::NoTimeout);
       
   660     msgbox.exec();
       
   661     msgbox.close();
   633     HbApplication::quit();
   662     HbApplication::quit();
   634 }
   663 }
   635 
   664 
   636 // ----------------------------------------------------------------------------
   665 // ----------------------------------------------------------------------------
   637 // MsgServiceViewManager::showOnViewReady
   666 // MsgServiceViewManager::showOnViewReady
   684     }
   713     }
   685     delete pluginLoader;
   714     delete pluginLoader;
   686 
   715 
   687     RingBc* ringBc = new RingBc();
   716     RingBc* ringBc = new RingBc();
   688     QString filename = ringBc->toneTitle(filepath);
   717     QString filename = ringBc->toneTitle(filepath);
   689     // TODO: use filename to create a localized string to show in dialog
   718     QString loc_str = LOC_SAVE_RINGTONE.arg(filename);
   690     QString loc_str = QString("Save ringtone? ").append(filename);
       
   691     bool save = HbDeviceMessageBox::question(loc_str,
   719     bool save = HbDeviceMessageBox::question(loc_str,
   692                     HbMessageBox::Save | HbMessageBox::Cancel);
   720                     HbMessageBox::Save | HbMessageBox::Cancel);
   693     if(save)
   721     if(save)
   694     {
   722     {
   695         ringBc->saveTone(filepath);
   723         ringBc->saveTone(filepath);