25 #include <hbnotificationdialog.h> |
25 #include <hbnotificationdialog.h> |
26 #include <HbStyleLoader> |
26 #include <HbStyleLoader> |
27 #include <centralrepository.h> |
27 #include <centralrepository.h> |
28 #include <MmsEngineDomainCRKeys.h> |
28 #include <MmsEngineDomainCRKeys.h> |
29 #include <ccsdefs.h> |
29 #include <ccsdefs.h> |
|
30 #include <xqappmgr.h> |
|
31 #include <xqaiwrequest.h> |
|
32 #include <sqldb.h> |
30 |
33 |
31 // USER INCLUDES |
34 // USER INCLUDES |
32 #include "uniscrollarea.h" |
35 #include "uniscrollarea.h" |
33 #include "unicontentswidget.h" |
36 #include "unicontentswidget.h" |
34 #include "univiewerfeeder.h" |
37 #include "univiewerfeeder.h" |
49 const QString DELETE_ICON("qtg_mono_delete"); |
52 const QString DELETE_ICON("qtg_mono_delete"); |
50 |
53 |
51 //DB-file |
54 //DB-file |
52 _LIT(KDbFileName, "c:[2002A542]conversations.db"); |
55 _LIT(KDbFileName, "c:[2002A542]conversations.db"); |
53 // query to see if msg is forwardable |
56 // query to see if msg is forwardable |
54 _LIT(KSelectMsgPropertyStmt, " SELECT message_id, msg_property FROM conversation_messages WHERE message_id=:message_id "); |
57 _LIT(KSelectMsgPropertyStmt, " SELECT message_id, msg_property, msg_processingstate FROM conversation_messages WHERE message_id=:message_id "); |
55 |
58 |
56 |
59 |
57 //LOCALIZED CONSTANTS |
60 //LOCALIZED CONSTANTS |
58 #define LOC_DELETE_MESSAGE hbTrId("txt_messaging_dialog_delete_message") |
61 #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") |
62 #define LOC_DELETE_SHARED_MESSAGE hbTrId("txt_messaging_dialog_same_message_exists_in_multip") |
60 |
63 |
61 //---------------------------------------------------------------------------- |
64 //---------------------------------------------------------------------------- |
62 // UnifiedViewer::UnifiedViewer |
65 // UnifiedViewer::UnifiedViewer |
63 // constructor |
66 // constructor |
64 //---------------------------------------------------------------------------- |
67 //---------------------------------------------------------------------------- |
65 UnifiedViewer::UnifiedViewer(const qint32 messageId, |
68 UnifiedViewer::UnifiedViewer(const qint32 messageId, QGraphicsItem *parent) : |
66 QGraphicsItem *parent) : |
69 MsgBaseView(parent), mConversationID(-1) |
67 MsgBaseView(parent) |
|
68 { |
70 { |
69 QDEBUG_WRITE("UnifiedViewer contruction start"); |
71 QDEBUG_WRITE("UnifiedViewer contruction start"); |
70 |
72 |
71 if (!HbStyleLoader::registerFilePath(":/layouts")) |
73 if (!HbStyleLoader::registerFilePath(":/layouts")) { |
72 { |
|
73 QDEBUG_WRITE("ERROR: UnifiedViewer -> HbStyleLoader::registerFilePath"); |
74 QDEBUG_WRITE("ERROR: UnifiedViewer -> HbStyleLoader::registerFilePath"); |
74 } |
75 } |
75 |
76 |
76 mMessageId = messageId; |
77 mMessageId = messageId; |
77 mViewFeeder = new UniViewerFeeder(mMessageId, this); |
78 mViewFeeder = new UniViewerFeeder(mMessageId, this); |
78 |
79 |
79 mScrollArea = new UniScrollArea(this); |
80 mScrollArea = new UniScrollArea(this); |
80 this->setWidget(mScrollArea); |
81 this->setWidget(mScrollArea); |
81 |
82 |
82 mContentsWidget = new UniContentsWidget(mViewFeeder,this); |
83 mContentsWidget = new UniContentsWidget(mViewFeeder, this); |
83 |
84 |
84 connect(mContentsWidget,SIGNAL(sendMessage(const QString&,const QString&)), |
85 connect(mContentsWidget, SIGNAL(sendMessage(const QString&,const QString&)), this, |
85 this, SLOT(sendMessage(const QString&,const QString&))); |
86 SLOT(sendMessage(const QString&,const QString&))); |
86 |
87 |
87 connect(mScrollArea, SIGNAL(scrolledToNextSlide()), |
88 connect(mScrollArea, SIGNAL(scrolledToNextSlide()), mContentsWidget, SLOT(populateNextSlide())); |
88 mContentsWidget, SLOT(populateNextSlide())); |
|
89 |
89 |
90 mScrollArea->setContentWidget(mContentsWidget); |
90 mScrollArea->setContentWidget(mContentsWidget); |
91 mScrollArea->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
91 mScrollArea->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
92 mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAutoHide); |
92 mScrollArea->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAutoHide); |
93 |
93 |
158 |
158 |
159 //--------------------------------------------------------------- |
159 //--------------------------------------------------------------- |
160 // UnifiedViewer::populateContent |
160 // UnifiedViewer::populateContent |
161 // @see header file |
161 // @see header file |
162 //--------------------------------------------------------------- |
162 //--------------------------------------------------------------- |
163 void UnifiedViewer::populateContent(const qint32 messageId, bool update, int msgCount) |
163 void UnifiedViewer::populateContent(const qint32 messageId, bool update, int msgCount, qint64 conversationId) |
164 { |
164 { |
165 QDEBUG_WRITE("UnifiedViewer populateContent Start"); |
165 QDEBUG_WRITE("UnifiedViewer populateContent Start"); |
166 |
166 |
167 mMsgCount = msgCount; |
167 mMsgCount = msgCount; |
168 mMessageId = messageId; |
168 mMessageId = messageId; |
|
169 mConversationID = conversationId; |
169 |
170 |
170 QDEBUG_WRITE("UnifiedViewer feeder->updateContent START"); |
171 QDEBUG_WRITE("UnifiedViewer feeder->updateContent START"); |
171 |
172 |
172 if (update) |
173 if (update) |
173 { |
174 { |
193 |
194 |
194 //Creation of toolbar now depends on content |
195 //Creation of toolbar now depends on content |
195 createToolBar(); |
196 createToolBar(); |
196 |
197 |
197 QDEBUG_WRITE("UnifiedViewer populateContent END"); |
198 QDEBUG_WRITE("UnifiedViewer populateContent END"); |
|
199 } |
|
200 |
|
201 //--------------------------------------------------------------- |
|
202 // UnifiedViewer::handleKeyEvent |
|
203 // @see header file |
|
204 //--------------------------------------------------------------- |
|
205 bool UnifiedViewer::handleKeyEvent(int key) |
|
206 { |
|
207 bool eventHandled = false; |
|
208 if (Qt::Key_Yes == key) { |
|
209 bool incoming = mViewFeeder->isIncoming(); |
|
210 QString number; |
|
211 if (incoming) { |
|
212 QString alias; |
|
213 mViewFeeder->fromAddressAndAlias(number, alias); |
|
214 } |
|
215 else if (!incoming && 1 == mViewFeeder->recipientCount()) { |
|
216 ConvergedMessageAddressList addrList; |
|
217 if ((addrList = mViewFeeder->toAddressList()).count()) { |
|
218 number = addrList[0]->address(); |
|
219 } |
|
220 else if((addrList = mViewFeeder->ccAddressList()).count()) { |
|
221 number = addrList[0]->address(); |
|
222 } |
|
223 else if ((addrList = mViewFeeder->bccAddressList()).count()) { |
|
224 number = addrList[0]->address(); |
|
225 } |
|
226 } |
|
227 |
|
228 // Call |
|
229 if (!number.isEmpty()) { |
|
230 eventHandled = true; |
|
231 call(number); |
|
232 } |
|
233 } |
|
234 return eventHandled; |
198 } |
235 } |
199 |
236 |
200 //--------------------------------------------------------------- |
237 //--------------------------------------------------------------- |
201 // UnifiedViewer::handleFwdAction |
238 // UnifiedViewer::handleFwdAction |
202 // @see header file |
239 // @see header file |
340 |
378 |
341 params << dataArray; |
379 params << dataArray; |
342 params << operation; |
380 params << operation; |
343 |
381 |
344 emit switchView(params); |
382 emit switchView(params); |
|
383 } |
|
384 |
|
385 //--------------------------------------------------------------- |
|
386 // UnifiedViewer::call |
|
387 // @see header file |
|
388 //--------------------------------------------------------------- |
|
389 void UnifiedViewer::call(const QString &number) |
|
390 { |
|
391 QString service("phoneui"); |
|
392 QString interface("com.nokia.symbian.ICallDial"); |
|
393 QString operation("dial(QString)"); |
|
394 |
|
395 XQApplicationManager appManager; |
|
396 QScopedPointer<XQAiwRequest> request(appManager.create(service, interface, operation, false)); |
|
397 if (request) { |
|
398 QList<QVariant> args; |
|
399 args << number; |
|
400 request->setArguments(args); |
|
401 request->send(); |
|
402 } |
345 } |
403 } |
346 |
404 |
347 //--------------------------------------------------------------- |
405 //--------------------------------------------------------------- |
348 // UnifiedViewer::isForwardOk |
406 // UnifiedViewer::isForwardOk |
349 // @see header file |
407 // @see header file |
364 TInt msgIdIndex = sqlSelectStmt.ParameterIndex(_L(":message_id")); |
422 TInt msgIdIndex = sqlSelectStmt.ParameterIndex(_L(":message_id")); |
365 sqlSelectStmt.BindInt(msgIdIndex, mMessageId); |
423 sqlSelectStmt.BindInt(msgIdIndex, mMessageId); |
366 // read the flag |
424 // read the flag |
367 TInt msgPropertyIndex = |
425 TInt msgPropertyIndex = |
368 sqlSelectStmt.ColumnIndex(_L("msg_property")); |
426 sqlSelectStmt.ColumnIndex(_L("msg_property")); |
|
427 |
|
428 TInt msgProcessingStateIndex = sqlSelectStmt.ColumnIndex( |
|
429 _L("msg_processingstate")); |
|
430 |
369 TInt retValue = 0; |
431 TInt retValue = 0; |
|
432 TInt processingStateVal = 0; |
370 if (sqlSelectStmt.Next() == KSqlAtRow) |
433 if (sqlSelectStmt.Next() == KSqlAtRow) |
371 { |
434 { |
372 retValue = static_cast<TInt> |
435 retValue = static_cast<TInt> |
373 (sqlSelectStmt.ColumnInt(msgPropertyIndex)); |
436 (sqlSelectStmt.ColumnInt(msgPropertyIndex)); |
374 } |
437 processingStateVal = static_cast<TInt> |
|
438 (sqlSelectStmt.ColumnInt(msgProcessingStateIndex)); |
|
439 } |
|
440 |
375 CleanupStack::PopAndDestroy(&sqlSelectStmt); |
441 CleanupStack::PopAndDestroy(&sqlSelectStmt); |
376 sqlDb.Close(); |
442 sqlDb.Close(); |
377 canForwardMsg = (retValue & EPreviewForward)? true:false; |
443 |
|
444 bool processing = (processingStateVal & EPreviewMsgProcessed)? true:false; |
|
445 if(processing) |
|
446 { |
|
447 canForwardMsg = (retValue & EPreviewForward)? true:false; |
|
448 } |
|
449 else |
|
450 { |
|
451 // If message is still getting processed, forward field may not be updated in |
|
452 // Preview DB, so get the forwardable state from MMS conformance checks... |
|
453 MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck; |
|
454 canForwardMsg = mmsConformanceCheck->validateMsgForForward(mMessageId); |
|
455 delete mmsConformanceCheck; |
|
456 } |
378 } |
457 } |
379 else |
458 else |
380 { |
459 { |
381 // fall-back plan |
460 // fall-back plan |
382 MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck; |
461 MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck; |