64 #include "convergedmessageaddress.h" |
64 #include "convergedmessageaddress.h" |
65 #include "UniEditorGenUtils.h" |
65 #include "UniEditorGenUtils.h" |
66 #include "unieditorpluginloader.h" |
66 #include "unieditorpluginloader.h" |
67 #include "unieditorplugininterface.h" |
67 #include "unieditorplugininterface.h" |
68 #include "msgsettingsview.h" |
68 #include "msgsettingsview.h" |
|
69 #include "msgcontacthandler.h" |
|
70 #include "msgaudiofetcherdialog.h" |
69 |
71 |
70 QTM_USE_NAMESPACE |
72 QTM_USE_NAMESPACE |
71 // Constants |
73 // Constants |
72 const QString SEND_ICON("qtg_mono_send"); |
74 const QString SEND_ICON("qtg_mono_send"); |
73 const QString ATTACH_ICON("qtg_mono_attach"); |
75 const QString ATTACH_ICON("qtg_mono_attach"); |
120 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
122 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
121 |
123 |
122 //settings confirmation |
124 //settings confirmation |
123 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e") |
125 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e") |
124 #define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_access_point_not_defined") |
126 #define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_access_point_not_defined") |
|
127 #define LOC_NOTE_FILES_MISSED_DRAFTS hbTrId("txt_messaging_dpopinfo_some_files_in_the_message") |
|
128 #define LOC_NOTE_FILES_MISSED_SEND hbTrId("txt_messaging_dialog_unable_to_send_message_some") |
125 // LOCAL FUNCTIONS |
129 // LOCAL FUNCTIONS |
126 |
130 |
127 //--------------------------------------------------------------- |
131 //--------------------------------------------------------------- |
128 // editorTempPath |
132 // editorTempPath |
129 // @return fullPath of unified editor's temporary dir |
133 // @return fullPath of unified editor's temporary dir |
156 mContentWidget(0), |
160 mContentWidget(0), |
157 mMsgMonitor(0), |
161 mMsgMonitor(0), |
158 mAttachmentContainer(0), |
162 mAttachmentContainer(0), |
159 mPluginLoader(0), |
163 mPluginLoader(0), |
160 mCanSaveToDrafts(true), |
164 mCanSaveToDrafts(true), |
161 mVkbHost(NULL) |
165 mVkbHost(NULL), |
|
166 mDialog(NULL), |
|
167 mOriginatingSC(0), |
|
168 mOriginatingSME(0), |
|
169 mReplyPath(false) |
162 { |
170 { |
163 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
171 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
164 |
172 |
165 addToolBar(); |
173 addToolBar(); |
166 initView(); |
174 initView(); |
172 //--------------------------------------------------------------- |
180 //--------------------------------------------------------------- |
173 MsgUnifiedEditorView::~MsgUnifiedEditorView() |
181 MsgUnifiedEditorView::~MsgUnifiedEditorView() |
174 { |
182 { |
175 // clean editor's temporary contents before exiting |
183 // clean editor's temporary contents before exiting |
176 removeTempFolder(); |
184 removeTempFolder(); |
|
185 |
|
186 //delete the popup dialog |
|
187 delete mDialog; |
177 } |
188 } |
178 |
189 |
179 //--------------------------------------------------------------- |
190 //--------------------------------------------------------------- |
180 // MsgUnifiedEditorView::initView |
191 // MsgUnifiedEditorView::initView |
181 // @see header file |
192 // @see header file |
293 ConvergedMessage* msg; |
304 ConvergedMessage* msg; |
294 msg = pluginInterface->convertFrom(messageId.getId()); |
305 msg = pluginInterface->convertFrom(messageId.getId()); |
295 |
306 |
296 if( msg != NULL ) |
307 if( msg != NULL ) |
297 { |
308 { |
|
309 mReplyPath = msg->replyPath(); |
|
310 if(mReplyPath) |
|
311 { |
|
312 mOriginatingSC = msg->originatingSC(); |
|
313 mOriginatingSME = msg->toAddressList().at(0)->address(); |
|
314 } |
298 //Populate the content inside editor |
315 //Populate the content inside editor |
299 populateContentIntoEditor(*msg,true); // true as it is draft message |
316 populateContentIntoEditor(*msg,true); // true as it is draft message |
300 delete msg; |
317 delete msg; |
301 } |
318 } |
302 |
319 |
328 ConvergedMessage* msg; |
345 ConvergedMessage* msg; |
329 msg = pluginInterface->convertFrom(messageId.getId(), |
346 msg = pluginInterface->convertFrom(messageId.getId(), |
330 (UniEditorPluginInterface::EditorOperation)editorOperation); |
347 (UniEditorPluginInterface::EditorOperation)editorOperation); |
331 if( msg != NULL ) |
348 if( msg != NULL ) |
332 { |
349 { |
|
350 if(editorOperation == UniEditorPluginInterface::Reply) |
|
351 { |
|
352 mReplyPath = msg->replyPath(); |
|
353 if(mReplyPath) |
|
354 { |
|
355 mOriginatingSC = msg->originatingSC(); |
|
356 mOriginatingSME = msg->toAddressList().at(0)->address(); |
|
357 } |
|
358 } |
333 //Populate the content inside editor |
359 //Populate the content inside editor |
334 populateContentIntoEditor(*msg); |
360 populateContentIntoEditor(*msg); |
335 delete msg; |
361 delete msg; |
336 } |
362 } |
337 } |
363 } |
472 { |
498 { |
473 // skip first-time MMS type switch note for draft |
499 // skip first-time MMS type switch note for draft |
474 mMsgMonitor->setSkipNote(true); |
500 mMsgMonitor->setSkipNote(true); |
475 mToField->skipMaxRecipientQuery(true); |
501 mToField->skipMaxRecipientQuery(true); |
476 |
502 |
477 mToField->setAddresses(messageDetails.toAddressList()); |
503 mToField->setAddresses(messageDetails.toAddressList(),draftMessage); |
478 if(messageDetails.ccAddressList().count() > 0 ) |
504 if(messageDetails.ccAddressList().count() > 0 ) |
479 { |
505 { |
480 if(!mCcField) |
506 if(!mCcField) |
481 { |
507 { |
482 addCcBcc(); |
508 addCcBcc(); |
483 } |
509 } |
484 mCcField->setAddresses(messageDetails.ccAddressList()); |
510 mCcField->setAddresses(messageDetails.ccAddressList(),draftMessage); |
485 } |
511 } |
486 if(messageDetails.bccAddressList().count() > 0 ) |
512 if(messageDetails.bccAddressList().count() > 0 ) |
487 { |
513 { |
488 if(!mBccField) |
514 if(!mBccField) |
489 { |
515 { |
490 addCcBcc(); |
516 addCcBcc(); |
491 } |
517 } |
492 mBccField->setAddresses(messageDetails.bccAddressList()); |
518 mBccField->setAddresses(messageDetails.bccAddressList(),draftMessage); |
493 } |
519 } |
494 if(messageDetails.subject().size() > 0) |
520 if(messageDetails.subject().size() > 0) |
495 { |
521 { |
496 if(!mSubjectField) |
522 if(!mSubjectField) |
497 { |
523 { |
858 } |
884 } |
859 |
885 |
860 //close vkb before switching view. |
886 //close vkb before switching view. |
861 mVkbHost->closeKeypad(true); |
887 mVkbHost->closeKeypad(true); |
862 |
888 |
863 packMessage(msg); |
889 int result = packMessage(msg); |
864 |
890 if(result == KErrNotFound) |
|
891 { |
|
892 HbMessageBox::information(LOC_NOTE_FILES_MISSED_SEND, 0, 0, HbMessageBox::Ok); |
|
893 deactivateInputBlocker(); |
|
894 return; |
|
895 } |
865 // send message |
896 // send message |
866 MsgSendUtil *sendUtil = new MsgSendUtil(this); |
897 MsgSendUtil *sendUtil = new MsgSendUtil(this); |
867 int sendResult = sendUtil->send(msg); |
898 int sendResult = sendUtil->send(msg); |
868 delete sendUtil; |
899 delete sendUtil; |
869 |
900 |
950 } |
981 } |
951 } |
982 } |
952 } |
983 } |
953 } |
984 } |
954 |
985 |
955 void MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave) |
986 int MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave) |
956 { |
987 { |
|
988 // reset reply-path if originating SME constraint is broken |
|
989 if(mReplyPath && isReplyPathBroken()) |
|
990 { |
|
991 mReplyPath = false; |
|
992 } |
|
993 |
|
994 msg.setReplyPath(mReplyPath); |
|
995 if(mReplyPath) |
|
996 { |
|
997 msg.setOriginatingSC(mOriginatingSC); |
|
998 } |
|
999 |
957 ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType(); |
1000 ConvergedMessage::MessageType messageType = MsgUnifiedEditorMonitor::messageType(); |
958 msg.setMessageType(messageType); |
1001 msg.setMessageType(messageType); |
959 // If isSave is true (save to draft usecase), then don't remove duplicates |
1002 // If isSave is true (save to draft usecase), then don't remove duplicates |
960 // If isSave is false (send usecase), then remove duplicates |
1003 // If isSave is false (send usecase), then remove duplicates |
961 bool removeDuplicates = !isSave; |
1004 bool removeDuplicates = !isSave; |
962 ConvergedMessageAddressList addresses = |
1005 ConvergedMessageAddressList addresses = |
963 mToField->addresses(removeDuplicates); |
1006 mToField->addresses(removeDuplicates); |
964 ConvergedMessageAddressList ccAddresses; |
1007 ConvergedMessageAddressList ccAddresses; |
965 ConvergedMessageAddressList bccAddresses; |
1008 ConvergedMessageAddressList bccAddresses; |
966 |
1009 ConvergedMessageAttachmentList mediaList; |
|
1010 int errorCode = 0; |
967 //Don't format the addresses for save to drfats case |
1011 //Don't format the addresses for save to drfats case |
968 if(!isSave) |
1012 if(!isSave) |
969 { |
1013 { |
970 formatAddresses(addresses); |
1014 formatAddresses(addresses); |
971 } |
1015 } |
1048 { |
1092 { |
1049 msg.setSubject(mSubjectField->text()); |
1093 msg.setSubject(mSubjectField->text()); |
1050 msg.setPriority(mSubjectField->priority()); |
1094 msg.setPriority(mSubjectField->priority()); |
1051 } |
1095 } |
1052 |
1096 |
1053 ConvergedMessageAttachmentList mediaList; |
|
1054 |
|
1055 QStringList mediafiles(mBody->mediaContent()); |
1097 QStringList mediafiles(mBody->mediaContent()); |
1056 if (!mediafiles.isEmpty()) |
1098 if (!mediafiles.isEmpty()) |
1057 { |
1099 { |
1058 for (int i = 0; i < mediafiles.size(); ++i) |
1100 for (int i = 0; i < mediafiles.size(); ++i) |
1059 { |
1101 { |
|
1102 if(QFile::exists(mediafiles.at(i))) |
|
1103 { |
1060 ConvergedMessageAttachment* attachment = |
1104 ConvergedMessageAttachment* attachment = |
1061 new ConvergedMessageAttachment( |
1105 new ConvergedMessageAttachment( |
1062 mediafiles.at(i), |
1106 mediafiles.at(i), |
1063 ConvergedMessageAttachment::EInline); |
1107 ConvergedMessageAttachment::EInline); |
1064 mediaList << attachment; |
1108 mediaList << attachment; |
|
1109 } |
|
1110 else |
|
1111 { mBody->removeMediaContent(mediafiles.at(i)); |
|
1112 errorCode = KErrNotFound; |
|
1113 } |
1065 } |
1114 } |
1066 |
1115 |
1067 } |
1116 } |
1068 if(mediaList.count() > 0) |
1117 if(mediaList.count() > 0) |
1069 { |
1118 { |
1077 { |
1126 { |
1078 MsgUnifiedEditorAttachmentList editorAttachmentList = |
1127 MsgUnifiedEditorAttachmentList editorAttachmentList = |
1079 mAttachmentContainer->attachmentList(); |
1128 mAttachmentContainer->attachmentList(); |
1080 for (int i = 0; i < editorAttachmentList.count(); ++i) |
1129 for (int i = 0; i < editorAttachmentList.count(); ++i) |
1081 { |
1130 { |
1082 ConvergedMessageAttachment* attachment = |
1131 if(QFile::exists(editorAttachmentList.at(i)->path())) |
1083 new ConvergedMessageAttachment( |
1132 { |
1084 editorAttachmentList.at(i)->path(), |
1133 ConvergedMessageAttachment* attachment = |
1085 ConvergedMessageAttachment::EAttachment); |
1134 new ConvergedMessageAttachment( |
1086 attachmentList << attachment; |
1135 editorAttachmentList.at(i)->path(), |
|
1136 ConvergedMessageAttachment::EAttachment); |
|
1137 attachmentList << attachment; |
|
1138 } |
|
1139 else |
|
1140 { |
|
1141 mAttachmentContainer->deleteAttachment(editorAttachmentList.at(i)); |
|
1142 errorCode = KErrNotFound; |
|
1143 } |
1087 } |
1144 } |
1088 } |
1145 } |
1089 if(attachmentList.count() > 0) |
1146 if(attachmentList.count() > 0) |
1090 { |
1147 { |
1091 msg.addAttachments(attachmentList); |
1148 msg.addAttachments(attachmentList); |
1092 } |
1149 } |
|
1150 return errorCode; |
1093 } |
1151 } |
1094 |
1152 |
1095 int MsgUnifiedEditorView::saveContentToDrafts() |
1153 int MsgUnifiedEditorView::saveContentToDrafts() |
1096 { |
1154 { |
1097 if(!mCanSaveToDrafts) |
1155 if(!mCanSaveToDrafts) |
1163 // if empty msg, do not send |
1221 // if empty msg, do not send |
1164 deactivateInputBlocker(); |
1222 deactivateInputBlocker(); |
1165 return INVALID_MSGID; |
1223 return INVALID_MSGID; |
1166 } |
1224 } |
1167 ConvergedMessage msg; |
1225 ConvergedMessage msg; |
1168 packMessage(msg, true); |
1226 int result = packMessage(msg, true); |
1169 |
1227 if(result == KErrNotFound) |
|
1228 { |
|
1229 HbNotificationDialog::launchDialog(LOC_NOTE_FILES_MISSED_DRAFTS); |
|
1230 if(messageType == ConvergedMessage::Sms && |
|
1231 addresses.isEmpty() && |
|
1232 MsgUnifiedEditorMonitor::bodySize() <= 0 && |
|
1233 MsgUnifiedEditorMonitor::containerSize() <= 0) |
|
1234 { |
|
1235 if(mOpenedMessageId.getId() != -1) |
|
1236 { |
|
1237 pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId()); |
|
1238 } |
|
1239 |
|
1240 // if empty msg, do not save |
|
1241 deactivateInputBlocker(); |
|
1242 return INVALID_MSGID; |
|
1243 } |
|
1244 } |
1170 // save to drafts |
1245 // save to drafts |
1171 MsgSendUtil *sendUtil = new MsgSendUtil(this); |
1246 MsgSendUtil *sendUtil = new MsgSendUtil(this); |
1172 int msgId = sendUtil->saveToDrafts(msg); |
1247 int msgId = sendUtil->saveToDrafts(msg); |
1173 delete sendUtil; |
1248 delete sendUtil; |
1174 |
1249 |
1427 // MsgUnifiedEditorView::fetchAudio |
1502 // MsgUnifiedEditorView::fetchAudio |
1428 // @see header file |
1503 // @see header file |
1429 //--------------------------------------------------------------- |
1504 //--------------------------------------------------------------- |
1430 void MsgUnifiedEditorView::fetchAudio() |
1505 void MsgUnifiedEditorView::fetchAudio() |
1431 { |
1506 { |
1432 // Launch Audio fetcher view |
1507 // Launch Audio fetcher dialog |
1433 QVariantList params; |
1508 if(!mDialog) |
1434 params << MsgBaseView::AUDIOFETCHER; // target view |
1509 { |
1435 params << MsgBaseView::UNIEDITOR; // source view |
1510 mDialog = new MsgAudioFetcherDialog(); |
1436 emit switchView(params); |
1511 connect(mDialog, |
|
1512 SIGNAL(audioSelected(QString&)), |
|
1513 this, |
|
1514 SLOT(onAudioSelected(QString&))); |
|
1515 } |
|
1516 |
|
1517 //show the dialog |
|
1518 mDialog->show(); |
1437 } |
1519 } |
1438 |
1520 |
1439 //--------------------------------------------------------------- |
1521 //--------------------------------------------------------------- |
1440 // MsgUnifiedEditorView::contactsFetched |
1522 // MsgUnifiedEditorView::contactsFetched |
1441 // @see header file |
1523 // @see header file |
1548 { |
1630 { |
1549 mAttachAction->setDisabled(false); |
1631 mAttachAction->setDisabled(false); |
1550 connect(mVkbHost,SIGNAL(aboutToOpen()), |
1632 connect(mVkbHost,SIGNAL(aboutToOpen()), |
1551 this,SLOT(vkbAboutToOpen())); |
1633 this,SLOT(vkbAboutToOpen())); |
1552 } |
1634 } |
|
1635 |
|
1636 //--------------------------------------------------------------- |
|
1637 // MsgUnifiedEditorView::onAudioSelected |
|
1638 // @see header file |
|
1639 //--------------------------------------------------------------- |
|
1640 void |
|
1641 MsgUnifiedEditorView::onAudioSelected(QString& filePath) |
|
1642 { |
|
1643 if (!filePath.isEmpty()) |
|
1644 { |
|
1645 mBody->setAudio(filePath); |
|
1646 } |
|
1647 } |
|
1648 |
1553 //--------------------------------------------------------------- |
1649 //--------------------------------------------------------------- |
1554 // MsgUnifiedEditorView::hideChrome |
1650 // MsgUnifiedEditorView::hideChrome |
1555 // |
1651 // |
1556 //--------------------------------------------------------------- |
1652 //--------------------------------------------------------------- |
1557 void MsgUnifiedEditorView::hideChrome(bool hide) |
1653 void MsgUnifiedEditorView::hideChrome(bool hide) |
1748 addresses[i]->setAddress(addr); |
1844 addresses[i]->setAddress(addr); |
1749 |
1845 |
1750 delete tempAddr; |
1846 delete tempAddr; |
1751 } |
1847 } |
1752 } |
1848 } |
|
1849 |
|
1850 // ---------------------------------------------------------------------------- |
|
1851 // MsgUnifiedEditorView::isReplyPathBroken |
|
1852 // @see header |
|
1853 // ---------------------------------------------------------------------------- |
|
1854 bool MsgUnifiedEditorView::isReplyPathBroken() |
|
1855 { |
|
1856 // 1. Never set for MMS |
|
1857 // 2. if additional recipients exits |
|
1858 if( (MsgUnifiedEditorMonitor::messageType() == ConvergedMessage::Mms) || |
|
1859 (mToField->addressCount() != 1) ) |
|
1860 { |
|
1861 // broken |
|
1862 return true; |
|
1863 } |
|
1864 |
|
1865 // 3. if only recipient is not same as originating SME |
|
1866 QString dispName; |
|
1867 int phCount; |
|
1868 int origCntLocalId = MsgContactHandler::resolveContactDisplayName( |
|
1869 mOriginatingSME, dispName, phCount); |
|
1870 int currCntLocalId = -1; |
|
1871 QString currAddress(mToField->addresses().at(0)->address()); |
|
1872 if(origCntLocalId != -1) |
|
1873 { |
|
1874 currCntLocalId = MsgContactHandler::resolveContactDisplayName( |
|
1875 currAddress, dispName, phCount); |
|
1876 } |
|
1877 |
|
1878 if(currCntLocalId != -1) |
|
1879 { // both are mapped contacts present in contacts db |
|
1880 if(currCntLocalId != origCntLocalId) |
|
1881 { |
|
1882 return true; |
|
1883 } |
|
1884 } |
|
1885 else |
|
1886 { // atleast one contact is not present in contacts db |
|
1887 // direct compare |
|
1888 UniEditorGenUtils* genUtils = q_check_ptr(new UniEditorGenUtils); |
|
1889 bool compareResult = false; |
|
1890 TRAP_IGNORE( |
|
1891 compareResult = genUtils->MatchPhoneNumberL( |
|
1892 *XQConversions::qStringToS60Desc(mOriginatingSME), |
|
1893 *XQConversions::qStringToS60Desc(currAddress)) |
|
1894 ); |
|
1895 delete genUtils; |
|
1896 if(!compareResult) |
|
1897 { |
|
1898 return true; |
|
1899 } |
|
1900 } |
|
1901 |
|
1902 return false; |
|
1903 } |
|
1904 |
1753 //EOF |
1905 //EOF |