messagingapp/msgnotifications/msgnotificationdialogplugin/src/msgnotificationdialogwidget.cpp
changeset 67 fc91263aee62
parent 51 3507212d340e
child 68 e8a69c93c830
--- a/messagingapp/msgnotifications/msgnotificationdialogplugin/src/msgnotificationdialogwidget.cpp	Tue Sep 14 22:54:56 2010 +0530
+++ b/messagingapp/msgnotifications/msgnotificationdialogplugin/src/msgnotificationdialogwidget.cpp	Fri Sep 17 20:01:45 2010 +0530
@@ -14,8 +14,6 @@
  * Description: Widget class for Notificaiton Dialog Plugin
  *
  */
-#include <QThreadPool>
-#include <QRunnable>
 #include "debugtraces.h"
 
 #include <ccsdefs.h>
@@ -38,11 +36,15 @@
 
 static const char NEW_MSG_ICON[] = "qtg_large_new_message";
 
+bool serviceTaskLaunched = false; 
+
 // ----------------------------------------------------------------------------
 // ServiceRequestSenderTask::ServiceRequestSenderTask
 // @see msgnotificationdialogwidget.h
 // ----------------------------------------------------------------------------   
-ServiceRequestSenderTask::ServiceRequestSenderTask(qint64 conversationId):
+ServiceRequestSenderTask::ServiceRequestSenderTask(qint64 conversationId,
+        QObject* parent):
+QThread(parent),        
 mConvId(conversationId)
      {     
      }
@@ -71,12 +73,38 @@
          {
          return;       
          }
+     connect(request,SIGNAL(requestOk(const QVariant&)),
+             this,SLOT(onRequestCompleted(const QVariant&)));
+     
+     connect(request,SIGNAL(requestError(int, const QString&)),
+             this,SLOT(onRequestError(int, const QString&)));
+     
      args << QVariant(mConvId);
      request->setArguments(args);
      request->send();
      delete request;
+     
+     exec();
      }
 
+void ServiceRequestSenderTask::onRequestCompleted(const QVariant& value)
+    {
+	Q_UNUSED(value);
+    serviceTaskLaunched = false;
+    emit serviceRequestCompleted();
+    
+    quit();
+    }
+
+void ServiceRequestSenderTask::onRequestError(int errorCode, const QString& errorMessage)
+    {
+    Q_UNUSED(errorCode);
+    Q_UNUSED(errorMessage);
+    serviceTaskLaunched = false;
+    emit serviceRequestCompleted();
+    
+    quit();
+    }
 
 // ----------------------------------------------------------------------------
 // MsgNotificationDialogWidget::MsgNotificationDialogWidget
@@ -170,12 +198,16 @@
     // Close device dialog
     Q_UNUSED(byClient);
     close();
-    // If show event has been received, close is signalled from hide event. If not,
-    // hide event does not come and close is signalled from here.
-    if (!mShowEventReceived) {
-        emit deviceDialogClosed();
-    }
-    
+
+    if (serviceTaskLaunched == false)
+        {
+        // If show event has been received, close is signalled from hide event. If not,
+        // hide event does not come and close is signalled from here.
+        if (!mShowEventReceived)
+            {
+            emit deviceDialogClosed();
+            }
+        }
 }
 
 // ----------------------------------------------------------------------------
@@ -196,7 +228,10 @@
 void MsgNotificationDialogWidget::hideEvent(QHideEvent *event)
 {
     HbNotificationDialog::hideEvent(event);
-    emit deviceDialogClosed();
+    if (serviceTaskLaunched == false)
+        {
+        emit deviceDialogClosed();
+        }
 }
 
 // ----------------------------------------------------------------------------
@@ -214,10 +249,15 @@
 // @see msgnotificationdialogwidget.h
 // ----------------------------------------------------------------------------
 void MsgNotificationDialogWidget::widgetActivated()
-{
-QThreadPool::globalInstance()->start(
-        	new ServiceRequestSenderTask(mConversationId));
-    enableTouchActivation(false);  
+{           
+    ServiceRequestSenderTask* task = 
+            new ServiceRequestSenderTask(mConversationId,this);
+    connect(task,SIGNAL(serviceRequestCompleted()),
+            this,SIGNAL(deviceDialogClosed()));
+    serviceTaskLaunched = true;
+    task->start();
+    enableTouchActivation(false);
+    
 }
 
 // ----------------------------------------------------------------------------