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> |
49 |
52 |
|
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" |
54 #include "msgunieditorsubject.h" |
58 #include "msgunieditorsubject.h" |
55 #include "msgunieditorbody.h" |
59 #include "msgunieditorbody.h" |
56 #include "msgmonitor.h" |
60 #include "msgunieditormonitor.h" |
57 #include "msgattachmentcontainer.h" |
61 #include "msgunieditorattachmentcontainer.h" |
58 #include "msgsendutil.h" |
62 #include "msgsendutil.h" |
59 #include "convergedmessageaddress.h" |
63 #include "convergedmessageaddress.h" |
60 #include "unieditorgenutils.h" |
64 #include "UniEditorGenUtils.h" |
61 #include "unieditorpluginloader.h" |
65 #include "unieditorpluginloader.h" |
62 #include "unieditorplugininterface.h" |
66 #include "unieditorplugininterface.h" |
63 |
67 #include "msgsettingsview.h" |
|
68 |
|
69 QTM_USE_NAMESPACE |
64 // Constants |
70 // Constants |
65 const QString SEND_ICON("qtg_mono_send"); |
71 const QString SEND_ICON("qtg_mono_send"); |
66 const QString ATTACH_ICON("qtg_mono_attach"); |
72 const QString ATTACH_ICON("qtg_mono_attach"); |
67 // temporary folder for unieditor |
73 // temporary folder for unieditor |
68 const QString UNIFIED_EDITOR_TEMP_FOLDER("unifiededitor"); |
74 const QString UNIFIED_EDITOR_TEMP_FOLDER("unifiededitor"); |
86 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_button_business_card") |
92 #define LOC_BUSINESS_CARD hbTrId("txt_messaging_button_business_card") |
87 |
93 |
88 //options menu. |
94 //options menu. |
89 #define LOC_ADD_SUBJECT hbTrId("txt_messaging_opt_add_subject") |
95 #define LOC_ADD_SUBJECT hbTrId("txt_messaging_opt_add_subject") |
90 #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") |
91 #define LOC_PRIORITY hbTrId("txt_messaging_setlabel_priority") |
97 #define LOC_PRIORITY hbTrId("txt_messaging_opt_priority") |
92 #define LOC_SENDING_OPTIONS hbTrId("txt_messaging_opt_sending_options") |
|
93 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_opt_delete_message") |
98 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_opt_delete_message") |
94 |
99 |
95 //priority sub menu |
100 //priority sub menu |
96 #define LOC_HIGH hbTrId("txt_messaging_setlabel_priority_val_high") |
101 #define LOC_HIGH hbTrId("txt_messaging_opt_attach_sub_high") |
97 #define LOC_NORMAL hbTrId("txt_messaging_setlabel_priority_val_normal") |
102 #define LOC_NORMAL hbTrId("txt_messaging_opt_attach_sub_normal") |
98 #define LOC_LOW hbTrId("txt_messaging_setlabel_priority_val_low") |
103 #define LOC_LOW hbTrId("txt_messaging_opt_attach_sub_low") |
99 |
104 |
100 //group box |
105 //group box |
101 #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") |
102 |
108 |
103 //saved to draft note |
109 //saved to draft note |
104 #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") |
105 |
111 |
106 //delete confermation |
112 //delete confermation |
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 |
109 #define LOC_BUTTON_CANCEL hbTrId("txt_common_button_cancel") |
115 // attachment addition failure note |
110 #define LOC_DIALOG_OK hbTrId("txt_common_button_ok") |
116 #define LOC_UNABLE_TO_ADD_ATTACHMENTS hbTrId("txt_messaging_dpopinfo_unable_to_attach_l1_of_l2") |
111 |
117 |
112 //extension list item frame. |
118 //extension list item frame. |
113 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
119 const QString POPUP_LIST_FRAME("qtg_fr_popup_list_normal"); |
114 |
120 |
|
121 //settings confirmation |
|
122 #define LOC_DIALOG_SMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_sms_message_centre_does_not_e") |
|
123 #define LOC_DIALOG_MMS_SETTINGS_INCOMPLETE hbTrId("txt_messaging_dialog_mms_access_point_not_defined") |
115 // LOCAL FUNCTIONS |
124 // LOCAL FUNCTIONS |
116 QString editorTempPath(); |
125 |
|
126 //--------------------------------------------------------------- |
|
127 // editorTempPath |
|
128 // @return fullPath of unified editor's temporary dir |
|
129 //--------------------------------------------------------------- |
|
130 QString editorTempPath() |
|
131 { |
|
132 QDir tempDir; |
|
133 QString tempPath(QDir::toNativeSeparators(tempDir.tempPath())); |
|
134 tempPath.append(QDir::separator()); |
|
135 tempPath.append(UNIFIED_EDITOR_TEMP_FOLDER); |
|
136 tempPath.append(QDir::separator()); |
|
137 return tempPath; |
|
138 } |
117 |
139 |
118 //--------------------------------------------------------------- |
140 //--------------------------------------------------------------- |
119 // MsgUnifiedEditorView::MsgUnifiedEditorView |
141 // MsgUnifiedEditorView::MsgUnifiedEditorView |
120 // @see header file |
142 // @see header file |
121 //--------------------------------------------------------------- |
143 //--------------------------------------------------------------- |
122 MsgUnifiedEditorView::MsgUnifiedEditorView( QGraphicsItem *parent ) : |
144 MsgUnifiedEditorView::MsgUnifiedEditorView( QGraphicsItem *parent ) : |
123 MsgBaseView(parent), |
145 MsgBaseView(parent), |
124 mSubjectAction(0), |
146 mSubjectAction(0), |
125 mCcBccAction(0), |
147 mCcBccAction(0), |
|
148 mSendAction(0), |
126 mMainLayout(0), |
149 mMainLayout(0), |
127 mSubjectField(0), |
150 mSubjectField(0), |
128 mToField(0), |
151 mToField(0), |
129 mCcField(0), |
152 mCcField(0), |
130 mBccField(0), |
153 mBccField(0), |
131 mBody(0), |
154 mBody(0), |
132 mContentWidget(0), |
155 mContentWidget(0), |
133 mMsgMonitor(0), |
156 mMsgMonitor(0), |
134 mAttachmentContainer(0), |
157 mAttachmentContainer(0), |
135 mPluginLoader(0), |
158 mPluginLoader(0), |
136 mCanSaveToDrafts(true) |
159 mCanSaveToDrafts(true), |
137 { |
160 mVkbHost(NULL) |
138 addMenu(); |
161 { |
|
162 connect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
|
163 |
139 addToolBar(); |
164 addToolBar(); |
140 |
165 initView(); |
|
166 } |
|
167 |
|
168 //--------------------------------------------------------------- |
|
169 // MsgUnifiedEditorView::~MsgUnifiedEditorView |
|
170 // @see header file |
|
171 //--------------------------------------------------------------- |
|
172 MsgUnifiedEditorView::~MsgUnifiedEditorView() |
|
173 { |
|
174 // clean editor's temporary contents before exiting |
|
175 removeTempFolder(); |
|
176 } |
|
177 |
|
178 //--------------------------------------------------------------- |
|
179 // MsgUnifiedEditorView::initView |
|
180 // @see header file |
|
181 //--------------------------------------------------------------- |
|
182 void MsgUnifiedEditorView::initView() |
|
183 { |
|
184 if (!HbStyleLoader::registerFilePath(":/layouts")) { |
|
185 QDEBUG_WRITE("ERROR: MsgUnifiedEditorView -> HbStyleLoader::registerFilePath"); |
|
186 } |
141 HbScrollArea* scrollArea = new HbScrollArea(this); |
187 HbScrollArea* scrollArea = new HbScrollArea(this); |
142 this->setWidget(scrollArea); |
188 this->setWidget(scrollArea); |
143 |
189 |
144 mContentWidget = new HbWidget(this); |
190 mContentWidget = new HbWidget(this); |
145 scrollArea->setContentWidget(mContentWidget); |
191 scrollArea->setContentWidget(mContentWidget); |
146 |
|
147 mPluginPath = pluginPath(); |
|
148 |
192 |
149 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget); |
193 mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, mContentWidget); |
150 qreal vTopSpacing = 0.0; |
194 qreal vTopSpacing = 0.0; |
151 qreal vItemSpacing = 0.0; |
195 qreal vItemSpacing = 0.0; |
152 style()->parameter("hb-param-margin-gene-top",vTopSpacing); |
196 style()->parameter("hb-param-margin-gene-top",vTopSpacing); |
153 style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing); |
197 style()->parameter("hb-param-margin-gene-middle-vertical",vItemSpacing); |
154 |
198 |
155 mMainLayout->setContentsMargins(0,vTopSpacing,0,0); |
199 mMainLayout->setContentsMargins(0,vTopSpacing,0,0); |
156 mMainLayout->setSpacing(vItemSpacing); |
200 mMainLayout->setSpacing(vItemSpacing); |
157 |
201 |
158 mMsgMonitor = new MsgMonitor(this); |
202 mMsgMonitor = new MsgUnifiedEditorMonitor(this); |
159 |
203 connect(mMsgMonitor, SIGNAL(enableSend(bool)), this, SLOT(enableSendButton(bool))); |
160 mToField = new MsgUnifiedEditorAddress( LOC_TO, mPluginPath, mContentWidget ); |
204 |
161 mBody = new MsgUnifiedEditorBody(mPluginPath, mContentWidget); |
205 mToField = new MsgUnifiedEditorAddress( LOC_TO, mContentWidget ); |
|
206 |
|
207 mBody = new MsgUnifiedEditorBody( mContentWidget); |
162 |
208 |
163 mMainLayout->addItem(mToField); |
209 mMainLayout->addItem(mToField); |
164 mMainLayout->addItem(mBody); |
210 mMainLayout->addItem(mBody); |
165 |
211 |
166 //Set the invalid msg id |
212 //Set the invalid msg id |
167 mOpenedMessageId.setId(-1); |
213 mOpenedMessageId.setId(-1); |
168 |
214 |
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())); |
215 connect(mToField, SIGNAL(sendMessage()), this, SLOT(send())); |
|
216 connect(mToField, SIGNAL(contentChanged()), |
|
217 mMsgMonitor, SLOT(handleContentChange())); |
|
218 connect(mToField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
|
219 |
185 connect(mBody, SIGNAL(sendMessage()), this, SLOT(send())); |
220 connect(mBody, SIGNAL(sendMessage()), this, SLOT(send())); |
|
221 connect(mBody, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
186 connect(mBody, SIGNAL(contentChanged()), |
222 connect(mBody, SIGNAL(contentChanged()), |
187 mMsgMonitor, SLOT(checkMsgTypeChange())); |
223 mMsgMonitor, SLOT(handleContentChange())); |
188 } |
224 connect(mBody, SIGNAL(enableSendButton(bool)), this, SLOT(enableSendButton(bool))); |
189 |
225 |
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); |
225 normalPriorityAction->setData(ConvergedMessage::Normal); |
251 normalPriorityAction->setData(ConvergedMessage::Normal); |
226 |
252 |
227 HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW); |
253 HbAction* lowPriorityAction = prioritySubMenu->addAction(LOC_LOW); |
228 lowPriorityAction->setData(ConvergedMessage::Low); |
254 lowPriorityAction->setData(ConvergedMessage::Low); |
229 |
255 |
230 HbAction* sendOptionsAction = mainMenu->addAction(LOC_SENDING_OPTIONS); |
|
231 HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE); |
256 HbAction* deleteMsgAction = mainMenu->addAction(LOC_DELETE_MESSAGE); |
232 |
257 |
233 connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject())); |
258 connect(mSubjectAction,SIGNAL(triggered()),this, SLOT(addSubject())); |
234 connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc())); |
259 connect(mCcBccAction,SIGNAL(triggered()),this, SLOT(addCcBcc())); |
235 connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
260 connect(highPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
236 connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
261 connect(normalPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
237 connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
262 connect(lowPriorityAction, SIGNAL(triggered()), this, SLOT(changePriority())); |
238 connect(sendOptionsAction,SIGNAL(triggered()),this, SLOT(sendingOptions())); |
|
239 connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage())); |
263 connect(deleteMsgAction,SIGNAL(triggered()),this, SLOT(deleteMessage())); |
240 |
264 |
241 setMenu(mainMenu); |
265 setMenu(mainMenu); |
242 } |
266 } |
243 |
267 |
517 //tool bar extension for attach action. |
555 //tool bar extension for attach action. |
518 HbToolBarExtension* attachExtension = new HbToolBarExtension(); |
556 HbToolBarExtension* attachExtension = new HbToolBarExtension(); |
519 HbAction *attachAction = toolBar->addExtension(attachExtension); |
557 HbAction *attachAction = toolBar->addExtension(attachExtension); |
520 attachAction->setIcon(HbIcon(ATTACH_ICON)); |
558 attachAction->setIcon(HbIcon(ATTACH_ICON)); |
521 |
559 |
522 HbListWidget* extnList = new HbListWidget(); |
560 mTBExtnContentWidget = new HbListWidget(); |
523 extnList->addItem(LOC_PHOTO); |
561 mTBExtnContentWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed); |
524 extnList->addItem(LOC_SOUND); |
562 mTBExtnContentWidget->addItem(LOC_PHOTO); |
525 extnList->addItem(LOC_BUSINESS_CARD); |
563 mTBExtnContentWidget->addItem(LOC_SOUND); |
526 |
564 mTBExtnContentWidget->addItem(LOC_BUSINESS_CARD); |
527 HbListViewItem *prototype = extnList->listItemPrototype(); |
565 |
|
566 HbListViewItem *prototype = mTBExtnContentWidget->listItemPrototype(); |
528 HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
567 HbFrameBackground frame(POPUP_LIST_FRAME, HbFrameDrawer::NinePieces); |
529 prototype->setDefaultFrame(frame); |
568 prototype->setDefaultFrame(frame); |
530 |
569 |
531 connect(extnList, SIGNAL(activated(HbListWidgetItem*)), this, |
570 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
532 SLOT(handleViewExtnActivated(HbListWidgetItem*))); |
571 this, SLOT(handleViewExtnActivated(HbListWidgetItem*))); |
533 connect(extnList, SIGNAL(activated(HbListWidgetItem*)), attachExtension, SLOT(close())); |
572 connect(mTBExtnContentWidget, SIGNAL(activated(HbListWidgetItem*)), |
534 |
573 attachExtension, SLOT(close())); |
535 attachExtension->setContentWidget(extnList); |
574 |
|
575 attachExtension->setContentWidget(mTBExtnContentWidget); |
536 |
576 |
537 //Add Action to the toolbar and show toolbar |
577 //Add Action to the toolbar and show toolbar |
538 toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send())); |
578 mSendAction = toolBar->addAction(HbIcon(SEND_ICON),QString(),this,SLOT(send())); |
539 |
579 mSendAction->setDisabled(true); |
540 |
580 |
541 setToolBar(toolBar); |
581 setToolBar(toolBar); |
542 } |
582 } |
543 |
583 |
544 void MsgUnifiedEditorView::addSubject() |
584 void MsgUnifiedEditorView::addSubject() |
545 { |
585 { |
546 if(mSubjectField) |
586 if(mSubjectField) |
547 { // do nothing if already present |
587 { // do nothing if already present |
548 return; |
588 return; |
549 } |
589 } |
550 // remove mainmenu's "Add Subject" action |
|
551 HbMenu* mainMenu = this->menu(); |
|
552 mainMenu->removeAction(mSubjectAction); |
|
553 mSubjectAction->setParent(NULL); |
|
554 delete mSubjectAction; |
|
555 |
590 |
556 int index =0; |
591 int index =0; |
557 int offset = 1; |
592 int offset = 1; |
558 if(mAttachmentContainer) |
593 if(mAttachmentContainer) |
559 { |
594 { |
560 ++offset; |
595 ++offset; |
561 } |
596 } |
562 index = mMainLayout->count() - offset; |
597 index = mMainLayout->count() - offset; |
563 |
598 |
564 mSubjectField = new MsgUnifiedEditorSubject(mPluginPath, mContentWidget); |
599 mSubjectField = new MsgUnifiedEditorSubject( mContentWidget); |
|
600 |
565 mMainLayout->insertItem(index,mSubjectField); |
601 mMainLayout->insertItem(index,mSubjectField); |
566 connect(mSubjectField, SIGNAL(contentChanged()), |
602 connect(mSubjectField, SIGNAL(contentChanged()), |
567 mMsgMonitor, SLOT(checkMsgTypeChange())); |
603 mMsgMonitor, SLOT(handleContentChange())); |
|
604 connect(mSubjectField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
|
605 |
|
606 //set focus to subject field. |
|
607 HbAction* subjectAction = qobject_cast<HbAction*>(this->sender()); |
|
608 if(subjectAction) |
|
609 { |
|
610 setFocus(mSubjectField); |
|
611 } |
|
612 |
|
613 // remove mainmenu's "Add Subject" action |
|
614 if(mSubjectAction) |
|
615 { |
|
616 HbMenu* mainMenu = this->menu(); |
|
617 mainMenu->removeAction(mSubjectAction); |
|
618 mSubjectAction->setParent(NULL); |
|
619 delete mSubjectAction; |
|
620 } |
568 } |
621 } |
569 |
622 |
570 void MsgUnifiedEditorView::addCcBcc() |
623 void MsgUnifiedEditorView::addCcBcc() |
571 { |
624 { |
572 if(mCcField && mBccField) |
625 if(mCcField && mBccField) |
573 { // do nothing if already present |
626 { // do nothing if already present |
574 return; |
627 return; |
575 } |
628 } |
576 |
629 |
577 // remove mainmenu's "Add Cc/Bcc" & "Add Subject" actions |
630 mCcField = new MsgUnifiedEditorAddress( LOC_CC, mContentWidget ); |
578 HbMenu* mainmenu = this->menu(); |
631 mBccField = new MsgUnifiedEditorAddress( LOC_BCC, mContentWidget ); |
579 mainmenu->removeAction(mCcBccAction); |
632 mCcField->skipMaxRecipientQuery(true); |
580 mCcBccAction->setParent(NULL); |
633 mBccField->skipMaxRecipientQuery(true); |
581 delete mCcBccAction; |
|
582 |
|
583 mCcField = new MsgUnifiedEditorAddress( LOC_CC, mPluginPath, mContentWidget ); |
|
584 mBccField = new MsgUnifiedEditorAddress( LOC_BCC, mPluginPath, mContentWidget ); |
|
585 |
634 |
586 connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send())); |
635 connect(mCcField, SIGNAL(sendMessage()), this, SLOT(send())); |
587 connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(checkMsgTypeChange())); |
636 connect(mCcField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange())); |
|
637 connect(mCcField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
|
638 |
588 connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send())); |
639 connect(mBccField, SIGNAL(sendMessage()), this, SLOT(send())); |
589 connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(checkMsgTypeChange())); |
640 connect(mBccField, SIGNAL(contentChanged()), mMsgMonitor, SLOT(handleContentChange())); |
|
641 connect(mBccField, SIGNAL(contentChanged()),this,SLOT(onContentChanged())); |
590 |
642 |
591 HbWidget* groupWidget = new HbWidget(mContentWidget); |
643 HbWidget* groupWidget = new HbWidget(mContentWidget); |
592 groupWidget->setContentsMargins(0,0,0,0); |
644 groupWidget->setContentsMargins(0,0,0,0); |
593 |
645 |
594 QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget); |
646 QGraphicsLinearLayout* ccBccLayout = new QGraphicsLinearLayout(Qt::Vertical, groupWidget); |
698 { |
740 { |
699 int fcount = files.count(); |
741 int fcount = files.count(); |
700 int i=0; |
742 int i=0; |
701 for(i=0; i<fcount; i++) |
743 for(i=0; i<fcount; i++) |
702 { |
744 { |
703 if(MsgAttachmentContainer::EAddSizeExceed |
745 int status = addAttachment(files.at(i)); |
704 == addAttachment(files.at(i))) |
746 if(status == MsgAttachmentContainer::EAddSizeExceed) |
705 { |
747 { |
706 // size already exceeds max mms size-limit |
748 QString displayStr = QString(LOC_UNABLE_TO_ADD_ATTACHMENTS) |
|
749 .arg(fcount-i).arg(fcount); |
|
750 HbNotificationDialog::launchDialog(displayStr); |
707 break; |
751 break; |
708 } |
752 } |
709 } |
753 } |
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 } |
754 } |
717 |
755 |
718 int MsgUnifiedEditorView::addAttachment(const QString& filepath) |
756 int MsgUnifiedEditorView::addAttachment(const QString& filepath) |
719 { |
757 { |
|
758 // do nothing if filepath is empty |
|
759 if(filepath.isEmpty()) |
|
760 { |
|
761 return MsgAttachmentContainer::EAddSuccess; |
|
762 } |
|
763 |
720 if(!mAttachmentContainer) |
764 if(!mAttachmentContainer) |
721 { |
765 { |
722 mAttachmentContainer = new MsgAttachmentContainer(mPluginPath, mContentWidget); |
766 mAttachmentContainer = new MsgAttachmentContainer( mContentWidget); |
723 connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()), |
767 connect(mAttachmentContainer, SIGNAL(emptyAttachmentContainer()), |
724 this, SLOT(removeAttachmentContainer())); |
768 this, SLOT(removeAttachmentContainer())); |
725 connect(mAttachmentContainer, SIGNAL(contentChanged()), |
769 connect(mAttachmentContainer, SIGNAL(contentChanged()), |
726 mMsgMonitor, SLOT(checkMsgTypeChange())); |
770 mMsgMonitor, SLOT(handleContentChange())); |
|
771 connect(mAttachmentContainer, SIGNAL(contentChanged()), |
|
772 this,SLOT(onContentChanged())); |
|
773 |
727 int index = mMainLayout->count() - 1; |
774 int index = mMainLayout->count() - 1; |
728 mMainLayout->insertItem(index,mAttachmentContainer); |
775 mMainLayout->insertItem(index,mAttachmentContainer); |
729 } |
776 } |
730 |
777 |
731 int ret = mAttachmentContainer->addAttachment(filepath); |
778 int ret = mAttachmentContainer->addAttachment(filepath); |
904 |
952 |
905 if(messageType == ConvergedMessage::Mms) |
953 if(messageType == ConvergedMessage::Mms) |
906 { |
954 { |
907 if(mCcField) |
955 if(mCcField) |
908 { |
956 { |
909 ccAddresses = mCcField->addresses(); |
957 ccAddresses = mCcField->addresses(removeDuplicates); |
910 } |
958 } |
911 |
959 |
912 if(mBccField) |
960 if(mBccField) |
913 { |
961 { |
914 bccAddresses = mBccField->addresses(); |
962 bccAddresses = mBccField->addresses(removeDuplicates); |
915 } |
963 } |
916 |
964 |
917 int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits(); |
965 if(removeDuplicates) |
918 //comapre cc and to field,remove duplicate from cc |
966 { |
919 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
967 int matchDigitsCount = MsgUnifiedEditorAddress::contactMatchDigits(); |
920 { |
968 //comapre cc and to field,remove duplicate from cc |
921 foreach(ConvergedMessageAddress *toAddress,addresses) |
969 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
922 { |
970 { |
923 if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
971 foreach(ConvergedMessageAddress *toAddress,addresses) |
924 { |
972 { |
925 ccAddresses.removeOne(ccAddress); |
973 if(0 == ccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
926 } |
974 { |
927 } |
975 ccAddresses.removeOne(ccAddress); |
928 } |
976 } |
929 //comapre bcc and cc field,remove duplicate from bcc |
977 } |
930 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
978 } |
931 { |
979 //comapre bcc and cc field,remove duplicate from bcc |
932 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
980 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
933 { |
981 { |
934 if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount))) |
982 foreach(ConvergedMessageAddress *ccAddress,ccAddresses) |
935 { |
983 { |
936 bccAddresses.removeOne(bccAddress); |
984 if(0 == bccAddress->address().right(matchDigitsCount).compare(ccAddress->address().right(matchDigitsCount))) |
937 } |
985 { |
938 } |
986 bccAddresses.removeOne(bccAddress); |
939 } |
987 } |
940 //comapre bcc and to field,remove duplicate from bcc |
988 } |
941 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
989 } |
942 { |
990 //comapre bcc and to field,remove duplicate from bcc |
943 foreach(ConvergedMessageAddress *toAddress,addresses) |
991 foreach(ConvergedMessageAddress *bccAddress,bccAddresses) |
944 { |
992 { |
945 if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
993 foreach(ConvergedMessageAddress *toAddress,addresses) |
946 { |
994 { |
947 bccAddresses.removeOne(bccAddress); |
995 if(0 == bccAddress->address().right(matchDigitsCount).compare(toAddress->address().right(matchDigitsCount))) |
948 } |
996 { |
949 } |
997 bccAddresses.removeOne(bccAddress); |
|
998 } |
|
999 } |
|
1000 } |
950 } |
1001 } |
951 |
1002 |
952 if(ccAddresses.count()>0) |
1003 if(ccAddresses.count()>0) |
953 { |
1004 { |
954 msg.addCcRecipients(ccAddresses); |
1005 msg.addCcRecipients(ccAddresses); |
1323 // MsgUnifiedEditorView::fetchImages |
1359 // MsgUnifiedEditorView::fetchImages |
1324 // @see header file |
1360 // @see header file |
1325 //--------------------------------------------------------------- |
1361 //--------------------------------------------------------------- |
1326 void MsgUnifiedEditorView::fetchImages() |
1362 void MsgUnifiedEditorView::fetchImages() |
1327 { |
1363 { |
1328 QString interface("Image"); |
1364 QString service("photos"); |
1329 QString operation("fetch(QVariantMap,QVariant)"); |
1365 QString interface("com.nokia.symbian.IImageFetch"); |
|
1366 QString operation("fetch()"); |
1330 XQAiwRequest* request = NULL; |
1367 XQAiwRequest* request = NULL; |
1331 XQApplicationManager appManager; |
1368 XQApplicationManager appManager; |
1332 request = appManager.create(interface, operation, true);//embedded |
1369 request = appManager.create(service,interface, operation, true);//embedded |
|
1370 request->setSynchronous(true); // synchronous |
1333 if(!request) |
1371 if(!request) |
1334 { |
1372 { |
1335 QCRITICAL_WRITE("AIW-ERROR: NULL request"); |
1373 QCRITICAL_WRITE("AIW-ERROR: NULL request"); |
1336 return; |
1374 return; |
1337 } |
1375 } |
1338 |
1376 |
1339 connect(request, SIGNAL(requestOk(const QVariant&)), |
1377 connect(request, SIGNAL(requestOk(const QVariant&)), |
1340 this, SLOT(imagesFetched(const QVariant&))); |
1378 this, SLOT(imagesFetched(const QVariant&))); |
1341 connect(request, SIGNAL(requestError(int,const QString&)), |
1379 connect(request, SIGNAL(requestError(int,const QString&)), |
1342 this, SLOT(serviceRequestError(int,const QString&))); |
1380 this, SLOT(serviceRequestError(int,const QString&))); |
1343 |
1381 |
1344 // Make the request |
1382 // Make the request |
1345 if (!request->send()) |
1383 if (!request->send()) |
1346 { |
1384 { |
1347 QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError()); |
1385 QDEBUG_WRITE_FORMAT("AIW-ERROR: Request Send failed:" , request->lastError()); |
1348 } |
1386 } |
1443 //--------------------------------------------------------------- |
1443 //--------------------------------------------------------------- |
1444 // MsgUnifiedEditorView::activateInputBlocker |
1444 // MsgUnifiedEditorView::activateInputBlocker |
1445 // @see header file |
1445 // @see header file |
1446 //-------------------------------------------------------------- |
1446 //-------------------------------------------------------------- |
1447 void MsgUnifiedEditorView::activateInputBlocker() |
1447 void MsgUnifiedEditorView::activateInputBlocker() |
1448 { |
1448 { |
1449 this->grabMouse(); |
1449 mainWindow()->setInteractive(false); |
1450 this->grabKeyboard(); |
1450 } |
1451 } |
|
1452 |
1451 |
1453 //--------------------------------------------------------------- |
1452 //--------------------------------------------------------------- |
1454 // MsgUnifiedEditorView::deactivateInputBlocker |
1453 // MsgUnifiedEditorView::deactivateInputBlocker |
1455 // @see header file |
1454 // @see header file |
1456 //-------------------------------------------------------------- |
1455 //-------------------------------------------------------------- |
1457 void MsgUnifiedEditorView::deactivateInputBlocker() |
1456 void MsgUnifiedEditorView::deactivateInputBlocker() |
1458 { |
1457 { |
1459 this->ungrabKeyboard(); |
1458 mainWindow()->setInteractive(true); |
1460 this->ungrabMouse(); |
1459 } |
|
1460 |
|
1461 //--------------------------------------------------------------- |
|
1462 // MsgUnifiedEditorView::setAttachOptionEnabled |
|
1463 // @see header file |
|
1464 //-------------------------------------------------------------- |
|
1465 void MsgUnifiedEditorView::setAttachOptionEnabled( |
|
1466 MsgUnifiedEditorView::TBE_AttachOption opt, bool enable) |
|
1467 { |
|
1468 HbListWidgetItem* wgtItem = mTBExtnContentWidget->item(opt); |
|
1469 wgtItem->setEnabled(enable); |
|
1470 } |
|
1471 |
|
1472 //--------------------------------------------------------------- |
|
1473 // MsgUnifiedEditorView::vkbOpened |
|
1474 // @see header file |
|
1475 //--------------------------------------------------------------- |
|
1476 void MsgUnifiedEditorView::vkbOpened() |
|
1477 { |
|
1478 hideChrome(true); |
|
1479 |
|
1480 disconnect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
|
1481 } |
|
1482 |
|
1483 //--------------------------------------------------------------- |
|
1484 // MsgUnifiedEditorView::vkbClosed |
|
1485 // @see header file |
|
1486 //--------------------------------------------------------------- |
|
1487 void MsgUnifiedEditorView::vkbClosed() |
|
1488 { |
|
1489 hideChrome(false); |
|
1490 |
|
1491 connect(mVkbHost,SIGNAL(keypadOpened()),this,SLOT(vkbOpened())); |
|
1492 } |
|
1493 |
|
1494 //--------------------------------------------------------------- |
|
1495 // MsgUnifiedEditorView::hideChrome |
|
1496 // |
|
1497 //--------------------------------------------------------------- |
|
1498 void MsgUnifiedEditorView::hideChrome(bool hide) |
|
1499 { |
|
1500 if(hide) |
|
1501 { |
|
1502 this->setContentFullScreen(true); |
|
1503 this->hideItems(Hb::StatusBarItem | Hb::TitleBarItem); |
|
1504 } |
|
1505 else |
|
1506 { |
|
1507 this->setContentFullScreen(false); |
|
1508 this->showItems(Hb::StatusBarItem | Hb::TitleBarItem); |
|
1509 } |
|
1510 } |
|
1511 |
|
1512 //--------------------------------------------------------------- |
|
1513 // MsgUnifiedEditorView::doDelayedConstruction |
|
1514 // |
|
1515 //--------------------------------------------------------------- |
|
1516 void MsgUnifiedEditorView::doDelayedConstruction() |
|
1517 { |
|
1518 addMenu(); |
|
1519 createTempFolder(); |
|
1520 |
|
1521 //Create VKB instance and listen to VKB open and close signals. |
|
1522 mVkbHost = new HbAbstractVkbHost(this); |
|
1523 connect(mVkbHost, SIGNAL(keypadOpened()), this, SLOT(vkbOpened())); |
|
1524 connect(mVkbHost, SIGNAL(keypadClosed()), this, SLOT(vkbClosed())); |
|
1525 |
|
1526 disconnect(this->mainWindow(),SIGNAL(viewReady()),this,SLOT(doDelayedConstruction())); |
|
1527 |
|
1528 } |
|
1529 |
|
1530 //--------------------------------------------------------------- |
|
1531 // MsgUnifiedEditorView::createTempFolder |
|
1532 // |
|
1533 //--------------------------------------------------------------- |
|
1534 bool MsgUnifiedEditorView::createTempFolder() |
|
1535 { |
|
1536 // create editor's temp folder |
|
1537 QDir tempDir; |
|
1538 QString tempPath(editorTempPath()); |
|
1539 bool result = tempDir.mkpath(tempPath); |
|
1540 return result; |
|
1541 } |
|
1542 |
|
1543 //--------------------------------------------------------------- |
|
1544 // MsgUnifiedEditorView::removeTempFolder |
|
1545 // |
|
1546 //--------------------------------------------------------------- |
|
1547 void MsgUnifiedEditorView::removeTempFolder() |
|
1548 { |
|
1549 QDir tempDir; |
|
1550 QString tempPath(editorTempPath()); |
|
1551 tempDir.cd(tempPath); |
|
1552 QStringList contentList(tempDir.entryList()); |
|
1553 |
|
1554 int contentCount = contentList.count(); |
|
1555 for(int i=0; i<contentCount; i++) |
|
1556 { |
|
1557 tempDir.remove(contentList.at(i)); |
|
1558 } |
|
1559 |
|
1560 tempDir.cdUp(); |
|
1561 tempDir.rmdir(UNIFIED_EDITOR_TEMP_FOLDER); |
|
1562 } |
|
1563 |
|
1564 //--------------------------------------------------------------- |
|
1565 // MsgUnifiedEditorView::setFocus |
|
1566 // |
|
1567 //--------------------------------------------------------------- |
|
1568 void MsgUnifiedEditorView::setFocus(MsgUnifiedEditorBaseWidget* item) |
|
1569 { |
|
1570 if(item) |
|
1571 { |
|
1572 item->setFocus(); |
|
1573 } |
|
1574 } |
|
1575 |
|
1576 //--------------------------------------------------------------- |
|
1577 // MsgUnifiedEditorView::onContentChanged |
|
1578 // |
|
1579 //--------------------------------------------------------------- |
|
1580 void MsgUnifiedEditorView::onContentChanged() |
|
1581 { |
|
1582 mCanSaveToDrafts = true; |
|
1583 } |
|
1584 |
|
1585 //--------------------------------------------------------------- |
|
1586 // MsgUnifiedEditorView::onDialogDeleteMsg |
|
1587 //--------------------------------------------------------------- |
|
1588 void MsgUnifiedEditorView::onDialogDeleteMsg(HbAction* action) |
|
1589 { |
|
1590 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1591 if (action == dlg->actions().at(0)) { |
|
1592 |
|
1593 mCanSaveToDrafts = false; |
|
1594 |
|
1595 //delete if draft entry opened |
|
1596 if (mOpenedMessageId.getId() != -1) { |
|
1597 if (!mPluginLoader) { |
|
1598 mPluginLoader = new UniEditorPluginLoader(this); |
|
1599 } |
|
1600 |
|
1601 UniEditorPluginInterface* pluginInterface = mPluginLoader->getUniEditorPlugin( |
|
1602 MsgUnifiedEditorMonitor::messageType()); |
|
1603 |
|
1604 pluginInterface->deleteDraftsEntry(mOpenedMessageId.getId()); |
|
1605 } |
|
1606 |
|
1607 //trigger back action. |
|
1608 HbAction* backAction = this->navigationAction(); |
|
1609 if (backAction) { |
|
1610 backAction->trigger(); |
|
1611 } |
|
1612 |
|
1613 } |
|
1614 } |
|
1615 |
|
1616 //--------------------------------------------------------------- |
|
1617 // MsgUnifiedEditorView::onDialogSmsSettings |
|
1618 //--------------------------------------------------------------- |
|
1619 void MsgUnifiedEditorView::onDialogSmsSettings(HbAction* action) |
|
1620 { |
|
1621 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1622 if (action == dlg->actions().at(0)) { |
|
1623 |
|
1624 QVariantList params; |
|
1625 params << MsgBaseView::MSGSETTINGS;// target view |
|
1626 params << MsgBaseView::UNIEDITOR; // source view |
|
1627 params << MsgSettingsView::SMSView; |
|
1628 emit switchView(params); |
|
1629 |
|
1630 } |
|
1631 } |
|
1632 |
|
1633 //--------------------------------------------------------------- |
|
1634 // MsgUnifiedEditorView::onDialogMmsSettings |
|
1635 //--------------------------------------------------------------- |
|
1636 void MsgUnifiedEditorView::onDialogMmsSettings(HbAction* action) |
|
1637 { |
|
1638 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
1639 if (action == dlg->actions().at(0)) { |
|
1640 |
|
1641 QVariantList params; |
|
1642 params << MsgBaseView::MSGSETTINGS;// target view |
|
1643 params << MsgBaseView::UNIEDITOR; // source view |
|
1644 params << MsgSettingsView::MMSView; |
|
1645 emit switchView(params); |
|
1646 } |
|
1647 } |
|
1648 |
|
1649 //--------------------------------------------------------------- |
|
1650 // MsgUnifiedEditorView::enableSendButton |
|
1651 // @see header file |
|
1652 //-------------------------------------------------------------- |
|
1653 void MsgUnifiedEditorView::enableSendButton(bool enable) |
|
1654 { |
|
1655 if(mSendAction) |
|
1656 { |
|
1657 // enable/disable based on only if its disabled/enabled. |
|
1658 // this check is to avoid unnecessary calls to mSendAction->setEnabled(enable); |
|
1659 if(mSendAction->isEnabled() != enable ) |
|
1660 mSendAction->setEnabled(enable); |
|
1661 } |
1461 } |
1662 } |
1462 |
1663 |
1463 //EOF |
1664 //EOF |