36 #include "convergedmessageaddress.h" |
37 #include "convergedmessageaddress.h" |
37 #include "conversationsenginedefines.h" |
38 #include "conversationsenginedefines.h" |
38 #include "conversationsengine.h" |
39 #include "conversationsengine.h" |
39 #include "debugtraces.h" |
40 #include "debugtraces.h" |
40 #include "nativemessageconsts.h" |
41 #include "nativemessageconsts.h" |
|
42 #include "mmsconformancecheck.h" |
41 |
43 |
42 // LOCAL CONSTANTS |
44 // LOCAL CONSTANTS |
43 const QString REPLY_ICON("qtg_mono_reply"); |
45 const QString REPLY_ICON("qtg_mono_reply"); |
44 const QString REPLY_ALL_ICON("qtg_mono_reply_all"); |
46 const QString REPLY_ALL_ICON("qtg_mono_reply_all"); |
45 const QString FORWARD_ICON("qtg_mono_forward_msg"); |
47 const QString FORWARD_ICON("qtg_mono_forward_msg"); |
46 const QString SEND_ICON("qtg_mono_send"); |
48 const QString SEND_ICON("qtg_mono_send"); |
47 const QString DELETE_ICON("qtg_mono_delete"); |
49 const QString DELETE_ICON("qtg_mono_delete"); |
48 |
50 |
|
51 //DB-file |
|
52 _LIT(KDbFileName, "c:[2002A542]conversations.db"); |
|
53 // query to see if msg is forwardable |
|
54 _LIT(KSelectMsgPropertyStmt, " SELECT message_id, msg_property FROM conversation_messages WHERE message_id=:message_id "); |
|
55 |
|
56 |
49 //LOCALIZED CONSTANTS |
57 //LOCALIZED CONSTANTS |
50 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
58 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
|
59 #define LOC_DELETE_SHARED_MESSAGE hbTrId("txt_messaging_dialog_same_message_exists_in_multip") |
51 |
60 |
52 //---------------------------------------------------------------------------- |
61 //---------------------------------------------------------------------------- |
53 // UnifiedViewer::UnifiedViewer |
62 // UnifiedViewer::UnifiedViewer |
54 // constructor |
63 // constructor |
55 //---------------------------------------------------------------------------- |
64 //---------------------------------------------------------------------------- |
56 UnifiedViewer::UnifiedViewer(const qint32 messageId, |
65 UnifiedViewer::UnifiedViewer(const qint32 messageId, |
57 int canForwardMessage, |
|
58 QGraphicsItem *parent) : |
66 QGraphicsItem *parent) : |
59 MsgBaseView(parent), mForwardMessage(false) |
67 MsgBaseView(parent) |
60 { |
68 { |
61 QDEBUG_WRITE("UnifiedViewer contruction start"); |
69 QDEBUG_WRITE("UnifiedViewer contruction start"); |
62 |
70 |
63 if (!HbStyleLoader::registerFilePath(":/layouts")) |
71 if (!HbStyleLoader::registerFilePath(":/layouts")) |
64 { |
72 { |
112 { |
118 { |
113 toolbar->addAction(HbIcon(SEND_ICON), ""); |
119 toolbar->addAction(HbIcon(SEND_ICON), ""); |
114 } |
120 } |
115 else |
121 else |
116 { |
122 { |
117 toolbar->addAction(HbIcon(REPLY_ICON), ""); |
123 // do not show reply option for multi recipient outgoing message |
|
124 if(!(!mViewFeeder->isIncoming() && mViewFeeder->recipientCount()>1)) |
|
125 { |
|
126 toolbar->addAction(HbIcon(REPLY_ICON), "", this, SLOT(handleReplyAction())); |
|
127 } |
118 |
128 |
119 if (mViewFeeder->recipientCount() > 1) |
129 if (mViewFeeder->recipientCount() > 1) |
120 { |
130 { |
121 toolbar->addAction(HbIcon(REPLY_ALL_ICON), ""); |
131 toolbar->addAction(HbIcon(REPLY_ALL_ICON), "", this, SLOT(handleReplyAllAction())); |
122 } |
132 } |
123 } |
133 } |
124 |
134 |
125 if (mForwardMessage) |
135 if (isForwardOk()) |
126 { |
136 { |
127 toolbar->addAction(HbIcon(FORWARD_ICON), "", this, SLOT(handleFwdAction())); |
137 toolbar->addAction(HbIcon(FORWARD_ICON), "", this, SLOT(handleFwdAction())); |
128 } |
138 } |
129 |
139 |
130 toolbar->addAction(HbIcon(DELETE_ICON), "", this, SLOT(handleDeleteAction())); |
140 toolbar->addAction(HbIcon(DELETE_ICON), "", this, SLOT(handleDeleteAction())); |
181 |
191 |
182 mContentsWidget->populateContent(); |
192 mContentsWidget->populateContent(); |
183 |
193 |
184 //Creation of toolbar now depends on content |
194 //Creation of toolbar now depends on content |
185 createToolBar(); |
195 createToolBar(); |
186 |
196 |
187 QDEBUG_WRITE("UnifiedViewer populateContent END"); |
197 QDEBUG_WRITE("UnifiedViewer populateContent END"); |
188 } |
198 } |
189 |
199 |
190 //--------------------------------------------------------------- |
200 //--------------------------------------------------------------- |
191 // UnifiedViewer::handleFwdAction |
201 // UnifiedViewer::handleFwdAction |
192 // @see header file |
202 // @see header file |
193 //--------------------------------------------------------------- |
203 //--------------------------------------------------------------- |
194 void UnifiedViewer::handleFwdAction() |
204 void UnifiedViewer::handleFwdAction() |
|
205 { |
|
206 launchEditor(MsgBaseView::FORWARD_MSG); |
|
207 } |
|
208 |
|
209 //--------------------------------------------------------------- |
|
210 // UnifiedViewer::handleReplyAction |
|
211 // @see header file |
|
212 //--------------------------------------------------------------- |
|
213 void UnifiedViewer::handleReplyAction() |
|
214 { |
|
215 launchEditor(MsgBaseView::REPLY_MSG); |
|
216 } |
|
217 |
|
218 //--------------------------------------------------------------- |
|
219 // UnifiedViewer::handleReplyAllAction |
|
220 // @see header file |
|
221 //--------------------------------------------------------------- |
|
222 void UnifiedViewer::handleReplyAllAction() |
|
223 { |
|
224 launchEditor(MsgBaseView::REPLY_ALL_MSG); |
|
225 } |
|
226 |
|
227 //--------------------------------------------------------------- |
|
228 // UnifiedViewer::resizeEvent |
|
229 // @see header file |
|
230 //--------------------------------------------------------------- |
|
231 void UnifiedViewer::resizeEvent(QGraphicsSceneResizeEvent * event) |
|
232 { |
|
233 Q_UNUSED(event) |
|
234 mContentsWidget->resize(this->rect().width(), this->rect().height()+1); |
|
235 } |
|
236 |
|
237 //--------------------------------------------------------------- |
|
238 // UnifiedViewer::handleDeleteAction |
|
239 // @see header file |
|
240 //--------------------------------------------------------------- |
|
241 void UnifiedViewer::handleDeleteAction() |
|
242 { |
|
243 QString txt = LOC_DELETE_MESSAGE; |
|
244 |
|
245 //if mms and out going. check for sharing |
|
246 if((mViewFeeder->msgType() == KSenduiMtmMmsUidValue) && (!mViewFeeder->isIncoming())) |
|
247 { |
|
248 if(mViewFeeder->recipientCount() > 1 ) |
|
249 { |
|
250 txt = LOC_DELETE_SHARED_MESSAGE; |
|
251 } |
|
252 } |
|
253 |
|
254 HbMessageBox::question(txt,this,SLOT(onDialogDeleteMsg(int)), |
|
255 HbMessageBox::Delete | HbMessageBox::Cancel); |
|
256 } |
|
257 |
|
258 //--------------------------------------------------------------- |
|
259 // UnifiedViewer::sendMessage |
|
260 // @see header file |
|
261 //--------------------------------------------------------------- |
|
262 void UnifiedViewer::sendMessage(const QString& phoneNumber,const QString& alias) |
|
263 { |
|
264 ConvergedMessage message; |
|
265 message.setBodyText(QString()); |
|
266 |
|
267 ConvergedMessageAddress address; |
|
268 address.setAlias(alias); |
|
269 address.setAddress(phoneNumber); |
|
270 message.addToRecipient(address); |
|
271 |
|
272 QByteArray dataArray; |
|
273 QDataStream messageStream |
|
274 (&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
|
275 message.serialize(messageStream); |
|
276 |
|
277 QVariantList params; |
|
278 params << MsgBaseView::UNIEDITOR; |
|
279 params << MsgBaseView::UNIVIEWER; |
|
280 params << dataArray; |
|
281 |
|
282 emit switchView(params); |
|
283 } |
|
284 |
|
285 //--------------------------------------------------------------- |
|
286 // UnifiedViewer::onDialogDeleteMsg |
|
287 // @see header file |
|
288 //--------------------------------------------------------------- |
|
289 void UnifiedViewer::onDialogDeleteMsg(int val) |
|
290 { |
|
291 if (val == HbMessageBox::Delete) { |
|
292 QList<int> msgIdList; |
|
293 msgIdList << mMessageId; |
|
294 |
|
295 ConversationsEngine::instance()->deleteMessages(msgIdList); |
|
296 |
|
297 QVariantList param; |
|
298 if (mMsgCount > 1) { |
|
299 param << MsgBaseView::CV; |
|
300 param << MsgBaseView::UNIVIEWER; |
|
301 } |
|
302 else { |
|
303 param << MsgBaseView::CLV; |
|
304 param << MsgBaseView::UNIVIEWER; |
|
305 } |
|
306 |
|
307 QVariant dummy(QVariant::Invalid); |
|
308 param << dummy; |
|
309 emit switchView(param); |
|
310 } |
|
311 } |
|
312 |
|
313 //--------------------------------------------------------------- |
|
314 // UnifiedViewer::launchEditor |
|
315 // @see header file |
|
316 //--------------------------------------------------------------- |
|
317 void UnifiedViewer::launchEditor( |
|
318 MsgBaseView::UniEditorOperation operation) |
195 { |
319 { |
196 ConvergedMessage message; |
320 ConvergedMessage message; |
197 ConvergedMessageId id(mMessageId); |
321 ConvergedMessageId id(mMessageId); |
198 message.setMessageId(id); |
322 message.setMessageId(id); |
199 if(mViewFeeder->msgType() == KSenduiMtmMmsUidValue) |
323 if(mViewFeeder->msgType() == KSenduiMtmMmsUidValue) |
200 { |
324 { |
201 message.setMessageType(ConvergedMessage::Mms); |
325 message.setMessageType(ConvergedMessage::Mms); |
202 } |
326 } |
203 else |
327 else |
204 { |
328 { |
205 message.setMessageType(ConvergedMessage::Sms); |
329 message.setMessageType(ConvergedMessage::Sms); |
206 } |
330 } |
207 |
331 |
208 QByteArray dataArray; |
332 QByteArray dataArray; |
209 QDataStream messageStream |
333 QDataStream messageStream |
210 (&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
334 (&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
213 QVariantList params; |
337 QVariantList params; |
214 params << MsgBaseView::UNIEDITOR; // target view |
338 params << MsgBaseView::UNIEDITOR; // target view |
215 params << MsgBaseView::UNIVIEWER; // source view |
339 params << MsgBaseView::UNIVIEWER; // source view |
216 |
340 |
217 params << dataArray; |
341 params << dataArray; |
218 params << MsgBaseView::FORWARD_MSG; |
342 params << operation; |
219 |
343 |
220 emit switchView(params); |
344 emit switchView(params); |
221 } |
345 } |
222 |
346 |
223 //--------------------------------------------------------------- |
347 //--------------------------------------------------------------- |
224 // UnifiedViewer::resizeEvent |
348 // UnifiedViewer::isForwardOk |
225 // @see header file |
349 // @see header file |
226 //--------------------------------------------------------------- |
350 //--------------------------------------------------------------- |
227 void UnifiedViewer::resizeEvent(QGraphicsSceneResizeEvent * event) |
351 bool UnifiedViewer::isForwardOk() |
228 { |
352 { |
229 Q_UNUSED(event) |
353 bool canForwardMsg = true; |
230 mContentsWidget->resize(this->rect().width(), this->rect().height()+1); |
354 if(mViewFeeder->msgType() == KSenduiMtmMmsUidValue) |
231 } |
355 { |
232 |
356 // open DB |
233 //--------------------------------------------------------------- |
357 RSqlDatabase sqlDb; |
234 // UnifiedViewer::handleDeleteAction |
358 TInt error = sqlDb.Open(KDbFileName); |
235 // @see header file |
359 if(error == KErrNone) |
236 //--------------------------------------------------------------- |
360 { |
237 void UnifiedViewer::handleDeleteAction() |
361 RSqlStatement sqlSelectStmt; |
238 { |
362 CleanupClosePushL(sqlSelectStmt); |
239 HbMessageBox::question(LOC_DELETE_MESSAGE,this, |
363 sqlSelectStmt.PrepareL(sqlDb,KSelectMsgPropertyStmt); |
240 SLOT(onDialogDeleteMsg(HbAction*)), |
364 TInt msgIdIndex = sqlSelectStmt.ParameterIndex(_L(":message_id")); |
241 HbMessageBox::Delete | HbMessageBox::Cancel); |
365 sqlSelectStmt.BindInt(msgIdIndex, mMessageId); |
242 } |
366 // read the flag |
243 |
367 TInt msgPropertyIndex = |
244 //--------------------------------------------------------------- |
368 sqlSelectStmt.ColumnIndex(_L("msg_property")); |
245 // UnifiedViewer::sendMessage |
369 TInt retValue = 0; |
246 // @see header file |
370 if (sqlSelectStmt.Next() == KSqlAtRow) |
247 //--------------------------------------------------------------- |
371 { |
248 void UnifiedViewer::sendMessage(const QString& phoneNumber,const QString& alias) |
372 retValue = static_cast<TInt> |
249 { |
373 (sqlSelectStmt.ColumnInt(msgPropertyIndex)); |
250 ConvergedMessage message; |
374 } |
251 message.setBodyText(QString()); |
375 CleanupStack::PopAndDestroy(&sqlSelectStmt); |
252 |
376 sqlDb.Close(); |
253 ConvergedMessageAddress address; |
377 canForwardMsg = (retValue & EPreviewForward)? true:false; |
254 address.setAlias(alias); |
378 } |
255 address.setAddress(phoneNumber); |
379 else |
256 message.addToRecipient(address); |
380 { |
257 |
381 // fall-back plan |
258 QByteArray dataArray; |
382 MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck; |
259 QDataStream messageStream |
383 canForwardMsg = mmsConformanceCheck->validateMsgForForward(mMessageId); |
260 (&dataArray, QIODevice::WriteOnly | QIODevice::Append); |
384 delete mmsConformanceCheck; |
261 message.serialize(messageStream); |
385 } |
262 |
386 } |
263 QVariantList params; |
387 return canForwardMsg; |
264 params << MsgBaseView::UNIEDITOR; |
|
265 params << MsgBaseView::UNIVIEWER; |
|
266 params << dataArray; |
|
267 |
|
268 emit switchView(params); |
|
269 } |
|
270 |
|
271 //--------------------------------------------------------------- |
|
272 // UnifiedViewer::onDialogDeleteMsg |
|
273 // @see header file |
|
274 //--------------------------------------------------------------- |
|
275 void UnifiedViewer::onDialogDeleteMsg(HbAction* action) |
|
276 { |
|
277 HbMessageBox *dlg = qobject_cast<HbMessageBox*> (sender()); |
|
278 if (action == dlg->actions().at(0)) { |
|
279 QList<int> msgIdList; |
|
280 msgIdList << mMessageId; |
|
281 |
|
282 ConversationsEngine::instance()->deleteMessages(msgIdList); |
|
283 |
|
284 QVariantList param; |
|
285 if (mMsgCount > 1) { |
|
286 param << MsgBaseView::CV; |
|
287 param << MsgBaseView::UNIVIEWER; |
|
288 } |
|
289 else { |
|
290 param << MsgBaseView::CLV; |
|
291 param << MsgBaseView::UNIVIEWER; |
|
292 } |
|
293 |
|
294 QVariant dummy(QVariant::Invalid); |
|
295 param << dummy; |
|
296 emit switchView(param); |
|
297 } |
|
298 } |
388 } |
299 |
389 |
300 // EOF |
390 // EOF |