47 #include <qversitdocument.h> |
47 #include <qversitdocument.h> |
48 #include <qcontact.h> |
48 #include <qcontact.h> |
49 #include <qcontactmanager.h> |
49 #include <qcontactmanager.h> |
50 #include <qversitcontactexporter.h> |
50 #include <qversitcontactexporter.h> |
51 #include <cntservicescontact.h> |
51 #include <cntservicescontact.h> |
52 |
52 #include <commonphoneparser.h> // Common phone number validity checker |
53 |
53 |
54 // USER INCLUDES |
54 // USER INCLUDES |
55 #include "debugtraces.h" |
55 #include "debugtraces.h" |
56 #include "msgunieditorview.h" |
56 #include "msgunieditorview.h" |
57 #include "msgunieditoraddress.h" |
57 #include "msgunieditoraddress.h" |
92 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_button_business_card") |
92 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_button_business_card") |
93 |
93 |
94 //options menu. |
94 //options menu. |
95 #define LOC_ADD_SUBJECT hbTrId("txt_messaging_opt_add_subject") |
95 #define LOC_ADD_SUBJECT hbTrId("txt_messaging_opt_add_subject") |
96 #define LOC_ADD_CC_BCC hbTrId("txt_messaging_opt_add_cc_bcc") |
96 #define LOC_ADD_CC_BCC hbTrId("txt_messaging_opt_add_cc_bcc") |
97 #define LOC_PRIORITY hbTrId("txt_messaging_setlabel_priority") |
97 #define LOC_PRIORITY hbTrId("txt_messaging_opt_priority") |
98 #define LOC_SENDING_OPTIONS hbTrId("txt_messaging_opt_sending_options") |
|
99 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_opt_delete_message") |
98 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_opt_delete_message") |
100 |
99 |
101 //priority sub menu |
100 //priority sub menu |
102 #define LOC_HIGH hbTrId("txt_messaging_setlabel_priority_val_high") |
101 #define LOC_HIGH hbTrId("txt_messaging_opt_attach_sub_high") |
103 #define LOC_NORMAL hbTrId("txt_messaging_setlabel_priority_val_normal") |
102 #define LOC_NORMAL hbTrId("txt_messaging_opt_attach_sub_normal") |
104 #define LOC_LOW hbTrId("txt_messaging_setlabel_priority_val_low") |
103 #define LOC_LOW hbTrId("txt_messaging_opt_attach_sub_low") |
105 |
104 |
106 //group box |
105 //group box |
107 #define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_group_title_ln_other_recipients",n) |
106 #define LOC_OTHER_RECIPIENTS(n) hbTrId("txt_messaging_group_title_ln_other_recipients",n) |
|
107 #define LOC_OTHER_RECIPIENTS_EXPAND hbTrId("txt_messaging_title_other_recipients") |
108 |
108 |
109 //saved to draft note |
109 //saved to draft note |
110 #define LOC_SAVED_TO_DRAFTS hbTrId("txt_messaging_dpopinfo_saved_to_drafts") |
110 #define LOC_SAVED_TO_DRAFTS hbTrId("txt_messaging_dpopinfo_saved_to_drafts") |
111 |
111 |
112 //delete confermation |
112 //delete confermation |
113 #define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
113 #define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
114 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
|
115 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
|
116 #define LOC_DIALOG_OK hbTrId("txt_common_button_ok") |
|
117 |
114 |
118 // attachment addition failure note |
115 // attachment addition failure note |
119 #define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2") |
116 #define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2") |
120 |
117 |
121 //extension list item frame. |
118 //extension list item frame. |
200 style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing); |
197 style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing); |
201 |
198 |
202 mMainLayout->setContentsMargins(0,vTopSpacing,0,0); |
199 mMainLayout->setContentsMargins(0,vTopSpacing,0,0); |
203 mMainLayout->setSpacing(vItemSpacing); |
200 mMainLayout->setSpacing(vItemSpacing); |
204 |
201 |
205 mMsgMonitor = new MsgUnifiedEditorMonitor(this); |
202 mMsgMonitor = new MsgUnifiedEditorMonitor(this); |
|
203 connect(mMsgMonitor, SIGNAL(enableSend(bool)), this, SLOT(enableSendButton(bool))); |
206 |
204 |
207 mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget ); |
205 mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget ); |
208 |
206 |
209 mBody = new MsgUnifiedEditorBody( mContentWidget); |
207 mBody = new MsgUnifiedEditorBody( mContentWidget); |
210 |
208 |
253 normalPriorityAction->setData(ConvergedMessage::Normal); |
251 normalPriorityAction->setData(ConvergedMessage::Normal); |
254 |
252 |
255 HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW); |
253 HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW); |
256 lowPriorityAction->setData(ConvergedMessage::Low); |
254 lowPriorityAction->setData(ConvergedMessage::Low); |
257 |
255 |
258 HbAction* sendOptionsAction = mainMenu->addAction(LOC_SENDING_OPTIONS); |
|
259 HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE); |
256 HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE); |
260 |
257 |
261 connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject())); |
258 connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject())); |
262 connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc())); |
259 connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc())); |
263 connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
260 connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
264 connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
261 connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
265 connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
262 connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
266 connect(sendOptionsAction,SIGNAL(triggered()),this, SLOT(sendingOptions())); |
|
267 connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage())); |
263 connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage())); |
268 |
264 |
269 setMenu(mainMenu); |
265 setMenu(mainMenu); |
270 } |
266 } |
271 |
267 |
560 HbToolBarExtension* attachExtension = new HbToolBarExtension(); |
556 HbToolBarExtension* attachExtension = new HbToolBarExtension(); |
561 HbAction *attachAction = toolBar->addExtension(attachExtension); |
557 HbAction *attachAction = toolBar->addExtension(attachExtension); |
562 attachAction->setIcon(HbIcon(ATTACH_ICON)); |
558 attachAction->setIcon(HbIcon(ATTACH_ICON)); |
563 |
559 |
564 mTBExtnContentWidget = new HbListWidget(); |
560 mTBExtnContentWidget = new HbListWidget(); |
|
561 mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); |
565 mTBExtnContentWidget->addItem(LOC_PHOTO); |
562 mTBExtnContentWidget->addItem(LOC_PHOTO); |
566 mTBExtnContentWidget->addItem(LOC_SOUND); |
563 mTBExtnContentWidget->addItem(LOC_SOUND); |
567 mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD); |
564 mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD); |
568 |
565 |
569 HbListViewItem *prototype = mTBExtnContentWidget->listItemPrototype(); |
566 HbListViewItem *prototype = mTBExtnContentWidget->listItemPrototype(); |
577 |
574 |
578 attachExtension->setContentWidget(mTBExtnContentWidget); |
575 attachExtension->setContentWidget(mTBExtnContentWidget); |
579 |
576 |
580 //Add Action to the toolbar and show toolbar |
577 //Add Action to the toolbar and show toolbar |
581 mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send())); |
578 mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send())); |
582 |
579 mSendAction->setDisabled(true); |
583 |
580 |
584 setToolBar(toolBar); |
581 setToolBar(toolBar); |
585 } |
582 } |
586 |
583 |
587 void MsgUnifiedEditorView::addSubject() |
584 void MsgUnifiedEditorView::addSubject() |
657 |
654 |
658 HbGroupBox* groupBox = new HbGroupBox(0); |
655 HbGroupBox* groupBox = new HbGroupBox(0); |
659 groupBox->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred); |
656 groupBox->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Preferred); |
660 |
657 |
661 groupBox->setContentWidget(groupWidget); |
658 groupBox->setContentWidget(groupWidget); |
662 groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1)); |
659 groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND); |
663 mMainLayout->insertItem(1,groupBox); |
660 mMainLayout->insertItem(1,groupBox); |
664 connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool))); |
661 connect(groupBox, SIGNAL(toggled(bool)), this, SLOT(updateOtherRecipientCount(bool))); |
665 |
662 |
666 // add subject field too |
663 // add subject field too |
667 addSubject(); |
664 addSubject(); |
690 HbGroupBox* groupBox = qobject_cast<HbGroupBox*>(sender()); |
687 HbGroupBox* groupBox = qobject_cast<HbGroupBox*>(sender()); |
691 if(groupBox) |
688 if(groupBox) |
692 { |
689 { |
693 if(!state) |
690 if(!state) |
694 { |
691 { |
695 groupBox->setHeading(LOC_OTHER_RECIPIENTS(-1)); |
692 groupBox->setHeading(LOC_OTHER_RECIPIENTS_EXPAND); |
696 } |
693 } |
697 else |
694 else |
698 { |
695 { |
699 int addrCount = mCcField->addressCount(); |
696 int addrCount = mCcField->addressCount(); |
700 addrCount += mBccField->addressCount(); |
697 addrCount += mBccField->addressCount(); |
701 groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount)); |
698 if(addrCount > 0) |
|
699 { |
|
700 groupBox->setHeading(LOC_OTHER_RECIPIENTS(addrCount)); |
|
701 } |
702 } |
702 } |
703 } |
703 } |
704 } |
704 } |
705 |
705 |
706 void MsgUnifiedEditorView::changePriority() |
706 void MsgUnifiedEditorView::changePriority() |
716 |
716 |
717 addSubject(); |
717 addSubject(); |
718 mSubjectField->setPriority(priority); |
718 mSubjectField->setPriority(priority); |
719 } |
719 } |
720 |
720 |
721 void MsgUnifiedEditorView::sendingOptions() |
|
722 { |
|
723 } |
|
724 |
|
725 void MsgUnifiedEditorView::deleteMessage() |
721 void MsgUnifiedEditorView::deleteMessage() |
726 { |
722 { |
727 HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this,SLOT(onDialogDeleteMsg(HbAction*)), |
723 HbMessageBox::question(LOC_NOTE_DELETE_MESSAGE,this, |
728 LOC_BUTTON_DELETE, LOC_BUTTON_CANCEL); |
724 SLOT(onDialogDeleteMsg(HbAction*)), |
|
725 HbMessageBox::Delete | HbMessageBox::Cancel); |
729 } |
726 } |
730 |
727 |
731 void MsgUnifiedEditorView::removeAttachmentContainer() |
728 void MsgUnifiedEditorView::removeAttachmentContainer() |
732 { |
729 { |
733 if(mAttachmentContainer) |
730 if(mAttachmentContainer) |
756 } |
753 } |
757 } |
754 } |
758 |
755 |
759 int MsgUnifiedEditorView::addAttachment(const QString& filepath) |
756 int MsgUnifiedEditorView::addAttachment(const QString& filepath) |
760 { |
757 { |
|
758 // do nothing if filepath is empty |
|
759 if(filepath.isEmpty()) |
|
760 { |
|
761 return MsgAttachmentContainer::EAddSuccess; |
|
762 } |
|
763 |
761 if(!mAttachmentContainer) |
764 if(!mAttachmentContainer) |
762 { |
765 { |
763 mAttachmentContainer = new MsgAttachmentContainer( mContentWidget); |
766 mAttachmentContainer = new MsgAttachmentContainer( mContentWidget); |
764 connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()), |
767 connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()), |
765 this, SLOT(removeAttachmentContainer())); |
768 this, SLOT(removeAttachmentContainer())); |
914 if(sendResult == KErrNotFound) |
917 if(sendResult == KErrNotFound) |
915 { |
918 { |
916 if (messageType == ConvergedMessage::Sms) |
919 if (messageType == ConvergedMessage::Sms) |
917 { |
920 { |
918 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, |
921 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, |
919 this,SLOT(onDialogSmsSettings(HbAction*)), |
922 this,SLOT(onDialogSmsSettings(HbAction*)), |
920 LOC_DIALOG_OK, |
923 HbMessageBox::Ok | HbMessageBox::Cancel); |
921 LOC_BUTTON_CANCEL); |
|
922 } |
924 } |
923 else |
925 else |
924 { |
926 { |
925 HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE, |
927 HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE, |
926 this,SLOT(onDialogMmsSettings(HbAction*)), |
928 this,SLOT(onDialogMmsSettings(HbAction*)), |
927 LOC_DIALOG_OK, |
929 HbMessageBox::Ok | HbMessageBox::Cancel); |
928 LOC_BUTTON_CANCEL); |
|
929 } |
930 } |
930 } |
931 } |
931 } |
932 } |
932 } |
933 } |
933 |
934 |
940 bool removeDuplicates = !isSave; |
941 bool removeDuplicates = !isSave; |
941 ConvergedMessageAddressList addresses = |
942 ConvergedMessageAddressList addresses = |
942 mToField->addresses(removeDuplicates); |
943 mToField->addresses(removeDuplicates); |
943 ConvergedMessageAddressList ccAddresses; |
944 ConvergedMessageAddressList ccAddresses; |
944 ConvergedMessageAddressList bccAddresses; |
945 ConvergedMessageAddressList bccAddresses; |
945 |
946 |
|
947 //Don't format the addresses for save to drfats case |
|
948 if(!isSave) |
|
949 { |
|
950 formatAddresses(addresses); |
|
951 } |
|
952 |
946 msg.addToRecipients(addresses); |
953 msg.addToRecipients(addresses); |
947 msg.setBodyText(mBody->text()); |
954 msg.setBodyText(mBody->text()); |
948 msg.setDirection(ConvergedMessage::Outgoing); |
955 msg.setDirection(ConvergedMessage::Outgoing); |
949 QDateTime time = QDateTime::currentDateTime(); |
956 QDateTime time = QDateTime::currentDateTime(); |
950 msg.setTimeStamp(time.toTime_t()); |
957 msg.setTimeStamp(time.toTime_t()); |
999 } |
1006 } |
1000 } |
1007 } |
1001 |
1008 |
1002 if(ccAddresses.count()>0) |
1009 if(ccAddresses.count()>0) |
1003 { |
1010 { |
|
1011 //Don't format the addresses for save to drfats case |
|
1012 if(!isSave) |
|
1013 { |
|
1014 formatAddresses(ccAddresses); |
|
1015 } |
1004 msg.addCcRecipients(ccAddresses); |
1016 msg.addCcRecipients(ccAddresses); |
1005 } |
1017 } |
1006 if(bccAddresses.count()>0) |
1018 if(bccAddresses.count()>0) |
1007 { |
1019 { |
|
1020 //Don't format the addresses for save to drfats case |
|
1021 if(!isSave) |
|
1022 { |
|
1023 formatAddresses(bccAddresses); |
|
1024 } |
1008 msg.addBccRecipients(bccAddresses); |
1025 msg.addBccRecipients(bccAddresses); |
1009 } |
1026 } |
1010 if(mSubjectField) |
1027 if(mSubjectField) |
1011 { |
1028 { |
1012 msg.setSubject(mSubjectField->text()); |
1029 msg.setSubject(mSubjectField->text()); |
1658 if(mSendAction->isEnabled() != enable ) |
1675 if(mSendAction->isEnabled() != enable ) |
1659 mSendAction->setEnabled(enable); |
1676 mSendAction->setEnabled(enable); |
1660 } |
1677 } |
1661 } |
1678 } |
1662 |
1679 |
|
1680 // ---------------------------------------------------------------------------- |
|
1681 // MsgUnifiedEditorView::formatAddresses |
|
1682 // @see header |
|
1683 // ---------------------------------------------------------------------------- |
|
1684 void MsgUnifiedEditorView::formatAddresses( |
|
1685 ConvergedMessageAddressList& addresses) |
|
1686 { |
|
1687 |
|
1688 for(int i=0; i < addresses.count() ;i++ ) |
|
1689 { |
|
1690 QString addr = addresses[i]->address(); |
|
1691 |
|
1692 HBufC *tempAddr = XQConversions::qStringToS60Desc(addr); |
|
1693 |
|
1694 TPtr ptr = tempAddr->Des(); |
|
1695 |
|
1696 // Note: This is just to parse spaces etc away from phonenumbers. |
|
1697 // Ignore EFalse returned for email addresses. |
|
1698 CommonPhoneParser::ParsePhoneNumber(ptr , |
|
1699 CommonPhoneParser::ESMSNumber ); |
|
1700 |
|
1701 addr = XQConversions::s60DescToQString(tempAddr->Des()); |
|
1702 |
|
1703 addresses[i]->setAddress(addr); |
|
1704 |
|
1705 delete tempAddr; |
|
1706 } |
|
1707 } |
1663 //EOF |
1708 //EOF |