messagingapp/msgnotifications/msgerrornotifier/src/msgerrornotifiersvc.cpp
changeset 31 ebfee66fde93
child 43 35b64624a9e7
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: 
       
    15  *
       
    16  */
       
    17 
       
    18 #include "msgerrornotifiersvc.h"
       
    19 #include <QVariant>
       
    20 #include <HbMessageBox>
       
    21 #include <HbDialog>
       
    22 #include <hbdevicemessagebox.h>
       
    23 #include <HbAction>
       
    24 #include <xqservicerequest.h>
       
    25 #include <xqaiwrequest.h>
       
    26 #include <xqappmgr.h>
       
    27 #include <ccsdefs.h>
       
    28 #include <qaction.h>
       
    29 
       
    30 #define LOC_VIEW hbTrId("txt_messaging_button_view")
       
    31 #define LOC_CANCEL hbTrId("txt_common_button_cancel")
       
    32 #define LOC_SEND_FAILURE hbTrId("txt_messaging_list_message_sending_failed")
       
    33 
       
    34 //---------------------------------------------------------
       
    35 // Constructor
       
    36 //---------------------------------------------------------
       
    37 MsgErrorNotifierSvc::MsgErrorNotifierSvc(QObject* parent) :
       
    38     XQServiceProvider(QLatin1String("messaging.com.nokia.symbian.MsgErrorNotifier"), parent)
       
    39 {
       
    40     publishAll();
       
    41 
       
    42 }
       
    43 //---------------------------------------------------------
       
    44 // Destructor
       
    45 //---------------------------------------------------------
       
    46 MsgErrorNotifierSvc::~MsgErrorNotifierSvc()
       
    47 {
       
    48 
       
    49 }
       
    50 
       
    51 //---------------------------------------------------------
       
    52 // displayErrorNote
       
    53 // @see msgerrornotifiersvc.h
       
    54 //---------------------------------------------------------
       
    55 void MsgErrorNotifierSvc::displayErrorNote(QVariantList displayParams)
       
    56 {
       
    57 
       
    58     HbDeviceMessageBox messageBox(HbMessageBox::MessageTypeWarning);
       
    59     QVariant first = displayParams[0];
       
    60     QVariant second = displayParams[1];
       
    61     QVariant third = displayParams[2];
       
    62 
       
    63     int convId = second.toInt();
       
    64     qint64 id = convId;
       
    65     QString errorNote;
       
    66     
       
    67     int msgType = third.toInt();
       
    68     if (msgType == ECsMmsNotification)
       
    69     {
       
    70         errorNote.append("Message Retrieval Failed!");//TODO: use logical str name
       
    71     }
       
    72     else
       
    73     {
       
    74         errorNote.append(LOC_SEND_FAILURE);
       
    75         errorNote.append(QChar(QChar::LineSeparator));
       
    76 
       
    77         QString contactName = first.toString();
       
    78         errorNote.append(contactName);        
       
    79     }
       
    80     
       
    81     messageBox.setTimeout(HbPopup::NoTimeout);
       
    82     messageBox.setText(errorNote);
       
    83     QAction* actionView = new QAction(LOC_VIEW,this);
       
    84     messageBox.setAction(actionView,HbDeviceMessageBox::AcceptButtonRole);
       
    85 
       
    86     QAction* actionQuit = new QAction(LOC_CANCEL,this);
       
    87     actionQuit->setMenuRole(QAction::QuitRole);
       
    88     messageBox.setAction(actionView,HbDeviceMessageBox::RejectButtonRole);
       
    89 
       
    90     setCurrentRequestAsync();
       
    91 
       
    92     const QAction* result = messageBox.exec();
       
    93 
       
    94     // TODO: use XQAiwrequest
       
    95     if (result->menuRole() != QAction::QuitRole) {
       
    96         QList<QVariant> args;
       
    97         QString serviceName("com.nokia.services.hbserviceprovider");
       
    98         QString operation("open(qint64)");
       
    99         XQAiwRequest* request;
       
   100         XQApplicationManager appManager;
       
   101         request = appManager.create(serviceName, "conversationview", operation, false); // embedded
       
   102         if (request == NULL) {
       
   103             return;
       
   104         }
       
   105         args << QVariant(id);
       
   106         request->setArguments(args);
       
   107         request->send();
       
   108         delete request;
       
   109     }
       
   110 }