devicemgmtdialogsplugin/src/fotadevicedialogs.cpp
changeset 67 fdbfe0a95492
parent 52 6e38e48ee756
equal deleted inserted replaced
62:03849bd79877 67:fdbfe0a95492
    13 *
    13 *
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 #include "devicemanagementnotifierutils.h"
    19 #include <hbdocumentloader.h>
    19 #include <hbdocumentloader.h>
    20 #include <hbdialog.h>
    20 #include <hbdialog.h>
    21 #include <hblabel.h>
    21 #include <hblabel.h>
    22 #include <hbmessagebox.h>
    22 #include <hbmessagebox.h>
    23 #include <hbaction.h>
    23 #include <hbaction.h>
    24 #include <e32property.h>
    24 #include <e32property.h>
       
    25 //#include "syncmlnotifierparams.h"
       
    26 #include "fotadevicedialogs.h"
       
    27 
    25 #include <qdebug.h>
    28 #include <qdebug.h>
    26 #include <hblistview.h>
    29 #include <hblistview.h>
    27 #include <hbpushbutton.h>
    30 #include <hbpushbutton.h>
    28 #include <e32math.h>
    31 #include <e32math.h>
    29 #include <QStandardItemModel>
    32 #include <QStandardItemModel>
    37 // fotadevicedialogs::fotadevicedialogs
    40 // fotadevicedialogs::fotadevicedialogs
    38 // Constructor for fota related device dialogs 
    41 // Constructor for fota related device dialogs 
    39 // ---------------------------------------------------------------------------
    42 // ---------------------------------------------------------------------------
    40 //
    43 //
    41 
    44 
    42 fotadevicedialogs::fotadevicedialogs(const QVariantMap &parameters)
    45 fotadevicedialogs::fotadevicedialogs(devicemanagementnotifierwidget* ptr)
    43 //:	devicemanagementnotifierwidget(parameters)
    46 //:	devicemanagementnotifierwidget(parameters)
    44     {
    47     {
    45     qDebug("devicemanagementnotifierutils fotadevicedialogs");
    48     qDebug("devicemanagementnotifierutils fotadevicedialogs");
       
    49     m_Ptr = ptr;
    46     QTranslator *translator = new QTranslator();
    50     QTranslator *translator = new QTranslator();
    47     QString lang = QLocale::system().name();
    51     QString lang = QLocale::system().name();
    48     QString path = "Z:/resource/qt/translations/";
    52     QString path = "Z:/resource/qt/translations/";
    49     bool fine = translator->load("deviceupdates_" + lang, path);
    53     bool fine = translator->load("deviceupdates_" + lang, path);
    50     if (fine)
    54     if (fine)
    56         qApp->installTranslator(commontranslator);
    60         qApp->installTranslator(commontranslator);
    57     else
    61     else
    58         qDebug("device dialog common translator loading failed");
    62         qDebug("device dialog common translator loading failed");
    59 
    63 
    60     
    64     
    61     launchFotaDialog(parameters);
    65   
       
    66     }
       
    67 
       
    68 
       
    69 fotadevicedialogs::~fotadevicedialogs()
       
    70     {
       
    71     if(m_dialog)
       
    72         m_dialog->deleteLater();
       
    73     
    62     }
    74     }
    63 
    75 
    64 
    76 
    65 
    77 
    66 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
    74 
    86 
    75     QVariantMap::const_iterator i = parameters.constBegin();
    87     QVariantMap::const_iterator i = parameters.constBegin();
    76     qDebug("devicemanagementnotifierutils fotadevicedialogs launchDialog");    
    88     qDebug("devicemanagementnotifierutils fotadevicedialogs launchDialog");    
    77     TFwUpdNoteTypes aType = EFwUpdDeviceBusy;
    89     TFwUpdNoteTypes aType = EFwUpdDeviceBusy;
    78     
    90     
    79     //QString temp = QString::fromUtf8(reinterpret_cast<const char*>(url.Ptr()), url.Length());
       
    80     //TDesC8 * tempStr = KKeyDialog;
       
    81     //const QString temp = QString::fromUtf8(reinterpret_cast<const char*>(tempStr.Ptr()), tempStr.Length());
       
    82     i = parameters.find(keydialog);
    91     i = parameters.find(keydialog);
    83     if(i != parameters.end())
    92     if(i != parameters.end())
    84         aType = (TFwUpdNoteTypes)i.value().toInt();
    93         aType = (TFwUpdNoteTypes)i.value().toInt();
    85     
    94     
       
    95     m_DialogId = (TInt)aType; 
    86     
    96     
    87     if(aType == EFwUpdRebootNote)
    97     if(aType == EFwUpdRebootNote)
    88     	{
    98     	{
    89     		createfotainformativedialog(aType,parameters);
    99     		createfotainformativedialog(aType,parameters);
    90     	}
   100     	}
    91     	else if(aType == EFwUpdResumeDownload || aType == EFwUpdResumeUpdate)
   101     	else if(aType == EFwUpdResumeDownload || aType == EFwUpdResumeUpdate)
    92         {
   102         {
    93         createfotaconfirmationdialog(aType,parameters);
   103         createfotaconfirmationdialog(aType,parameters);
    94         //createfotainformativedialog();
   104         }
    95         }
   105     else
    96     else if(aType == EFwDLNeedMoreMemory || aType == EFwDLConnectionFailure || aType == EFwDLGeneralFailure || 
   106         {
    97     	 aType == EFwUpdNotEnoughBattery || aType == EFwUpdDeviceBusy || aType == EFwUpdSuccess || aType == EFwUpdNotCompatible
       
    98     || aType == EFwDLNonResumableFailure)
       
    99         {
       
   100         //createfotamessagedialog();
       
   101         createfotamessagedialog(aType,parameters);
   107         createfotamessagedialog(aType,parameters);
   102         }
   108         }
   103     }
   109     }
   104 
   110 
   105 
   111 
   109 // ---------------------------------------------------------------------------
   115 // ---------------------------------------------------------------------------
   110 //
   116 //
   111 void fotadevicedialogs::createfotainformativedialog(TFwUpdNoteTypes aType,const QVariantMap &parameters)
   117 void fotadevicedialogs::createfotainformativedialog(TFwUpdNoteTypes aType,const QVariantMap &parameters)
   112     {
   118     {
   113     qDebug("createserveralertinformative start");
   119     qDebug("createserveralertinformative start");
   114 		LOGSTRING("createserveralertinformative start");
       
   115     HbDocumentLoader loader;
   120     HbDocumentLoader loader;
   116     bool ok = false;
   121     bool ok = false;
   117     loader.load(":/xml/resources/fotainformativedialog.docml", &ok);
   122     loader.load(":/xml/resources/fotainformativedialog.docml", &ok);
   118     if (!ok)
   123     if (!ok)
   119         {
   124         {
   120         return;
   125         return;
   121         }
   126         }
   122     HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
   127     m_dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
   123 
   128 
   124     HbLabel *content = qobject_cast<HbLabel *> (loader.findWidget(
   129     HbLabel *content = qobject_cast<HbLabel *> (loader.findWidget(
   125             "lblContent"));
   130             "lblContent"));
   126 
   131 
   127     // No translations required
   132     // No translations required
   128     //content->setPlainText("Testing");
   133     //content->setPlainText("Testing");
   129 
   134 
   130     dialog->setTimeout(3000);
   135     m_dialog->setTimeout(3000);
   131 
   136 
   132     if (dialog)
   137     if (m_dialog)
   133         dialog->show();
   138         m_dialog->show();
   134 
   139 
   135     QObject::connect(dialog, SIGNAL(aboutToClose()), this, SLOT(okSelected()));
   140     QObject::connect(m_dialog, SIGNAL(aboutToClose()), this, SLOT(okSelected()));
   136 
   141 
   137 	qDebug("createserveralertinformative end");
   142 	qDebug("createserveralertinformative end");
   138 
   143 
   139     }
   144     }
   140 
   145 
   146 // ---------------------------------------------------------------------------
   151 // ---------------------------------------------------------------------------
   147 //
   152 //
   148 void fotadevicedialogs::createfotaconfirmationdialog(TFwUpdNoteTypes aType,const QVariantMap &parameters)
   153 void fotadevicedialogs::createfotaconfirmationdialog(TFwUpdNoteTypes aType,const QVariantMap &parameters)
   149     {
   154     {
   150     qDebug("createserveralertinformative start");
   155     qDebug("createserveralertinformative start");
   151         LOGSTRING("createserveralertinformative start");
       
   152         
   156         
   153     QVariantMap::const_iterator i;
   157     QVariantMap::const_iterator i;
   154     HbDocumentLoader loader;
   158     HbDocumentLoader loader;
   155     bool ok = false;
   159     bool ok = false;
   156     HbDialog *dialog = NULL;
   160     HbDialog *dialog = NULL;
   182             loader.load(":/xml/resources/fotasoftkeysdialog.docml", &ok);
   186             loader.load(":/xml/resources/fotasoftkeysdialog.docml", &ok);
   183             if (!ok)
   187             if (!ok)
   184             {
   188             {
   185             return;
   189             return;
   186             }
   190             }
   187             dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
   191             m_dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
   188             
   192             
   189             HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
   193             HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
   190                                 "lblDialogHeading"));
   194                                 "lblDialogHeading"));
   191             
   195             
   192             headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
   196             headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
   209                 {
   213                 {
   210                 Math::Round(sizeRounded,sizeKB,2);
   214                 Math::Round(sizeRounded,sizeKB,2);
   211                 contentString->setPlainText(hbTrId("txt_device_update_info_the_last_update_incomplete_dwnld_kb")
   215                 contentString->setPlainText(hbTrId("txt_device_update_info_the_last_update_incomplete_dwnld_kb")
   212                         .arg(param1).arg(param2).arg(sizeRounded));
   216                         .arg(param1).arg(param2).arg(sizeRounded));
   213                 }
   217                 }
   214             //HbAction *primaryAction = dialog->primaryAction();
   218 
   215             HbAction *primaryAction = (HbAction *) dialog->actions().first();
   219             HbAction *primaryAction = (HbAction *) m_dialog->actions().first();
   216             primaryAction->setText(hbTrId("txt_common_button_continue_dialog"));
   220             primaryAction->setText(hbTrId("txt_common_button_continue_dialog"));
   217 
   221 
   218             //HbAction *secondaryAction = dialog->secondaryAction();
   222             HbAction *secondaryAction = (HbAction *) m_dialog->actions().at(1);
   219             HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
       
   220             secondaryAction->setText(hbTrId("txt_device_update_button_resume_later"));
   223             secondaryAction->setText(hbTrId("txt_device_update_button_resume_later"));
   221             if(!postpone)
   224             if(!postpone)
   222                 secondaryAction->setEnabled(postpone);
   225                 secondaryAction->setEnabled(postpone);
   223 
   226 
   224             dialog->setTimeout(HbPopup::NoTimeout);
   227             m_dialog->setTimeout(HbPopup::NoTimeout);
   225             dialog->setDismissPolicy(HbPopup::NoDismiss);
   228             m_dialog->setDismissPolicy(HbPopup::NoDismiss);
   226 
   229 
   227             QObject::connect(primaryAction, SIGNAL(triggered()), this,
   230             QObject::connect(primaryAction, SIGNAL(triggered()), this,
   228                     SLOT(fotaLSK()));
   231                     SLOT(fotaLSK()));
   229 
   232 
   230             QObject::connect(secondaryAction, SIGNAL(triggered()), this,
   233             QObject::connect(secondaryAction, SIGNAL(triggered()), this,
   238                 if (!ok)
   241                 if (!ok)
   239                     {
   242                     {
   240                     return;
   243                     return;
   241                     }
   244                     }
   242                 
   245                 
   243                 dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
   246                 m_dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
   244                 
   247                 
   245                 dialog->setTimeout(HbPopup::NoTimeout);
   248                 m_dialog->setTimeout(HbPopup::NoTimeout);
   246                 dialog->setDismissPolicy(HbPopup::NoDismiss);
   249                 m_dialog->setDismissPolicy(HbPopup::NoDismiss);
   247                 
   250                 
   248                 HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
   251                 HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
   249                         "lblHeading"));
   252                         "lblHeading"));
   250                 headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
   253                 headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
   251                             
   254                             
   252                 
   255                 
   253                 //HbAction *primaryAction = dialog->primaryAction();
   256                 HbAction *primaryAction = (HbAction *) m_dialog->actions().first();
   254                 HbAction *primaryAction = (HbAction *) dialog->actions().first();
       
   255                 primaryAction->setText(hbTrId("txt_common_button_continue_dialog"));
   257                 primaryAction->setText(hbTrId("txt_common_button_continue_dialog"));
   256                 
   258                 
   257                 //HbAction *secondaryAction = dialog->secondaryAction();
   259                 HbAction *secondaryAction = (HbAction *) m_dialog->actions().at(1);
   258                 HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
       
   259                 secondaryAction->setText(hbTrId("txt_device_update_button_resume_later"));
   260                 secondaryAction->setText(hbTrId("txt_device_update_button_resume_later"));
   260                 if(!postpone)
   261                 if(!postpone)
   261                     secondaryAction->setEnabled(postpone);
   262                     secondaryAction->setEnabled(postpone);
   262                 
   263                 
   263                 HbLabel *contentSwDetails = qobject_cast<HbLabel *> (loader.findWidget(
   264                 HbLabel *contentSwDetails = qobject_cast<HbLabel *> (loader.findWidget(
   290                 
   291                 
   291                 HbLabel *contentEmergency = qobject_cast<HbLabel *> (loader.findWidget(
   292                 HbLabel *contentEmergency = qobject_cast<HbLabel *> (loader.findWidget(
   292                                                                 "label_1"));
   293                                                                 "label_1"));
   293                 contentEmergency->setPlainText(hbTrId("txt_device_update_info_during_the_installation_the"));
   294                 contentEmergency->setPlainText(hbTrId("txt_device_update_info_during_the_installation_the"));
   294 
   295 
   295                 dialog->setTimeout(HbPopup::NoTimeout);
   296                 m_dialog->setTimeout(HbPopup::NoTimeout);
   296 
   297 
   297                 QObject::connect(primaryAction, SIGNAL(triggered()), this,
   298                 QObject::connect(primaryAction, SIGNAL(triggered()), this,
   298                         SLOT(fotaLSK()));
   299                         SLOT(fotaLSK()));
   299 
   300 
   300                 QObject::connect(secondaryAction, SIGNAL(triggered()), this,
   301                 QObject::connect(secondaryAction, SIGNAL(triggered()), this,
   305             {
   306             {
   306             break;
   307             break;
   307             }
   308             }
   308         }
   309         }
   309 
   310 
   310     if (dialog)
   311     if (m_dialog)
   311         dialog->show();
   312         m_dialog->show();
   312 
   313 
   313     qDebug("createserveralertinformative end");
   314     qDebug("createserveralertinformative end");
   314 
   315 
   315     }
   316     }
   316 
   317 
   322 //
   323 //
   323 void fotadevicedialogs::createfotamessagedialog(TFwUpdNoteTypes aType,const QVariantMap &parameters)
   324 void fotadevicedialogs::createfotamessagedialog(TFwUpdNoteTypes aType,const QVariantMap &parameters)
   324     {
   325     {
   325     QVariantMap::const_iterator i;
   326     QVariantMap::const_iterator i;
   326     qDebug("createserveralertinformative start");
   327     qDebug("createserveralertinformative start");
   327         LOGSTRING("createserveralertinformative start");
       
   328     HbDocumentLoader loader;
   328     HbDocumentLoader loader;
   329     bool ok = false;
   329     bool ok = false;
   330     loader.load(":/xml/resources/fotasoftkeydialog.docml", &ok);
   330     loader.load(":/xml/resources/fotasoftkeydialog.docml", &ok);
   331     if (!ok)
   331     if (!ok)
   332         {
   332         {
   333         return;
   333         return;
   334         }
   334         }
   335     HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
   335     m_dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
   336     
   336     
   337     HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
   337     HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
   338             "lblHeaind"));
   338             "lblHeaind"));
   339     headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
   339     headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
   340     
   340     
   341     HbLabel *contentString = qobject_cast<HbLabel *> (loader.findWidget(
   341     HbLabel *contentString = qobject_cast<HbLabel *> (loader.findWidget(
   342             "lblContent"));
   342             "lblContent"));
   343             
   343             
   344     dialog->setTimeout(HbPopup::NoTimeout);
   344     m_dialog->setTimeout(HbPopup::NoTimeout);
   345     dialog->setDismissPolicy(HbPopup::NoDismiss);
   345     m_dialog->setDismissPolicy(HbPopup::NoDismiss);
   346     
   346     
   347     //HbAction *primaryAction = dialog->primaryAction();
   347     HbAction *primaryAction = (HbAction *) m_dialog->actions().first();
   348     HbAction *primaryAction = (HbAction *) dialog->actions().first();
       
   349     primaryAction->setText(hbTrId("txt_common_button_ok_single_dialog"));
   348     primaryAction->setText(hbTrId("txt_common_button_ok_single_dialog"));
   350 
   349 
   351     QObject::connect(primaryAction, SIGNAL(triggered()), this,
   350     QObject::connect(primaryAction, SIGNAL(triggered()), this,
   352                 SLOT(fotaLSK()));
   351                 SLOT(fotaLSK()));
   353                 
   352                 
   414            {
   413            {
   415            break;
   414            break;
   416            }
   415            }
   417         }
   416         }
   418 
   417 
   419     if (dialog)
   418     if (m_dialog)
   420         dialog->show();
   419         m_dialog->show();
   421 
   420 
   422     qDebug("createserveralertinformative end");
   421     qDebug("createserveralertinformative end");
   423 
   422 
   424     }
   423     }
   425 
   424 
   430 // ---------------------------------------------------------------------------
   429 // ---------------------------------------------------------------------------
   431 //
   430 //
   432 void fotadevicedialogs::fotaLSK()
   431 void fotadevicedialogs::fotaLSK()
   433     {
   432     {
   434     qDebug("ok selected");
   433     qDebug("ok selected");
   435     QVariantMap resultMap;
   434     emit m_Ptr->fotaDevdialogDismissed(m_DialogId,EHbLSK);
   436     resultMap.insert(returnkey, EHbLSK);
       
   437     emit deviceDialogData(resultMap);
       
   438     }
   435     }
   439 
   436 
   440 
   437 
   441 
   438 
   442 // ---------------------------------------------------------------------------
   439 // ---------------------------------------------------------------------------
   445 // ---------------------------------------------------------------------------
   442 // ---------------------------------------------------------------------------
   446 //
   443 //
   447 void fotadevicedialogs::fotaRSK()
   444 void fotadevicedialogs::fotaRSK()
   448     {
   445     {
   449     qDebug("cancel selected");
   446     qDebug("cancel selected");
   450     QVariantMap resultMap;
   447     emit m_Ptr->fotaDevdialogDismissed(m_DialogId,EHbRSK);
   451     resultMap.insert(returnkey, EHbRSK);
   448     }
   452     emit deviceDialogData(resultMap);
       
   453     }
       
   454 
       
   455 
       
   456 
       
   457 // Set parameters
       
   458 bool fotadevicedialogs::setDeviceDialogParameters(
       
   459     const QVariantMap &parameters)
       
   460 {
       
   461     
       
   462     return true;
       
   463 }
       
   464 
       
   465 // Get error
       
   466 int fotadevicedialogs::deviceDialogError() const
       
   467 {
       
   468     
       
   469     return 0;
       
   470 }
       
   471 
       
   472 
       
   473 // Close device dialog
       
   474 // ---------------------------------------------------------------------------
       
   475 // fotadevicedialogs::closeDeviceDialog
       
   476 // This slot is called when device dialog is closed due to errors.
       
   477 // ---------------------------------------------------------------------------
       
   478 //
       
   479 
       
   480 void fotadevicedialogs::closeDeviceDialog(bool byClient)
       
   481 {
       
   482 		qDebug("cancel selected");
       
   483     emit deviceDialogClosed();
       
   484 }
       
   485 
       
   486 
       
   487 // Return display widget
       
   488 HbDialog *fotadevicedialogs::deviceDialogWidget() const
       
   489 {
       
   490    
       
   491     return const_cast<fotadevicedialogs*>(this);
       
   492     //return const_cast<devicemanagementnotifierwidget*>(this);
       
   493 }