34 #include <HbFrameBackground> |
34 #include <HbFrameBackground> |
35 #include <HbListViewItem> |
35 #include <HbListViewItem> |
36 #include <HbListWidgetItem> |
36 #include <HbListWidgetItem> |
37 #include <HbNotificationDialog> |
37 #include <HbNotificationDialog> |
38 #include <HbMessageBox> |
38 #include <HbMessageBox> |
|
39 #include <HbAbstractVkbHost> |
|
40 #include <HbMainWindow> |
39 #include <xqaiwrequest.h> |
41 #include <xqaiwrequest.h> |
40 #include <xqappmgr.h> |
42 #include <xqappmgr.h> |
41 |
43 #include <HbStyleLoader> |
42 // QT Mobility for fetching business card |
44 // QT Mobility for fetching business card |
|
45 #include <qmobilityglobal.h> |
43 #include <qversitwriter.h> |
46 #include <qversitwriter.h> |
44 #include <qversitdocument.h> |
47 #include <qversitdocument.h> |
45 #include <qcontact.h> |
48 #include <qcontact.h> |
46 #include <qcontactmanager.h> |
49 #include <qcontactmanager.h> |
47 #include <qversitcontactexporter.h> |
50 #include <qversitcontactexporter.h> |
48 #include <cntservicescontact.h> |
51 #include <cntservicescontact.h> |
|
52 |
49 |
53 |
50 // USER INCLUDES |
54 // USER INCLUDES |
51 #include "debugtraces.h" |
55 #include "debugtraces.h" |
52 #include "msgunieditorview.h" |
56 #include "msgunieditorview.h" |
53 #include "msgunieditoraddress.h" |
57 #include "msgunieditoraddress.h" |
107 #define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
113 #define LOC_NOTE_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
108 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
114 #define LOC_BUTTON_DELETE hbTrId("txt_common_button_delete") |
109 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
115 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
110 #define LOC_DIALOG_OK hbTrId("txt_common_button_ok") |
116 #define LOC_DIALOG_OK hbTrId("txt_common_button_ok") |
111 |
117 |
|
118 // attachment addition failure note |
|
119 #define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2") |
|
120 |
112 //extension list item frame. |
121 //extension list item frame. |
113 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
122 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
114 |
123 |
|
124 //settings confirmation |
|
125 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_settings_incomplete") |
|
126 #define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_settings_incomplete") |
115 // LOCAL FUNCTIONS |
127 // LOCAL FUNCTIONS |
116 QString editorTempPath(); |
128 |
|
129 //--------------------------------------------------------------- |
|
130 // editorTempPath |
|
131 // @return fullPath of unified editor's temporary dir |
|
132 //--------------------------------------------------------------- |
|
133 QString editorTempPath() |
|
134 { |
|
135 QDir tempDir; |
|
136 QString tempPath(QDir::toNativeSeparators(tempDir.tempPath())); |
|
137 tempPath.append(QDir::separator()); |
|
138 tempPath.append(UNIFIED_EDITOR_TEMP_FOLDER); |
|
139 tempPath.append(QDir::separator()); |
|
140 return tempPath; |
|
141 } |
117 |
142 |
118 //--------------------------------------------------------------- |
143 //--------------------------------------------------------------- |
119 // MsgUnifiedEditorView::MsgUnifiedEditorView |
144 // MsgUnifiedEditorView::MsgUnifiedEditorView |
120 // @see header file |
145 // @see header file |
121 //--------------------------------------------------------------- |
146 //--------------------------------------------------------------- |
131 mBody(0), |
156 mBody(0), |
132 mContentWidget(0), |
157 mContentWidget(0), |
133 mMsgMonitor(0), |
158 mMsgMonitor(0), |
134 mAttachmentContainer(0), |
159 mAttachmentContainer(0), |
135 mPluginLoader(0), |
160 mPluginLoader(0), |
136 mCanSaveToDrafts(true) |
161 mCanSaveToDrafts(true), |
137 { |
162 mVkbHost(NULL) |
138 addMenu(); |
163 { |
|
164 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
|
165 |
139 addToolBar(); |
166 addToolBar(); |
140 |
167 initView(); |
|
168 } |
|
169 |
|
170 //--------------------------------------------------------------- |
|
171 // MsgUnifiedEditorView::~MsgUnifiedEditorView |
|
172 // @see header file |
|
173 //--------------------------------------------------------------- |
|
174 MsgUnifiedEditorView::~MsgUnifiedEditorView() |
|
175 { |
|
176 // clean editor's temporary contents before exiting |
|
177 removeTempFolder(); |
|
178 } |
|
179 |
|
180 //--------------------------------------------------------------- |
|
181 // MsgUnifiedEditorView::initView |
|
182 // @see header file |
|
183 //--------------------------------------------------------------- |
|
184 void MsgUnifiedEditorView::initView() |
|
185 { |
|
186 if (!HbStyleLoader::registerFilePath(":/layouts")) { |
|
187 QDEBUG_WRITE("ERROR: MsgUnifiedEditorView -> HbStyleLoader::registerFilePath"); |
|
188 } |
141 HbScrollArea* scrollArea = new HbScrollArea(this); |
189 HbScrollArea* scrollArea = new HbScrollArea(this); |
142 this->setWidget(scrollArea); |
190 this->setWidget(scrollArea); |
143 |
191 |
144 mContentWidget = new HbWidget(this); |
192 mContentWidget = new HbWidget(this); |
145 scrollArea->setContentWidget(mContentWidget); |
193 scrollArea->setContentWidget(mContentWidget); |
146 |
|
147 mPluginPath = pluginPath(); |
|
148 |
194 |
149 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget); |
195 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget); |
150 qreal vTopSpacing = 0.0; |
196 qreal vTopSpacing = 0.0; |
151 qreal vItemSpacing = 0.0; |
197 qreal vItemSpacing = 0.0; |
152 style()->parameter("hb-param-margin-gene-top",vTopSpacing); |
198 style()->parameter("hb-param-margin-gene-top",vTopSpacing); |
155 mMainLayout->setContentsMargins(0,vTopSpacing,0,0); |
201 mMainLayout->setContentsMargins(0,vTopSpacing,0,0); |
156 mMainLayout->setSpacing(vItemSpacing); |
202 mMainLayout->setSpacing(vItemSpacing); |
157 |
203 |
158 mMsgMonitor = new MsgMonitor(this); |
204 mMsgMonitor = new MsgMonitor(this); |
159 |
205 |
160 mToField = new MsgUnifiedEditorAddress( LOC_TO, mPluginPath, mContentWidget ); |
206 mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget ); |
161 mBody = new MsgUnifiedEditorBody(mPluginPath, mContentWidget); |
207 |
|
208 mBody = new MsgUnifiedEditorBody( mContentWidget); |
162 |
209 |
163 mMainLayout->addItem(mToField); |
210 mMainLayout->addItem(mToField); |
164 mMainLayout->addItem(mBody); |
211 mMainLayout->addItem(mBody); |
165 |
212 |
166 //Set the invalid msg id |
213 //Set the invalid msg id |
167 mOpenedMessageId.setId(-1); |
214 mOpenedMessageId.setId(-1); |
168 |
215 |
169 // create editor's temp folder |
|
170 QDir tempDir = QDir(QString()); |
|
171 QString tempPath(editorTempPath()); |
|
172 if(tempDir.mkpath(tempPath)) |
|
173 { |
|
174 tempDir.cd(tempPath); |
|
175 // remove stale folder content when freshly launched |
|
176 QStringList contentList(tempDir.entryList()); |
|
177 int contentCount = contentList.count(); |
|
178 for(int i=0; i<contentCount; i++) |
|
179 { |
|
180 tempDir.remove(contentList.at(i)); |
|
181 } |
|
182 } |
|
183 |
|
184 connect(mToField, SIGNAL(sendMessage()), this, SLOT(send())); |
216 connect(mToField, SIGNAL(sendMessage()), this, SLOT(send())); |
|
217 connect(mToField, SIGNAL(contentChanged()), |
|
218 mMsgMonitor, SLOT(handleContentChange())); |
|
219 connect(mToField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
|
220 |
185 connect(mBody, SIGNAL(sendMessage()), this, SLOT(send())); |
221 connect(mBody, SIGNAL(sendMessage()), this, SLOT(send())); |
|
222 connect(mBody, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
186 connect(mBody, SIGNAL(contentChanged()), |
223 connect(mBody, SIGNAL(contentChanged()), |
187 mMsgMonitor, SLOT(checkMsgTypeChange())); |
224 mMsgMonitor, SLOT(handleContentChange())); |
188 } |
225 |
189 |
|
190 //--------------------------------------------------------------- |
|
191 // MsgUnifiedEditorView::~MsgUnifiedEditorView |
|
192 // @see header file |
|
193 //--------------------------------------------------------------- |
|
194 MsgUnifiedEditorView::~MsgUnifiedEditorView() |
|
195 { |
|
196 // clean editor's temporary contents before exiting |
|
197 QDir tempDir = QDir(QString()); |
|
198 QString tempPath(editorTempPath()); |
|
199 tempDir.cd(tempPath); |
|
200 QStringList contentList(tempDir.entryList()); |
|
201 int contentCount = contentList.count(); |
|
202 for(int i=0; i<contentCount; i++) |
|
203 { |
|
204 tempDir.remove(contentList.at(i)); |
|
205 } |
|
206 tempDir.cdUp(); |
|
207 tempDir.rmdir(UNIFIED_EDITOR_TEMP_FOLDER); |
|
208 } |
226 } |
209 |
227 |
210 void MsgUnifiedEditorView::addMenu() |
228 void MsgUnifiedEditorView::addMenu() |
211 { |
229 { |
212 //Create Menu Options |
230 //Create Menu Options |
213 HbMenu* mainMenu = new HbMenu(); |
231 HbMenu* mainMenu = new HbMenu(); |
214 |
232 mainMenu->setFocusPolicy(Qt::NoFocus); |
215 //TODO:These 2 should be submenu option to Add |
233 |
216 mSubjectAction = mainMenu->addAction(LOC_ADD_SUBJECT); |
234 //if subject field / cc,bcc fields are already present don't add corresponding actions. |
217 mCcBccAction = mainMenu->addAction(LOC_ADD_CC_BCC); |
235 if(!mSubjectField) |
|
236 { |
|
237 mSubjectAction = mainMenu->addAction(LOC_ADD_SUBJECT); |
|
238 } |
|
239 |
|
240 if(!mCcField) |
|
241 { |
|
242 mCcBccAction = mainMenu->addAction(LOC_ADD_CC_BCC); |
|
243 } |
218 |
244 |
219 HbMenu* prioritySubMenu = mainMenu->addMenu(LOC_PRIORITY); |
245 HbMenu* prioritySubMenu = mainMenu->addMenu(LOC_PRIORITY); |
220 |
246 |
221 HbAction* highPriorityAction = prioritySubMenu->addAction(LOC_HIGH); |
247 HbAction* highPriorityAction = prioritySubMenu->addAction(LOC_HIGH); |
222 highPriorityAction->setData(ConvergedMessage::High); |
248 highPriorityAction->setData(ConvergedMessage::High); |
353 } |
377 } |
354 |
378 |
355 // additional common operations for non-forwarded messages |
379 // additional common operations for non-forwarded messages |
356 if(editorOp != MsgBaseView::FORWARD_MSG) |
380 if(editorOp != MsgBaseView::FORWARD_MSG) |
357 { |
381 { |
358 mToField->setAddresses(messageDetails->toAddressList()); |
382 if(editorOp == MsgBaseView::ADD_RECIPIENTS) |
|
383 { |
|
384 // CV sends contact card address as the first address |
|
385 ConvergedMessageAddressList toAddresses = |
|
386 messageDetails->toAddressList(); |
|
387 int addrCount = toAddresses.count(); |
|
388 if(addrCount > 0) |
|
389 { |
|
390 // add contact card address first |
|
391 ConvergedMessageAddress *firstAddress = |
|
392 new ConvergedMessageAddress(); |
|
393 firstAddress->setAlias(toAddresses.at(0)->alias()); |
|
394 firstAddress->setAddress(toAddresses.at(0)->address()); |
|
395 ConvergedMessageAddressList firstList; |
|
396 firstList << firstAddress; |
|
397 mToField->setAddresses(firstList); |
|
398 |
|
399 // add remaining contacts now |
|
400 ConvergedMessageAddressList otherList; |
|
401 for(int i=1; i<addrCount; i++) |
|
402 { |
|
403 otherList << toAddresses.at(i); |
|
404 } |
|
405 mToField->setAddresses(otherList); |
|
406 } |
|
407 } |
|
408 else |
|
409 { |
|
410 mToField->setAddresses(messageDetails->toAddressList()); |
|
411 } |
359 QString bodyTxt = messageDetails->bodyText(); |
412 QString bodyTxt = messageDetails->bodyText(); |
360 mBody->setText(bodyTxt); |
413 mBody->setText(bodyTxt); |
361 |
414 |
362 int attachmentCount = messageDetails->attachments().count(); |
415 int attachmentCount = messageDetails->attachments().count(); |
363 QStringList pendingAttList; |
416 QStringList pendingAttList; |
517 //tool bar extension for attach action. |
557 //tool bar extension for attach action. |
518 HbToolBarExtension* attachExtension = new HbToolBarExtension(); |
558 HbToolBarExtension* attachExtension = new HbToolBarExtension(); |
519 HbAction *attachAction = toolBar->addExtension(attachExtension); |
559 HbAction *attachAction = toolBar->addExtension(attachExtension); |
520 attachAction->setIcon(HbIcon(ATTACH_ICON)); |
560 attachAction->setIcon(HbIcon(ATTACH_ICON)); |
521 |
561 |
522 HbListWidget* extnList = new HbListWidget(); |
562 mTBExtnContentWidget = new HbListWidget(); |
523 extnList->addItem(LOC_PHOTO); |
563 mTBExtnContentWidget->addItem(LOC_PHOTO); |
524 extnList->addItem(LOC_SOUND); |
564 mTBExtnContentWidget->addItem(LOC_SOUND); |
525 extnList->addItem(LOC_BUSINESS_CARD); |
565 mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD); |
526 |
566 |
527 HbListViewItem *prototype = extnList->listItemPrototype(); |
567 HbListViewItem *prototype = mTBExtnContentWidget->listItemPrototype(); |
528 HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
568 HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
529 prototype->setDefaultFrame(frame); |
569 prototype->setDefaultFrame(frame); |
530 |
570 |
531 connect(extnList, SIGNAL(activated(HbListWidgetItem*)), this, |
571 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
532 SLOT(handleViewExtnActivated(HbListWidgetItem*))); |
572 this, SLOT(handleViewExtnActivated(HbListWidgetItem*))); |
533 connect(extnList, SIGNAL(activated(HbListWidgetItem*)), attachExtension, SLOT(close())); |
573 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
534 |
574 attachExtension, SLOT(close())); |
535 attachExtension->setContentWidget(extnList); |
575 |
|
576 attachExtension->setContentWidget(mTBExtnContentWidget); |
536 |
577 |
537 //Add Action to the toolbar and show toolbar |
578 //Add Action to the toolbar and show toolbar |
538 toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send())); |
579 toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send())); |
539 |
580 |
540 |
581 |
545 { |
586 { |
546 if(mSubjectField) |
587 if(mSubjectField) |
547 { // do nothing if already present |
588 { // do nothing if already present |
548 return; |
589 return; |
549 } |
590 } |
550 // remove mainmenu's "Add Subject" action |
|
551 HbMenu* mainMenu = this->menu(); |
|
552 mainMenu->removeAction(mSubjectAction); |
|
553 mSubjectAction->setParent(NULL); |
|
554 delete mSubjectAction; |
|
555 |
591 |
556 int index =0; |
592 int index =0; |
557 int offset = 1; |
593 int offset = 1; |
558 if(mAttachmentContainer) |
594 if(mAttachmentContainer) |
559 { |
595 { |
560 ++offset; |
596 ++offset; |
561 } |
597 } |
562 index = mMainLayout->count() - offset; |
598 index = mMainLayout->count() - offset; |
563 |
599 |
564 mSubjectField = new MsgUnifiedEditorSubject(mPluginPath, mContentWidget); |
600 mSubjectField = new MsgUnifiedEditorSubject( mContentWidget); |
|
601 |
565 mMainLayout->insertItem(index,mSubjectField); |
602 mMainLayout->insertItem(index,mSubjectField); |
566 connect(mSubjectField, SIGNAL(contentChanged()), |
603 connect(mSubjectField, SIGNAL(contentChanged()), |
567 mMsgMonitor, SLOT(checkMsgTypeChange())); |
604 mMsgMonitor, SLOT(handleContentChange())); |
|
605 connect(mSubjectField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
|
606 |
|
607 //set focus to subject field. |
|
608 HbAction* subjectAction = qobject_cast<HbAction*>(this->sender()); |
|
609 if(subjectAction) |
|
610 { |
|
611 setFocus(mSubjectField); |
|
612 } |
|
613 |
|
614 // remove mainmenu's "Add Subject" action |
|
615 if(mSubjectAction) |
|
616 { |
|
617 HbMenu* mainMenu = this->menu(); |
|
618 mainMenu->removeAction(mSubjectAction); |
|
619 mSubjectAction->setParent(NULL); |
|
620 delete mSubjectAction; |
|
621 } |
568 } |
622 } |
569 |
623 |
570 void MsgUnifiedEditorView::addCcBcc() |
624 void MsgUnifiedEditorView::addCcBcc() |
571 { |
625 { |
572 if(mCcField && mBccField) |
626 if(mCcField && mBccField) |
573 { // do nothing if already present |
627 { // do nothing if already present |
574 return; |
628 return; |
575 } |
629 } |
576 |
630 |
577 // remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions |
631 mCcField = new MsgUnifiedEditorAddress( LOC_CC, mContentWidget ); |
578 HbMenu* mainmenu = this->menu(); |
632 mBccField = new MsgUnifiedEditorAddress( LOC_BCC, mContentWidget ); |
579 mainmenu->removeAction(mCcBccAction); |
633 mCcField->skipMaxRecipientQuery(true); |
580 mCcBccAction->setParent(NULL); |
634 mBccField->skipMaxRecipientQuery(true); |
581 delete mCcBccAction; |
|
582 |
|
583 mCcField = new MsgUnifiedEditorAddress( LOC_CC, mPluginPath, mContentWidget ); |
|
584 mBccField = new MsgUnifiedEditorAddress( LOC_BCC, mPluginPath, mContentWidget ); |
|
585 |
635 |
586 connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send())); |
636 connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send())); |
587 connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(checkMsgTypeChange())); |
637 connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange())); |
|
638 connect(mCcField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
|
639 |
588 connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send())); |
640 connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send())); |
589 connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(checkMsgTypeChange())); |
641 connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange())); |
|
642 connect(mBccField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
590 |
643 |
591 HbWidget* groupWidget = new HbWidget(mContentWidget); |
644 HbWidget* groupWidget = new HbWidget(mContentWidget); |
592 groupWidget->setContentsMargins(0,0,0,0); |
645 groupWidget->setContentsMargins(0,0,0,0); |
593 |
646 |
594 QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget); |
647 QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget); |
698 { |
741 { |
699 int fcount = files.count(); |
742 int fcount = files.count(); |
700 int i=0; |
743 int i=0; |
701 for(i=0; i<fcount; i++) |
744 for(i=0; i<fcount; i++) |
702 { |
745 { |
703 if(MsgAttachmentContainer::EAddSizeExceed |
746 int status = addAttachment(files.at(i)); |
704 == addAttachment(files.at(i))) |
747 if(status == MsgAttachmentContainer::EAddSizeExceed) |
705 { |
748 { |
706 // size already exceeds max mms size-limit |
749 QString displayStr = QString(LOC_UNABLE_TO_ADD_ATTACHMENTS) |
|
750 .arg(fcount-i).arg(fcount); |
|
751 HbNotificationDialog::launchDialog(displayStr); |
707 break; |
752 break; |
708 } |
753 } |
709 } |
754 } |
710 // check if some files failed to add |
|
711 // happens only when size exceeded during addition |
|
712 if(i<fcount) |
|
713 { |
|
714 // TODO: show a note for size exceed |
|
715 } |
|
716 } |
755 } |
717 |
756 |
718 int MsgUnifiedEditorView::addAttachment(const QString& filepath) |
757 int MsgUnifiedEditorView::addAttachment(const QString& filepath) |
719 { |
758 { |
720 if(!mAttachmentContainer) |
759 if(!mAttachmentContainer) |
721 { |
760 { |
722 mAttachmentContainer = new MsgAttachmentContainer(mPluginPath, mContentWidget); |
761 mAttachmentContainer = new MsgAttachmentContainer( mContentWidget); |
723 connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()), |
762 connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()), |
724 this, SLOT(removeAttachmentContainer())); |
763 this, SLOT(removeAttachmentContainer())); |
725 connect(mAttachmentContainer, SIGNAL(contentChanged()), |
764 connect(mAttachmentContainer, SIGNAL(contentChanged()), |
726 mMsgMonitor, SLOT(checkMsgTypeChange())); |
765 mMsgMonitor, SLOT(handleContentChange())); |
|
766 connect(mAttachmentContainer, SIGNAL(contentChanged()), |
|
767 this,SLOT(onContentChanged())); |
|
768 |
727 int index = mMainLayout->count() - 1; |
769 int index = mMainLayout->count() - 1; |
728 mMainLayout->insertItem(index,mAttachmentContainer); |
770 mMainLayout->insertItem(index,mAttachmentContainer); |
729 } |
771 } |
730 |
772 |
731 int ret = mAttachmentContainer->addAttachment(filepath); |
773 int ret = mAttachmentContainer->addAttachment(filepath); |
735 if(mAttachmentContainer->count() == 0) |
777 if(mAttachmentContainer->count() == 0) |
736 { |
778 { |
737 removeAttachmentContainer(); |
779 removeAttachmentContainer(); |
738 } |
780 } |
739 } |
781 } |
740 else if(mAttachmentContainer->hasMMContent()) |
|
741 { |
|
742 // when msg is converted to MMS, subject needs to be auto-inserted |
|
743 addSubject(); |
|
744 } |
|
745 return ret; |
782 return ret; |
746 } |
783 } |
747 |
784 |
748 QString MsgUnifiedEditorView::pluginPath() |
|
749 { |
|
750 QString pluginPath; |
|
751 #ifdef Q_OS_WIN |
|
752 #define PLUGINPATH "../unifiededitorplugin/debug/unifiededitorplugind.dll" |
|
753 #endif |
|
754 #ifdef Q_OS_SYMBIAN |
|
755 #define PLUGINPATH "unifiededitorplugin.dll" |
|
756 #endif |
|
757 pluginPath.append(PLUGINPATH); |
|
758 return pluginPath; |
|
759 } |
|
760 |
|
761 void MsgUnifiedEditorView::send() |
785 void MsgUnifiedEditorView::send() |
762 { |
786 { |
763 activateInputBlocker(); |
787 activateInputBlocker(); |
|
788 |
|
789 // first run the address validation tests |
|
790 if( !mToField->validateContacts() || |
|
791 (mCcField && !mCcField->validateContacts()) || |
|
792 (mBccField && !mBccField->validateContacts()) ) |
|
793 { |
|
794 deactivateInputBlocker(); |
|
795 return; |
|
796 } |
764 |
797 |
765 // converged msg for sending |
798 // converged msg for sending |
766 ConvergedMessage msg; |
799 ConvergedMessage msg; |
767 ConvergedMessage::MessageType messageType = MsgMonitor::messageType(); |
800 ConvergedMessage::MessageType messageType = MsgMonitor::messageType(); |
768 msg.setMessageType(messageType); |
801 msg.setMessageType(messageType); |
769 |
802 |
770 ConvergedMessageAddressList addresses = mToField->addresses(); |
803 // we need to remove duplicate addresses |
|
804 bool removeDuplicates = true; |
|
805 ConvergedMessageAddressList addresses = |
|
806 mToField->addresses(removeDuplicates); |
771 if(messageType == ConvergedMessage::Sms && |
807 if(messageType == ConvergedMessage::Sms && |
772 addresses.isEmpty()) |
808 addresses.isEmpty()) |
773 { |
809 { |
774 // no recipient specified for sms, do not send msg |
810 // no recipient specified for sms, do not send msg |
775 deactivateInputBlocker(); |
811 deactivateInputBlocker(); |
871 else |
909 else |
872 { |
910 { |
873 deactivateInputBlocker(); |
911 deactivateInputBlocker(); |
874 if(sendResult == KErrNotFound) |
912 if(sendResult == KErrNotFound) |
875 { |
913 { |
876 bool result = HbMessageBox::question("Settings not defined\nDefine now ?", |
914 if (messageType == ConvergedMessage::Sms) |
877 LOC_DIALOG_OK, |
|
878 LOC_BUTTON_CANCEL); |
|
879 if (result) |
|
880 { |
915 { |
881 QVariantList params; |
916 HbMessageBox::question(LOC_DIALOG_SMS_SETTINGS_INCOMPLETE, |
882 params << MsgBaseView::MSGSETTINGS;// target view |
917 this,SLOT(onDialogSmsSettings(HbAction*)), |
883 params << MsgBaseView::UNIEDITOR; // source view |
918 LOC_DIALOG_OK, |
884 emit switchView(params); |
919 LOC_BUTTON_CANCEL); |
885 } |
920 } |
886 } |
921 else |
887 } |
922 { |
888 } |
923 HbMessageBox::question(LOC_DIALOG_MMS_SETTINGS_INCOMPLETE, |
889 |
924 this,SLOT(onDialogMmsSettings(HbAction*)), |
890 void MsgUnifiedEditorView::packMessage(ConvergedMessage &msg) |
925 LOC_DIALOG_OK, |
|
926 LOC_BUTTON_CANCEL); |
|
927 } |
|
928 } |
|
929 } |
|
930 } |
|
931 |
|
932 void MsgUnifiedEditorView::packMessage(ConvergedMessage &msg, bool isSave) |
891 { |
933 { |
892 ConvergedMessage::MessageType messageType = MsgMonitor::messageType(); |
934 ConvergedMessage::MessageType messageType = MsgMonitor::messageType(); |
893 msg.setMessageType(messageType); |
935 msg.setMessageType(messageType); |
894 |
936 // If isSave is true (save to draft usecase), then don't remove duplicates |
895 ConvergedMessageAddressList addresses = mToField->addresses(); |
937 // If isSave is false (send usecase), then remove duplicates |
|
938 bool removeDuplicates = !isSave; |
|
939 ConvergedMessageAddressList addresses = |
|
940 mToField->addresses(removeDuplicates); |
896 ConvergedMessageAddressList ccAddresses; |
941 ConvergedMessageAddressList ccAddresses; |
897 ConvergedMessageAddressList bccAddresses; |
942 ConvergedMessageAddressList bccAddresses; |
898 |
943 |
899 msg.addToRecipients(addresses); |
944 msg.addToRecipients(addresses); |
900 msg.setBodyText(mBody->text()); |
945 msg.setBodyText(mBody->text()); |
904 |
949 |
905 if(messageType == ConvergedMessage::Mms) |
950 if(messageType == ConvergedMessage::Mms) |
906 { |
951 { |
907 if(mCcField) |
952 if(mCcField) |
908 { |
953 { |
909 ccAddresses = mCcField->addresses(); |
954 ccAddresses = mCcField->addresses(removeDuplicates); |
910 } |
955 } |
911 |
956 |
912 if(mBccField) |
957 if(mBccField) |
913 { |
958 { |
914 bccAddresses = mBccField->addresses(); |
959 bccAddresses = mBccField->addresses(removeDuplicates); |
915 } |
960 } |
916 |
961 |
917 int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits(); |
962 if(removeDuplicates) |
918 //comapre cc and to field,remove duplicate from cc |
963 { |
919 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
964 int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits(); |
920 { |
965 //comapre cc and to field,remove duplicate from cc |
921 foreach(ConvergedMessageAddress *toAddress,addresses) |
966 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
922 { |
967 { |
923 if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
968 foreach(ConvergedMessageAddress *toAddress,addresses) |
924 { |
969 { |
925 ccAddresses.removeOne(ccAddress); |
970 if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
926 } |
971 { |
927 } |
972 ccAddresses.removeOne(ccAddress); |
928 } |
973 } |
929 //comapre bcc and cc field,remove duplicate from bcc |
974 } |
930 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
975 } |
931 { |
976 //comapre bcc and cc field,remove duplicate from bcc |
932 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
977 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
933 { |
978 { |
934 if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount))) |
979 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
935 { |
980 { |
936 bccAddresses.removeOne(bccAddress); |
981 if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount))) |
937 } |
982 { |
938 } |
983 bccAddresses.removeOne(bccAddress); |
939 } |
984 } |
940 //comapre bcc and to field,remove duplicate from bcc |
985 } |
941 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
986 } |
942 { |
987 //comapre bcc and to field,remove duplicate from bcc |
943 foreach(ConvergedMessageAddress *toAddress,addresses) |
988 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
944 { |
989 { |
945 if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
990 foreach(ConvergedMessageAddress *toAddress,addresses) |
946 { |
991 { |
947 bccAddresses.removeOne(bccAddress); |
992 if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
948 } |
993 { |
949 } |
994 bccAddresses.removeOne(bccAddress); |
|
995 } |
|
996 } |
|
997 } |
950 } |
998 } |
951 |
999 |
952 if(ccAddresses.count()>0) |
1000 if(ccAddresses.count()>0) |
953 { |
1001 { |
954 msg.addCcRecipients(ccAddresses); |
1002 msg.addCcRecipients(ccAddresses); |
1111 |
1159 |
1112 mContentWidget->resize(this->rect().width(),this->rect().height()+1); |
1160 mContentWidget->resize(this->rect().width(),this->rect().height()+1); |
1113 } |
1161 } |
1114 |
1162 |
1115 //--------------------------------------------------------------- |
1163 //--------------------------------------------------------------- |
1116 // editorTempPath |
|
1117 // @return fullPath of unified editor's temporary dir |
|
1118 //--------------------------------------------------------------- |
|
1119 QString editorTempPath() |
|
1120 { |
|
1121 QDir tempDir = QDir(QString()); |
|
1122 QString tempPath(QDir::toNativeSeparators(tempDir.tempPath())); |
|
1123 tempPath.append(QDir::separator()); |
|
1124 tempPath.append(UNIFIED_EDITOR_TEMP_FOLDER); |
|
1125 tempPath.append(QDir::separator()); |
|
1126 return tempPath; |
|
1127 } |
|
1128 |
|
1129 //--------------------------------------------------------------- |
|
1130 // MsgUnifiedEditorView::createVCards |
1164 // MsgUnifiedEditorView::createVCards |
1131 // @see header file |
1165 // @see header file |
1132 //--------------------------------------------------------------- |
1166 //--------------------------------------------------------------- |
1133 int MsgUnifiedEditorView::createVCards( |
1167 int MsgUnifiedEditorView::createVCards( |
1134 const QVariant& value, QStringList& filelist) |
1168 const QVariant& value, QStringList& filelist) |
1135 { |
1169 { |
1136 // make sure that temp-folder is created for storing vcards |
1170 // make sure that temp-folder is created for storing vcards |
1137 QDir tempDir = QDir(QString()); |
1171 if(!createTempFolder()) |
1138 if(!tempDir.mkpath(editorTempPath())) |
|
1139 { |
1172 { |
1140 return KErrGeneral; |
1173 return KErrGeneral; |
1141 } |
1174 } |
1142 tempDir.cd(editorTempPath()); |
|
1143 |
|
1144 |
1175 |
1145 // extract contact-list |
1176 // extract contact-list |
1146 QContactManager* contactManager = new QContactManager("symbian"); |
1177 QContactManager* contactManager = new QContactManager("symbian"); |
1147 CntServicesContactList cntServicesContacts = qVariantValue<CntServicesContactList>(value); |
1178 CntServicesContactList cntServicesContacts = qVariantValue<CntServicesContactList>(value); |
1148 int cntCount = cntServicesContacts.count(); |
1179 int cntCount = cntServicesContacts.count(); |
1328 QString interface("Image"); |
1359 QString interface("Image"); |
1329 QString operation("fetch(QVariantMap,QVariant)"); |
1360 QString operation("fetch(QVariantMap,QVariant)"); |
1330 XQAiwRequest* request = NULL; |
1361 XQAiwRequest* request = NULL; |
1331 XQApplicationManager appManager; |
1362 XQApplicationManager appManager; |
1332 request = appManager.create(interface, operation, true);//embedded |
1363 request = appManager.create(interface, operation, true);//embedded |
|
1364 request->setSynchronous(true); // synchronous |
1333 if(!request) |
1365 if(!request) |
1334 { |
1366 { |
1335 QCRITICAL_WRITE("AIW-ERROR: NULL request"); |
1367 QCRITICAL_WRITE("AIW-ERROR: NULL request"); |
1336 return; |
1368 return; |
1337 } |
1369 } |
1338 |
1370 |
1339 connect(request, SIGNAL(requestOk(const QVariant&)), |
1371 connect(request, SIGNAL(requestOk(const QVariant&)), |
1340 this, SLOT(imagesFetched(const QVariant&))); |
1372 this, SLOT(imagesFetched(const QVariant&))); |
1341 connect(request, SIGNAL(requestError(int,const QString&)), |
1373 connect(request, SIGNAL(requestError(int,const QString&)), |
1342 this, SLOT(serviceRequestError(int,const QString&))); |
1374 this, SLOT(serviceRequestError(int,const QString&))); |
1343 |
1375 |
|
1376 // Set arguments for request |
|
1377 QList<QVariant> args; |
|
1378 args << QVariantMap(); |
|
1379 args << QVariant(); |
|
1380 request->setArguments(args); |
1344 // Make the request |
1381 // Make the request |
1345 if (!request->send()) |
1382 if (!request->send()) |
1346 { |
1383 { |
1347 QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError()); |
1384 QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError()); |
1348 } |
1385 } |
1443 //--------------------------------------------------------------- |
1479 //--------------------------------------------------------------- |
1444 // MsgUnifiedEditorView::activateInputBlocker |
1480 // MsgUnifiedEditorView::activateInputBlocker |
1445 // @see header file |
1481 // @see header file |
1446 //-------------------------------------------------------------- |
1482 //-------------------------------------------------------------- |
1447 void MsgUnifiedEditorView::activateInputBlocker() |
1483 void MsgUnifiedEditorView::activateInputBlocker() |
1448 { |
1484 { |
1449 this->grabMouse(); |
1485 this->grabMouse(); |
1450 this->grabKeyboard(); |
1486 this->grabKeyboard(); |
1451 } |
1487 } |
1452 |
1488 |
1453 //--------------------------------------------------------------- |
1489 //--------------------------------------------------------------- |
1454 // MsgUnifiedEditorView::deactivateInputBlocker |
1490 // MsgUnifiedEditorView::deactivateInputBlocker |
1455 // @see header file |
1491 // @see header file |
1456 //-------------------------------------------------------------- |
1492 //-------------------------------------------------------------- |
1457 void MsgUnifiedEditorView::deactivateInputBlocker() |
1493 void MsgUnifiedEditorView::deactivateInputBlocker() |
1458 { |
1494 { |
1459 this->ungrabKeyboard(); |
1495 this->ungrabKeyboard(); |
1460 this->ungrabMouse(); |
1496 this->ungrabMouse(); |
1461 } |
1497 } |
|
1498 |
|
1499 //--------------------------------------------------------------- |
|
1500 // MsgUnifiedEditorView::setAttachOptionEnabled |
|
1501 // @see header file |
|
1502 //-------------------------------------------------------------- |
|
1503 void MsgUnifiedEditorView::setAttachOptionEnabled( |
|
1504 MsgUnifiedEditorView::TBE_AttachOption opt, bool enable) |
|
1505 { |
|
1506 HbListWidgetItem* wgtItem = mTBExtnContentWidget->item(opt); |
|
1507 wgtItem->setEnabled(enable); |
|
1508 } |
|
1509 |
|
1510 //--------------------------------------------------------------- |
|
1511 // MsgUnifiedEditorView::vkbOpened |
|
1512 // @see header file |
|
1513 //--------------------------------------------------------------- |
|
1514 void MsgUnifiedEditorView::vkbOpened() |
|
1515 { |
|
1516 hideChrome(true); |
|
1517 |
|
1518 disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
|
1519 } |
|
1520 |
|
1521 //--------------------------------------------------------------- |
|
1522 // MsgUnifiedEditorView::vkbClosed |
|
1523 // @see header file |
|
1524 //--------------------------------------------------------------- |
|
1525 void MsgUnifiedEditorView::vkbClosed() |
|
1526 { |
|
1527 hideChrome(false); |
|
1528 |
|
1529 connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
|
1530 } |
|
1531 |
|
1532 //--------------------------------------------------------------- |
|
1533 // MsgUnifiedEditorView::hideChrome |
|
1534 // |
|
1535 //--------------------------------------------------------------- |
|
1536 void MsgUnifiedEditorView::hideChrome(bool hide) |
|
1537 { |
|
1538 if(hide) |
|
1539 { |
|
1540 this->setContentFullScreen(true); |
|
1541 this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem); |
|
1542 } |
|
1543 else |
|
1544 { |
|
1545 this->setContentFullScreen(false); |
|
1546 this->showItems(Hb::StatusBarItem | Hb::TitleBarItem); |
|
1547 } |
|
1548 } |
|
1549 |
|
1550 //--------------------------------------------------------------- |
|
1551 // MsgUnifiedEditorView::doDelayedConstruction |
|
1552 // |
|
1553 //--------------------------------------------------------------- |
|
1554 void MsgUnifiedEditorView::doDelayedConstruction() |
|
1555 { |
|
1556 addMenu(); |
|
1557 createTempFolder(); |
|
1558 |
|
1559 //Create VKB instance and listen to VKB open and close signals. |
|
1560 mVkbHost = new HbAbstractVkbHost(this); |
|
1561 connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened())); |
|
1562 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed())); |
|
1563 |
|
1564 disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
|
1565 |
|
1566 } |
|
1567 |
|
1568 //--------------------------------------------------------------- |
|
1569 // MsgUnifiedEditorView::createTempFolder |
|
1570 // |
|
1571 //--------------------------------------------------------------- |
|
1572 bool MsgUnifiedEditorView::createTempFolder() |
|
1573 { |
|
1574 // create editor's temp folder |
|
1575 QDir tempDir; |
|
1576 QString tempPath(editorTempPath()); |
|
1577 bool result = tempDir.mkpath(tempPath); |
|
1578 return result; |
|
1579 } |
|
1580 |
|
1581 //--------------------------------------------------------------- |
|
1582 // MsgUnifiedEditorView::removeTempFolder |
|
1583 // |
|
1584 //--------------------------------------------------------------- |
|
1585 void MsgUnifiedEditorView::removeTempFolder() |
|
1586 { |
|
1587 QDir tempDir; |
|
1588 QString tempPath(editorTempPath()); |
|
1589 tempDir.cd(tempPath); |
|
1590 QStringList contentList(tempDir.entryList()); |
|
1591 |
|
1592 int contentCount = contentList.count(); |
|
1593 for(int i=0; i<contentCount; i++) |
|
1594 { |
|
1595 tempDir.remove(contentList.at(i)); |
|
1596 } |
|
1597 |
|
1598 tempDir.cdUp(); |
|
1599 tempDir.rmdir(UNIFIED_EDITOR_TEMP_FOLDER); |
|
1600 } |
|
1601 |
|
1602 //--------------------------------------------------------------- |
|
1603 // MsgUnifiedEditorView::setFocus |
|
1604 // |
|
1605 //--------------------------------------------------------------- |
|
1606 void MsgUnifiedEditorView::setFocus(MsgUnifiedEditorBaseWidget* item) |
|
1607 { |
|
1608 if(item) |
|
1609 { |
|
1610 item->setFocus(); |
|
1611 } |
|
1612 } |
|
1613 |
|
1614 //--------------------------------------------------------------- |
|
1615 // MsgUnifiedEditorView::onContentChanged |
|
1616 // |
|
1617 //--------------------------------------------------------------- |
|
1618 void MsgUnifiedEditorView::onContentChanged() |
|
1619 { |
|
1620 mCanSaveToDrafts = true; |
|
1621 } |
|
1622 |
|
1623 //--------------------------------------------------------------- |
|
1624 // MsgUnifiedEditorView::onDialogDeleteMsg |
|
1625 //--------------------------------------------------------------- |
|
1626 void MsgUnifiedEditorView::onDialogDeleteMsg(HbAction* action) |
|
1627 { |
|
1628 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1629 if (action == dlg->actions().at(0)) { |
|
1630 |
|
1631 mCanSaveToDrafts = false; |
|
1632 |
|
1633 //delete if draft entry opened |
|
1634 if (mOpenedMessageId.getId() != -1) { |
|
1635 if (!mPluginLoader) { |
|
1636 mPluginLoader = new UniEditorPluginLoader(this); |
|
1637 } |
|
1638 |
|
1639 UniEditorPluginInterface* pluginInterface = mPluginLoader->getUniEditorPlugin( |
|
1640 MsgMonitor::messageType()); |
|
1641 |
|
1642 pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId()); |
|
1643 } |
|
1644 |
|
1645 //trigger back action. |
|
1646 HbAction* backAction = this->navigationAction(); |
|
1647 if (backAction) { |
|
1648 backAction->trigger(); |
|
1649 } |
|
1650 |
|
1651 } |
|
1652 } |
|
1653 |
|
1654 //--------------------------------------------------------------- |
|
1655 // MsgUnifiedEditorView::onDialogSmsSettings |
|
1656 //--------------------------------------------------------------- |
|
1657 void MsgUnifiedEditorView::onDialogSmsSettings(HbAction* action) |
|
1658 { |
|
1659 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1660 if (action == dlg->actions().at(0)) { |
|
1661 |
|
1662 QVariantList params; |
|
1663 params << MsgBaseView::MSGSETTINGS;// target view |
|
1664 params << MsgBaseView::UNIEDITOR; // source view |
|
1665 params << MsgSettingsView::SMSView; |
|
1666 emit switchView(params); |
|
1667 |
|
1668 } |
|
1669 } |
|
1670 |
|
1671 //--------------------------------------------------------------- |
|
1672 // MsgUnifiedEditorView::onDialogMmsSettings |
|
1673 //--------------------------------------------------------------- |
|
1674 void MsgUnifiedEditorView::onDialogMmsSettings(HbAction* action) |
|
1675 { |
|
1676 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1677 if (action == dlg->actions().at(0)) { |
|
1678 |
|
1679 QVariantList params; |
|
1680 params << MsgBaseView::MSGSETTINGS;// target view |
|
1681 params << MsgBaseView::UNIEDITOR; // source view |
|
1682 params << MsgSettingsView::MMSView; |
|
1683 emit switchView(params); |
|
1684 } |
|
1685 } |
1462 |
1686 |
1463 //EOF |
1687 //EOF |