messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp
changeset 62 fdbe8253b596
parent 56 f42d9a78f435
child 63 eceabb8c7a12
--- a/messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp	Wed Sep 01 14:19:13 2010 +0530
+++ b/messagingapp/msgui/unifiedviewer/src/unifiedviewer.cpp	Tue Sep 07 13:28:39 2010 +0530
@@ -27,6 +27,8 @@
 #include <centralrepository.h>
 #include <MmsEngineDomainCRKeys.h>
 #include <ccsdefs.h>
+#include <xqappmgr.h>
+#include <xqaiwrequest.h>
 
 // USER INCLUDES
 #include "uniscrollarea.h"
@@ -64,7 +66,7 @@
 //----------------------------------------------------------------------------
 UnifiedViewer::UnifiedViewer(const qint32 messageId,
                              QGraphicsItem *parent) :
-    MsgBaseView(parent)
+    MsgBaseView(parent), mConversationID(-1)
 {
     QDEBUG_WRITE("UnifiedViewer contruction start");
 
@@ -160,12 +162,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 +201,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 +337,7 @@
         if (mMsgCount > 1) {
             param << MsgBaseView::CV;
             param << MsgBaseView::UNIVIEWER;
+            param << mConversationID;
         }
         else {
             param << MsgBaseView::CLV;
@@ -345,6 +385,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
 //---------------------------------------------------------------