messagingapp/msgnotifications/msgnotificationdialogplugin/src/msgnotificationdialogwidget.cpp
changeset 73 ecf6a73a9186
parent 68 e8a69c93c830
equal deleted inserted replaced
68:e8a69c93c830 73:ecf6a73a9186
    12  * Contributors:
    12  * Contributors:
    13  *
    13  *
    14  * Description: Widget class for Notificaiton Dialog Plugin
    14  * Description: Widget class for Notificaiton Dialog Plugin
    15  *
    15  *
    16  */
    16  */
    17 #include <QThreadPool>
       
    18 #include <QRunnable>
       
    19 #include "debugtraces.h"
    17 #include "debugtraces.h"
    20 
    18 
    21 #include <ccsdefs.h>
    19 #include <ccsdefs.h>
    22 #include <QIcon>
    20 #include <QIcon>
    23 #include <QVariant>
    21 #include <QVariant>
    24 #include <QList>
    22 #include <QList>
    25 #include <hbicon.h>
    23 #include <hbicon.h>
    26 #include <hbpopup.h>
    24 #include <hbpopup.h>
    27 #include <xqservicerequest.h>
    25 
    28 #include <xqaiwrequest.h>
       
    29 #include <xqappmgr.h>
       
    30 
    26 
    31 #include "convergedmessage.h"
    27 #include "convergedmessage.h"
    32 
    28 
    33 #include "msgnotificationdialogpluginkeys.h"
    29 #include "msgnotificationdialogpluginkeys.h"
    34 #include "msgnotificationdialogwidget.h"
    30 #include "msgnotificationdialogwidget.h"
    36 const int NoError = 0;
    32 const int NoError = 0;
    37 const int ParameterError = 10000;
    33 const int ParameterError = 10000;
    38 
    34 
    39 static const char NEW_MSG_ICON[] = "qtg_large_new_message";
    35 static const char NEW_MSG_ICON[] = "qtg_large_new_message";
    40 
    36 
    41 bool serviceTaskLaunched = false; 
       
    42 
       
    43 // ----------------------------------------------------------------------------
       
    44 // ServiceRequestSenderTask::ServiceRequestSenderTask
       
    45 // @see msgnotificationdialogwidget.h
       
    46 // ----------------------------------------------------------------------------   
       
    47 ServiceRequestSenderTask::ServiceRequestSenderTask(qint64 conversationId):
       
    48 mConvId(conversationId)
       
    49      {     
       
    50      }
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // ServiceRequestSenderTask::~ServiceRequestSenderTask
       
    54 // @see msgnotificationdialogwidget.h
       
    55 // ----------------------------------------------------------------------------   
       
    56 ServiceRequestSenderTask::~ServiceRequestSenderTask()
       
    57      {     
       
    58      }
       
    59      
       
    60 // ----------------------------------------------------------------------------
       
    61 // ServiceRequestSenderTask::run
       
    62 // @see msgnotificationdialogwidget.h
       
    63 // ----------------------------------------------------------------------------   
       
    64 void ServiceRequestSenderTask::run()
       
    65      {
       
    66      QList<QVariant> args;
       
    67      QString serviceName("com.nokia.services.hbserviceprovider");
       
    68      QString operation("open(qint64)");
       
    69      XQAiwRequest* request;
       
    70      XQApplicationManager appManager;
       
    71      request = appManager.create(serviceName, "conversationview", operation, false); // not embedded
       
    72      if ( request == NULL )
       
    73          {
       
    74          return;       
       
    75          }
       
    76      connect(request,SIGNAL(requestOk(const QVariant&)),
       
    77              this,SLOT(onRequestCompleted(const QVariant&)));
       
    78      
       
    79      connect(request,SIGNAL(requestError(int, const QString&)),
       
    80              this,SLOT(onRequestError(int, const QString&)));
       
    81      
       
    82      args << QVariant(mConvId);
       
    83      request->setArguments(args);
       
    84      request->setSynchronous(true);
       
    85      request->send();
       
    86      delete request;
       
    87      }
       
    88 
       
    89 void ServiceRequestSenderTask::onRequestCompleted(const QVariant& value)
       
    90     {
       
    91 	Q_UNUSED(value);
       
    92     serviceTaskLaunched = false;
       
    93     emit serviceRequestCompleted();
       
    94     }
       
    95 
       
    96 void ServiceRequestSenderTask::onRequestError(int errorCode, const QString& errorMessage)
       
    97     {
       
    98     Q_UNUSED(errorCode);
       
    99     Q_UNUSED(errorMessage);
       
   100     serviceTaskLaunched = false;
       
   101     emit serviceRequestCompleted();
       
   102     }
       
   103 
       
   104 // ----------------------------------------------------------------------------
    37 // ----------------------------------------------------------------------------
   105 // MsgNotificationDialogWidget::MsgNotificationDialogWidget
    38 // MsgNotificationDialogWidget::MsgNotificationDialogWidget
   106 // @see msgnotificationdialogwidget.h
    39 // @see msgnotificationdialogwidget.h
   107 // ----------------------------------------------------------------------------
    40 // ----------------------------------------------------------------------------
   108 MsgNotificationDialogWidget::MsgNotificationDialogWidget(
    41 MsgNotificationDialogWidget::MsgNotificationDialogWidget(
   109                                                 const QVariantMap &parameters)
    42                                                 const QVariantMap &parameters)
   110 : HbNotificationDialog(),
    43 : HbNotificationDialog(),
       
    44 mConversationId(-1),
   111 mLastError(NoError),
    45 mLastError(NoError),
   112 mShowEventReceived(false),
    46 mShowEventReceived(false)
   113 mConversationId(-1)
       
   114 {
    47 {
   115     constructDialog(parameters);
    48     constructDialog(parameters);
   116 }
    49 }
   117 
    50 
   118                                                 
    51 // ----------------------------------------------------------------------------
       
    52 // MsgNotificationDialogWidget::~MsgNotificationDialogWidget
       
    53 // @see msgnotificationdialogwidget.h
       
    54 // ----------------------------------------------------------------------------                                                
       
    55 MsgNotificationDialogWidget::~MsgNotificationDialogWidget()
       
    56 {
       
    57 }
       
    58 
   119 // ----------------------------------------------------------------------------
    59 // ----------------------------------------------------------------------------
   120 // MsgNotificationDialogWidget::setDeviceDialogParameters
    60 // MsgNotificationDialogWidget::setDeviceDialogParameters
   121 // @see msgnotificationdialogwidget.h
    61 // @see msgnotificationdialogwidget.h
   122 // ----------------------------------------------------------------------------
    62 // ----------------------------------------------------------------------------
   123 bool MsgNotificationDialogWidget::setDeviceDialogParameters(
    63 bool MsgNotificationDialogWidget::setDeviceDialogParameters(
   192 {
   132 {
   193     // Close device dialog
   133     // Close device dialog
   194     Q_UNUSED(byClient);
   134     Q_UNUSED(byClient);
   195     close();
   135     close();
   196 
   136 
   197     if (serviceTaskLaunched == false)
   137     // If show event has been received, close is signalled from hide event. If not,
   198         {
   138     // hide event does not come and close is signalled from here.
   199         // If show event has been received, close is signalled from hide event. If not,
   139     if (!mShowEventReceived)
   200         // hide event does not come and close is signalled from here.
   140         {
   201         if (!mShowEventReceived)
   141         emit deviceDialogClosed();
   202             {
       
   203             emit deviceDialogClosed();
       
   204             }
       
   205         }
   142         }
   206 }
   143 }
   207 
   144 
   208 // ----------------------------------------------------------------------------
   145 // ----------------------------------------------------------------------------
   209 // MsgNotificationDialogWidget::deviceDialogWidget
   146 // MsgNotificationDialogWidget::deviceDialogWidget
   221 // @see msgnotificationdialogwidget.h
   158 // @see msgnotificationdialogwidget.h
   222 // ----------------------------------------------------------------------------
   159 // ----------------------------------------------------------------------------
   223 void MsgNotificationDialogWidget::hideEvent(QHideEvent *event)
   160 void MsgNotificationDialogWidget::hideEvent(QHideEvent *event)
   224 {
   161 {
   225     HbNotificationDialog::hideEvent(event);
   162     HbNotificationDialog::hideEvent(event);
   226     if (serviceTaskLaunched == false)
   163     emit deviceDialogClosed();
   227         {
       
   228         emit deviceDialogClosed();
       
   229         }
       
   230 }
   164 }
   231 
   165 
   232 // ----------------------------------------------------------------------------
   166 // ----------------------------------------------------------------------------
   233 // MsgNotificationDialogWidget::showEvent
   167 // MsgNotificationDialogWidget::showEvent
   234 // @see msgnotificationdialogwidget.h
   168 // @see msgnotificationdialogwidget.h
   243 // MsgNotificationDialogWidget::widgetActivated
   177 // MsgNotificationDialogWidget::widgetActivated
   244 // @see msgnotificationdialogwidget.h
   178 // @see msgnotificationdialogwidget.h
   245 // ----------------------------------------------------------------------------
   179 // ----------------------------------------------------------------------------
   246 void MsgNotificationDialogWidget::widgetActivated()
   180 void MsgNotificationDialogWidget::widgetActivated()
   247 {           
   181 {           
   248     ServiceRequestSenderTask* task = 
   182     //Emit data to be used by msgnotifier
   249             new ServiceRequestSenderTask(mConversationId);
   183     QVariantMap data;
   250     connect(task,SIGNAL(serviceRequestCompleted()),
   184     data.insert(KConversationIdKey,mConversationId);
   251             this,SIGNAL(deviceDialogClosed()));
   185     emit deviceDialogData(data);
   252     serviceTaskLaunched = true;
   186     enableTouchActivation(false);    
   253     QThreadPool::globalInstance()->start(task);
       
   254     enableTouchActivation(false);
       
   255     
       
   256 }
   187 }
   257 
   188 
   258 // ----------------------------------------------------------------------------
   189 // ----------------------------------------------------------------------------
   259 // MsgNotificationDialogWidget::prepareDisplayName
   190 // MsgNotificationDialogWidget::prepareDisplayName
   260 // @see msgnotificationdialogwidget.h
   191 // @see msgnotificationdialogwidget.h