messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp
changeset 70 a15d9966050f
parent 52 12db4185673b
child 72 6f657153cbc5
--- a/messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp	Thu Sep 02 20:23:03 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp	Fri Sep 17 08:28:39 2010 +0300
@@ -27,6 +27,9 @@
 #include <centralrepository.h>
 #include <MmsEngineDomainCRKeys.h>
 #include <ccsdefs.h>
+#include <xqappmgr.h>
+#include <xqaiwrequest.h>
+#include <sqldb.h>
 
 // USER INCLUDES
 #include "uniscrollarea.h"
@@ -51,7 +54,7 @@
 //DB-file
 _LIT(KDbFileName, "c:[2002A542]conversations.db");
 // query to see if msg is forwardable
-_LIT(KSelectMsgPropertyStmt, " SELECT message_id, msg_property FROM conversation_messages WHERE message_id=:message_id ");
+_LIT(KSelectMsgPropertyStmt, " SELECT message_id, msg_property, msg_processingstate FROM conversation_messages WHERE message_id=:message_id ");
 
 
 //LOCALIZED CONSTANTS
@@ -62,14 +65,12 @@
 // UnifiedViewer::UnifiedViewer
 // constructor
 //----------------------------------------------------------------------------
-UnifiedViewer::UnifiedViewer(const qint32 messageId,
-                             QGraphicsItem *parent) :
-    MsgBaseView(parent)
+UnifiedViewer::UnifiedViewer(const qint32 messageId, QGraphicsItem *parent) :
+    MsgBaseView(parent), mConversationID(-1)
 {
     QDEBUG_WRITE("UnifiedViewer contruction start");
 
-    if (!HbStyleLoader::registerFilePath(":/layouts"))
-    {
+    if (!HbStyleLoader::registerFilePath(":/layouts")) {
         QDEBUG_WRITE("ERROR: UnifiedViewer -> HbStyleLoader::registerFilePath");
     }
 
@@ -79,13 +80,12 @@
     mScrollArea = new UniScrollArea(this);
     this->setWidget(mScrollArea);
 
-    mContentsWidget = new UniContentsWidget(mViewFeeder,this);
+    mContentsWidget = new UniContentsWidget(mViewFeeder, this);
 
-    connect(mContentsWidget,SIGNAL(sendMessage(const QString&,const QString&)),
-            this, SLOT(sendMessage(const QString&,const QString&)));
+    connect(mContentsWidget, SIGNAL(sendMessage(const QString&,const QString&)), this,
+        SLOT(sendMessage(const QString&,const QString&)));
 
-    connect(mScrollArea, SIGNAL(scrolledToNextSlide()),
-    mContentsWidget, SLOT(populateNextSlide()));
+    connect(mScrollArea, SIGNAL(scrolledToNextSlide()), mContentsWidget, SLOT(populateNextSlide()));
 
     mScrollArea->setContentWidget(mContentsWidget);
     mScrollArea->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
@@ -160,12 +160,13 @@
 // UnifiedViewer::populateContent
 // @see header file
 //---------------------------------------------------------------
-void UnifiedViewer::populateContent(const qint32 messageId, bool update, int msgCount)
+void UnifiedViewer::populateContent(const qint32 messageId, bool update, int msgCount, qint64 conversationId)
 {
     QDEBUG_WRITE("UnifiedViewer populateContent Start");
 
     mMsgCount = msgCount;
     mMessageId = messageId;
+    mConversationID = conversationId;
 
     QDEBUG_WRITE("UnifiedViewer feeder->updateContent START");
 
@@ -198,6 +199,42 @@
 }
 
 //---------------------------------------------------------------
+// UnifiedViewer::handleKeyEvent
+// @see header file
+//---------------------------------------------------------------
+bool UnifiedViewer::handleKeyEvent(int key)
+{
+    bool eventHandled = false;
+    if (Qt::Key_Yes == key) {
+        bool incoming = mViewFeeder->isIncoming();
+        QString number;
+        if (incoming) {
+            QString alias;
+            mViewFeeder->fromAddressAndAlias(number, alias);
+        }
+        else if (!incoming && 1 == mViewFeeder->recipientCount()) {
+            ConvergedMessageAddressList addrList;
+            if ((addrList = mViewFeeder->toAddressList()).count()) {
+                number = addrList[0]->address();
+            }
+            else if((addrList = mViewFeeder->ccAddressList()).count()) {
+                number = addrList[0]->address();
+            }
+            else if ((addrList = mViewFeeder->bccAddressList()).count()) {
+                number = addrList[0]->address();
+            }
+        }
+
+        // Call
+        if (!number.isEmpty()) {
+            eventHandled = true;
+            call(number);
+        }
+    }
+    return eventHandled;
+}
+
+//---------------------------------------------------------------
 // UnifiedViewer::handleFwdAction
 // @see header file
 //---------------------------------------------------------------
@@ -298,6 +335,7 @@
         if (mMsgCount > 1) {
             param << MsgBaseView::CV;
             param << MsgBaseView::UNIVIEWER;
+            param << mConversationID;
         }
         else {
             param << MsgBaseView::CLV;
@@ -345,6 +383,26 @@
 }
 
 //---------------------------------------------------------------
+// UnifiedViewer::call
+// @see header file
+//---------------------------------------------------------------
+void UnifiedViewer::call(const QString &number)
+{
+    QString service("phoneui");
+    QString interface("com.nokia.symbian.ICallDial");
+    QString operation("dial(QString)");
+
+    XQApplicationManager appManager;
+    QScopedPointer<XQAiwRequest> request(appManager.create(service, interface, operation, false));
+    if (request) {
+        QList<QVariant> args;
+        args << number;
+        request->setArguments(args);
+        request->send();
+    }
+}
+
+//---------------------------------------------------------------
 // UnifiedViewer::isForwardOk
 // @see header file
 //---------------------------------------------------------------
@@ -366,15 +424,36 @@
             // read the flag
             TInt msgPropertyIndex =
                     sqlSelectStmt.ColumnIndex(_L("msg_property"));
+            
+            TInt msgProcessingStateIndex = sqlSelectStmt.ColumnIndex(
+                       _L("msg_processingstate"));
+            
             TInt retValue = 0;
+            TInt processingStateVal = 0;
             if (sqlSelectStmt.Next() == KSqlAtRow)
             {
                 retValue = static_cast<TInt>
                     (sqlSelectStmt.ColumnInt(msgPropertyIndex));
-            }
+                processingStateVal = static_cast<TInt>
+                    (sqlSelectStmt.ColumnInt(msgProcessingStateIndex));              
+            }        
+           
             CleanupStack::PopAndDestroy(&sqlSelectStmt);
             sqlDb.Close();
-            canForwardMsg = (retValue & EPreviewForward)? true:false;
+            
+            bool processing =  (processingStateVal & EPreviewMsgProcessed)? true:false;
+            if(processing)
+            {
+                canForwardMsg = (retValue & EPreviewForward)? true:false;
+            }
+            else
+            {
+               	// If message is still getting processed, forward field may not be updated in
+               	// Preview DB, so get the forwardable state from MMS conformance checks...
+                MmsConformanceCheck* mmsConformanceCheck = new MmsConformanceCheck;
+                canForwardMsg = mmsConformanceCheck->validateMsgForForward(mMessageId);
+                delete mmsConformanceCheck;  
+            }
         }
         else
         {