messagingapp/msgui/unifiededitor/src/msgunieditorview.cpp
changeset 34 84197e66a4bd
parent 31 ebfee66fde93
child 43 35b64624a9e7
equal deleted inserted replaced
31:ebfee66fde93 34:84197e66a4bd
    55 #include "debugtraces.h"
    55 #include "debugtraces.h"
    56 #include "msgunieditorview.h"
    56 #include "msgunieditorview.h"
    57 #include "msgunieditoraddress.h"
    57 #include "msgunieditoraddress.h"
    58 #include "msgunieditorsubject.h"
    58 #include "msgunieditorsubject.h"
    59 #include "msgunieditorbody.h"
    59 #include "msgunieditorbody.h"
    60 #include "msgmonitor.h"
    60 #include "msgunieditormonitor.h"
    61 #include "msgattachmentcontainer.h"
    61 #include "msgunieditorattachmentcontainer.h"
    62 #include "msgsendutil.h"
    62 #include "msgsendutil.h"
    63 #include "convergedmessageaddress.h"
    63 #include "convergedmessageaddress.h"
    64 #include "unieditorgenutils.h"
    64 #include "UniEditorGenUtils.h"
    65 #include "unieditorpluginloader.h"
    65 #include "unieditorpluginloader.h"
    66 #include "unieditorplugininterface.h"
    66 #include "unieditorplugininterface.h"
    67 #include "msgsettingsview.h"
    67 #include "msgsettingsview.h"
    68 
    68 
    69 QTM_USE_NAMESPACE
    69 QTM_USE_NAMESPACE
   120 
   120 
   121 //extension list item frame.
   121 //extension list item frame.
   122 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal");
   122 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal");
   123 
   123 
   124 //settings confirmation
   124 //settings confirmation
   125 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_settings_incomplete")
   125 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e")
   126 #define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_settings_incomplete")
   126 #define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_access_point_not_defined")
   127 // LOCAL FUNCTIONS
   127 // LOCAL FUNCTIONS
   128 
   128 
   129 //---------------------------------------------------------------
   129 //---------------------------------------------------------------
   130 // editorTempPath
   130 // editorTempPath
   131 // @return fullPath of unified editor's temporary dir
   131 // @return fullPath of unified editor's temporary dir
   146 //---------------------------------------------------------------
   146 //---------------------------------------------------------------
   147 MsgUnifiedEditorView::MsgUnifiedEditorView( QGraphicsItem *parent ) :
   147 MsgUnifiedEditorView::MsgUnifiedEditorView( QGraphicsItem *parent ) :
   148     MsgBaseView(parent),
   148     MsgBaseView(parent),
   149     mSubjectAction(0),
   149     mSubjectAction(0),
   150     mCcBccAction(0),
   150     mCcBccAction(0),
       
   151     mSendAction(0),
   151     mMainLayout(0),
   152     mMainLayout(0),
   152     mSubjectField(0),
   153     mSubjectField(0),
   153     mToField(0),
   154     mToField(0),
   154     mCcField(0),
   155     mCcField(0),
   155     mBccField(0),
   156     mBccField(0),
   199     style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
   200     style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing);
   200     
   201     
   201     mMainLayout->setContentsMargins(0,vTopSpacing,0,0);
   202     mMainLayout->setContentsMargins(0,vTopSpacing,0,0);
   202     mMainLayout->setSpacing(vItemSpacing);
   203     mMainLayout->setSpacing(vItemSpacing);
   203 
   204 
   204     mMsgMonitor = new MsgMonitor(this);    
   205     mMsgMonitor = new MsgUnifiedEditorMonitor(this);    
   205 
   206 
   206     mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget );
   207     mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget );
   207     
   208     
   208     mBody = new MsgUnifiedEditorBody( mContentWidget);
   209     mBody = new MsgUnifiedEditorBody( mContentWidget);
   209 
   210 
   220     
   221     
   221     connect(mBody, SIGNAL(sendMessage()), this, SLOT(send()));
   222     connect(mBody, SIGNAL(sendMessage()), this, SLOT(send()));
   222     connect(mBody, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
   223     connect(mBody, SIGNAL(contentChanged()),this,SLOT(onContentChanged()));
   223     connect(mBody, SIGNAL(contentChanged()),
   224     connect(mBody, SIGNAL(contentChanged()),
   224             mMsgMonitor, SLOT(handleContentChange()));
   225             mMsgMonitor, SLOT(handleContentChange()));
       
   226     connect(mBody, SIGNAL(enableSendButton(bool)), this, SLOT(enableSendButton(bool)));    
   225     
   227     
   226 }
   228 }
   227 
   229 
   228 void MsgUnifiedEditorView::addMenu()
   230 void MsgUnifiedEditorView::addMenu()
   229 {
   231 {
   295     msg = pluginInterface->convertFrom(messageId.getId());
   297     msg = pluginInterface->convertFrom(messageId.getId());
   296 
   298 
   297     if( msg != NULL )
   299     if( msg != NULL )
   298     {
   300     {
   299         //Populate the content inside editor
   301         //Populate the content inside editor
   300         populateContentIntoEditor(*msg);
   302         populateContentIntoEditor(*msg,true); // true as it is  draft message
   301         delete msg;
   303         delete msg;
   302     }
   304     }
   303     
   305     
   304     mCanSaveToDrafts = false;  
   306     mCanSaveToDrafts = false;  
   305 }
   307 }
   448     }
   450     }
   449     delete messageDetails; 
   451     delete messageDetails; 
   450 }
   452 }
   451 
   453 
   452 void MsgUnifiedEditorView::populateContentIntoEditor(
   454 void MsgUnifiedEditorView::populateContentIntoEditor(
   453     const ConvergedMessage& messageDetails)
   455     const ConvergedMessage& messageDetails,bool draftMessage)
   454 {
   456 {
   455     // skip first-time MMS type switch note for draft
   457     // skip first-time MMS type switch note for draft
   456     mMsgMonitor->setSkipNote(true);
   458     mMsgMonitor->setSkipNote(true);
   457     mToField->skipMaxRecipientQuery(true);
   459     mToField->skipMaxRecipientQuery(true);
   458 
   460 
   517 
   519 
   518             switch(mediaType)
   520             switch(mediaType)
   519             {
   521             {
   520                 case EMsgMediaImage:
   522                 case EMsgMediaImage:
   521                 {
   523                 {
   522                     mBody->setImage(filePath);
   524                     mBody->setImage(filePath,draftMessage);
   523                     break;
   525                     break;
   524                 }
   526                 }
   525                 case EMsgMediaAudio:
   527                 case EMsgMediaAudio:
   526                 {
   528                 {
   527                     mBody->setAudio(filePath);
   529                     mBody->setAudio(filePath);
   574             attachExtension, SLOT(close()));
   576             attachExtension, SLOT(close()));
   575 
   577 
   576     attachExtension->setContentWidget(mTBExtnContentWidget);
   578     attachExtension->setContentWidget(mTBExtnContentWidget);
   577 
   579 
   578     //Add Action to the toolbar and show toolbar
   580     //Add Action to the toolbar and show toolbar
   579     toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send()));
   581     mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send()));
   580 
   582 
   581 
   583 
   582     setToolBar(toolBar);
   584     setToolBar(toolBar);
   583 }
   585 }
   584 
   586 
   795         return;
   797         return;
   796     }
   798     }
   797 
   799 
   798     // converged msg for sending
   800     // converged msg for sending
   799     ConvergedMessage msg;
   801     ConvergedMessage msg;
   800     ConvergedMessage::MessageType messageType = MsgMonitor::messageType();
   802     ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
   801     msg.setMessageType(messageType);
   803     msg.setMessageType(messageType);
   802 
   804 
   803     // we need to remove duplicate addresses
   805     // we need to remove duplicate addresses
   804     bool removeDuplicates = true;
   806     bool removeDuplicates = true;
   805     ConvergedMessageAddressList addresses =
   807     ConvergedMessageAddressList addresses =
   929     }
   931     }
   930 }
   932 }
   931 
   933 
   932 void MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave)
   934 void MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave)
   933 {
   935 {
   934     ConvergedMessage::MessageType messageType = MsgMonitor::messageType();
   936     ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
   935     msg.setMessageType(messageType);
   937     msg.setMessageType(messageType);
   936     // If isSave is true (save to draft usecase), then don't remove duplicates
   938     // If isSave is true (save to draft usecase), then don't remove duplicates
   937     // If isSave is false (send usecase), then remove duplicates
   939     // If isSave is false (send usecase), then remove duplicates
   938     bool removeDuplicates = !isSave;
   940     bool removeDuplicates = !isSave;
   939     ConvergedMessageAddressList addresses = 
   941     ConvergedMessageAddressList addresses = 
  1058     if(!mCanSaveToDrafts)
  1060     if(!mCanSaveToDrafts)
  1059         {
  1061         {
  1060         return;
  1062         return;
  1061         }
  1063         }
  1062     activateInputBlocker();
  1064     activateInputBlocker();
  1063     ConvergedMessage::MessageType messageType = MsgMonitor::messageType();
  1065     ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType();
  1064 
  1066 
  1065     ConvergedMessageAddressList addresses = mToField->addresses();
  1067     ConvergedMessageAddressList addresses = mToField->addresses();
  1066 
  1068 
  1067     UniEditorPluginInterface* pluginInterface = NULL;
  1069     UniEditorPluginInterface* pluginInterface = NULL;
  1068 
  1070 
  1077             mPluginLoader->getUniEditorPlugin(messageType);
  1079             mPluginLoader->getUniEditorPlugin(messageType);
  1078     }
  1080     }
  1079 
  1081 
  1080     if(messageType == ConvergedMessage::Sms &&
  1082     if(messageType == ConvergedMessage::Sms &&
  1081             addresses.isEmpty() &&
  1083             addresses.isEmpty() &&
  1082             MsgMonitor::bodySize() <= 0 &&
  1084             MsgUnifiedEditorMonitor::bodySize() <= 0 &&
  1083             MsgMonitor::containerSize() <= 0)
  1085             MsgUnifiedEditorMonitor::containerSize() <= 0)
  1084     {
  1086     {
  1085         if(mOpenedMessageId.getId() != -1)
  1087         if(mOpenedMessageId.getId() != -1)
  1086         {
  1088         {
  1087         pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1089         pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1088         }
  1090         }
  1111     if( messageType == ConvergedMessage::Mms &&
  1113     if( messageType == ConvergedMessage::Mms &&
  1112             addresses.isEmpty() &&
  1114             addresses.isEmpty() &&
  1113             ccAddresses.isEmpty() &&
  1115             ccAddresses.isEmpty() &&
  1114             bccAddresses.isEmpty() &&
  1116             bccAddresses.isEmpty() &&
  1115             subectSize <= 0 &&
  1117             subectSize <= 0 &&
  1116             MsgMonitor::bodySize() <= 0 &&
  1118             MsgUnifiedEditorMonitor::bodySize() <= 0 &&
  1117             MsgMonitor::containerSize() <= 0)
  1119             MsgUnifiedEditorMonitor::containerSize() <= 0)
  1118     {
  1120     {
  1119         if(mOpenedMessageId.getId() != -1)
  1121         if(mOpenedMessageId.getId() != -1)
  1120         {
  1122         {
  1121             pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1123             pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1122         }
  1124         }
  1354 // MsgUnifiedEditorView::fetchImages
  1356 // MsgUnifiedEditorView::fetchImages
  1355 // @see header file
  1357 // @see header file
  1356 //---------------------------------------------------------------
  1358 //---------------------------------------------------------------
  1357 void MsgUnifiedEditorView::fetchImages()
  1359 void MsgUnifiedEditorView::fetchImages()
  1358 {
  1360 {
  1359     QString interface("Image");
  1361     QString service("photos");
  1360     QString operation("fetch(QVariantMap,QVariant)");
  1362     QString interface("com.nokia.symbian.IImageFetch");
       
  1363     QString operation("fetch(void)");
  1361     XQAiwRequest* request = NULL;
  1364     XQAiwRequest* request = NULL;
  1362     XQApplicationManager appManager;
  1365     XQApplicationManager appManager;
  1363     request = appManager.create(interface, operation, true);//embedded
  1366     request = appManager.create(service,interface, operation, true);//embedded
  1364     request->setSynchronous(true); // synchronous
  1367     request->setSynchronous(true); // synchronous
  1365     if(!request)
  1368     if(!request)
  1366     {     
  1369     {     
  1367         QCRITICAL_WRITE("AIW-ERROR: NULL request");
  1370         QCRITICAL_WRITE("AIW-ERROR: NULL request");
  1368         return;
  1371         return;
  1371     connect(request, SIGNAL(requestOk(const QVariant&)),
  1374     connect(request, SIGNAL(requestOk(const QVariant&)),
  1372         this, SLOT(imagesFetched(const QVariant&)));
  1375         this, SLOT(imagesFetched(const QVariant&)));
  1373     connect(request, SIGNAL(requestError(int,const QString&)),
  1376     connect(request, SIGNAL(requestError(int,const QString&)),
  1374         this, SLOT(serviceRequestError(int,const QString&)));
  1377         this, SLOT(serviceRequestError(int,const QString&)));
  1375     
  1378     
  1376     // Set arguments for request
       
  1377     QList<QVariant> args;
       
  1378     args << QVariantMap();
       
  1379     args << QVariant();
       
  1380     request->setArguments(args);
       
  1381     // Make the request
  1379     // Make the request
  1382     if (!request->send())
  1380     if (!request->send())
  1383     {
  1381     {
  1384         QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError());
  1382         QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError());
  1385     }  
  1383     }  
  1480 // MsgUnifiedEditorView::activateInputBlocker
  1478 // MsgUnifiedEditorView::activateInputBlocker
  1481 // @see header file
  1479 // @see header file
  1482 //--------------------------------------------------------------
  1480 //--------------------------------------------------------------
  1483 void MsgUnifiedEditorView::activateInputBlocker()
  1481 void MsgUnifiedEditorView::activateInputBlocker()
  1484 {
  1482 {
  1485     this->grabMouse();
  1483     mainWindow()->setInteractive(false);
  1486     this->grabKeyboard();
       
  1487 }
  1484 }
  1488 
  1485 
  1489 //---------------------------------------------------------------
  1486 //---------------------------------------------------------------
  1490 // MsgUnifiedEditorView::deactivateInputBlocker
  1487 // MsgUnifiedEditorView::deactivateInputBlocker
  1491 // @see header file
  1488 // @see header file
  1492 //--------------------------------------------------------------
  1489 //--------------------------------------------------------------
  1493 void MsgUnifiedEditorView::deactivateInputBlocker()
  1490 void MsgUnifiedEditorView::deactivateInputBlocker()
  1494 {    
  1491 {
  1495     this->ungrabKeyboard();
  1492     mainWindow()->setInteractive(true);
  1496     this->ungrabMouse();
       
  1497 }
  1493 }
  1498 
  1494 
  1499 //---------------------------------------------------------------
  1495 //---------------------------------------------------------------
  1500 // MsgUnifiedEditorView::setAttachOptionEnabled
  1496 // MsgUnifiedEditorView::setAttachOptionEnabled
  1501 // @see header file
  1497 // @see header file
  1635             if (!mPluginLoader) {
  1631             if (!mPluginLoader) {
  1636                 mPluginLoader = new UniEditorPluginLoader(this);
  1632                 mPluginLoader = new UniEditorPluginLoader(this);
  1637             }
  1633             }
  1638 
  1634 
  1639             UniEditorPluginInterface* pluginInterface = mPluginLoader->getUniEditorPlugin(
  1635             UniEditorPluginInterface* pluginInterface = mPluginLoader->getUniEditorPlugin(
  1640                 MsgMonitor::messageType());
  1636                 MsgUnifiedEditorMonitor::messageType());
  1641 
  1637 
  1642             pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1638             pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId());
  1643         }
  1639         }
  1644 
  1640 
  1645         //trigger back action.
  1641         //trigger back action.
  1682         params << MsgSettingsView::MMSView;
  1678         params << MsgSettingsView::MMSView;
  1683         emit switchView(params); 
  1679         emit switchView(params); 
  1684     }
  1680     }
  1685 }
  1681 }
  1686 
  1682 
       
  1683 //---------------------------------------------------------------
       
  1684 // MsgUnifiedEditorView::enableSendButton
       
  1685 // @see header file
       
  1686 //--------------------------------------------------------------
       
  1687 void MsgUnifiedEditorView::enableSendButton(bool enable)
       
  1688     {
       
  1689     if(mSendAction)
       
  1690         {
       
  1691          // enable/disable based on only if its disabled/enabled.
       
  1692          // this check is to avoid unnecessary calls to mSendAction->setEnabled(enable);
       
  1693         if(mSendAction->isEnabled() != enable )
       
  1694             mSendAction->setEnabled(enable);
       
  1695         }
       
  1696     }
       
  1697 
  1687 //EOF
  1698 //EOF