securitysettings/eapqtdialogs/src/eapfastinstallpacquerydialog.cpp
changeset 26 9abfd4f00d37
equal deleted inserted replaced
25:e03a3db4489e 26:9abfd4f00d37
       
     1 /*
       
     2 * Copyright (c) 2010 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: Prompt Dialog implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "eapfastinstallpacquerydialog.h"
       
    19 #include "OstTraceDefinitions.h"
       
    20 #ifdef OST_TRACE_COMPILER_IN_USE
       
    21 #endif
       
    22 
       
    23 // The index numbers of the button of the dialog
       
    24 const int yesButtonIndex = 1;
       
    25 
       
    26 /**
       
    27  * The constructor
       
    28  */
       
    29 EapFastInstallPacQueryDialog::EapFastInstallPacQueryDialog(const QVariantMap &parameters)
       
    30 :HbMessageBox("default text...",HbMessageBox::MessageTypeQuestion),
       
    31 mActionYes(NULL),
       
    32 mTranslator(new HbTranslator("eapprompts"))
       
    33 {
       
    34     OstTraceFunctionEntry0( EAPGTCQUERYDIALOG_EAPGTCQUERYDIALOG_ENTRY );
       
    35     qDebug("EapFastInstallPacQueryDialog::EapFastInstallPacQueryDialog ENTER");
       
    36         
       
    37     createDialog( parameters );
       
    38     
       
    39     mClose = false;
       
    40     mYesActionPressed = false;
       
    41     
       
    42     OstTraceFunctionExit0( EAPGTCQUERYDIALOG_EAPGTCQUERYDIALOG_EXIT );
       
    43     qDebug("EapFastInstallPacQueryDialog::EapFastInstallPacQueryDialog EXIT");
       
    44 }
       
    45     
       
    46 /**
       
    47  * The construction of the dialog
       
    48  */ 
       
    49 void EapFastInstallPacQueryDialog::createDialog(const QVariantMap &parameters )
       
    50 {
       
    51     OstTraceFunctionEntry0( EAPGTCQUERYDIALOG_CREATEDIALOG_ENTRY );
       
    52     qDebug("EapFastInstallPacQueryDialog::createDialog ENTER");
       
    53          
       
    54     QString servername = QString("foobar");
       
    55     QString key = QString("pacservername");
       
    56        
       
    57     if ( parameters.empty() == false ) {
       
    58         if ( parameters.contains(key) ) {
       
    59             QVariant variant = parameters.value(key);
       
    60             servername = variant.toString();
       
    61             }
       
    62         }  
       
    63     
       
    64     QString mainText = QString(hbTrId("txt_occ_info_install_pac_from_server_1").arg(servername));
       
    65     
       
    66     //Set the dialog to be on the screen until user reacts
       
    67     //by pressing any of the Action buttons
       
    68     this->setModal(true);
       
    69     this->setTimeout(HbPopup::NoTimeout);
       
    70     this->setDismissPolicy(HbPopup::NoDismiss);
       
    71                
       
    72     this->setText(mainText);    
       
    73     this->setIconVisible(true);
       
    74         
       
    75     QList<QAction*> action_list = this->actions();
       
    76         
       
    77     for ( int i = 0; i < action_list.count(); i++ ) {
       
    78         this->removeAction(action_list.at(i));
       
    79         }
       
    80     
       
    81     mActionYes = new HbAction(hbTrId("txt_common_button_yes"),this); 
       
    82     this->addAction(mActionYes);
       
    83     
       
    84     HbAction* actionNo = new HbAction(hbTrId("txt_common_button_no"),this);
       
    85     this->addAction(actionNo);    
       
    86     
       
    87     disconnect(mActionYes, SIGNAL(triggered()),this, SLOT(close()));
       
    88     bool connected = connect(mActionYes, SIGNAL(triggered()), this, SLOT(yesPressed()));
       
    89     Q_ASSERT(connected == true);
       
    90     
       
    91     disconnect(actionNo, SIGNAL(triggered()),this, SLOT(close()));
       
    92     connected = connect(actionNo, SIGNAL(triggered()), this, SLOT(noPressed()));
       
    93     Q_ASSERT(connected == true);
       
    94         
       
    95     // Connect the about to close and hide signals, so that we are able to inform 
       
    96     // the caller that the dialog was closed    
       
    97     connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
       
    98     Q_ASSERT(connected == true);
       
    99     connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
       
   100     Q_ASSERT(connected == true);
       
   101    
       
   102     OstTraceFunctionExit0( DUP1_EAPGTCQUERYDIALOG_CREATEDIALOG_EXIT );
       
   103     qDebug("EapFastInstallPacQueryDialog::createDialog EXIT");
       
   104 }
       
   105 
       
   106 /**
       
   107  * Destructor
       
   108  */
       
   109 EapFastInstallPacQueryDialog::~EapFastInstallPacQueryDialog()
       
   110 {
       
   111     OstTraceFunctionEntry0( EAPGTCQUERYDIALOG_DEAPGTCQUERYDIALOG_ENTRY );
       
   112     
       
   113     // The dialog widgets are deleted as the dialog is deleted
       
   114     
       
   115     OstTraceFunctionExit0( EAPGTCQUERYDIALOG_DEAPGTCQUERYDIALOG_EXIT );
       
   116 }
       
   117 
       
   118 /**
       
   119  * Function is called when the Yes Action button is pressed
       
   120  */
       
   121 void EapFastInstallPacQueryDialog::yesPressed()
       
   122 {
       
   123     OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_YESBUTTONPRESSED_ENTRY );
       
   124     qDebug("EapFastInstallPacQueryDialog::yesPressed ENTER");
       
   125     
       
   126     if ( mYesActionPressed == false ) {
       
   127         
       
   128          mYesActionPressed = true;
       
   129             
       
   130          QVariantMap data;
       
   131          QVariant variant(yesButtonIndex);
       
   132          data.insert("yesbutton", variant);
       
   133          // emit the data of the selected button and close the dialog
       
   134          qDebug("EapFastInstallPacQueryDialog::yesPressed: emit deviceDialogData");
       
   135          emit deviceDialogData(data);   
       
   136          closeDeviceDialog(true);
       
   137     }
       
   138     OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_YESBUTTONPRESSED_EXIT );
       
   139     qDebug("EapFastInstallPacQueryDialog::yesPressed EXIT");
       
   140 }
       
   141 
       
   142 /**
       
   143  * Function is called when the No Action button is pressed
       
   144  */
       
   145 void EapFastInstallPacQueryDialog::noPressed()
       
   146 {
       
   147     OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_NOPRESSED_ENTRY );
       
   148     qDebug("EapFastInstallPacQueryDialog::noPressed ENTER");
       
   149     
       
   150     if (!mClose) {
       
   151         mClose = true;
       
   152         closeDeviceDialog(true);
       
   153     }   
       
   154     qDebug("EapFastInstallPacQueryDialog::noPressed EXIT");
       
   155     OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_NOPRESSED_EXIT );
       
   156 }
       
   157 
       
   158 /**
       
   159  * Function is called when the dialog is about to close
       
   160  * 
       
   161  */
       
   162 void EapFastInstallPacQueryDialog::closingDialog()
       
   163 {
       
   164     OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_CLOSINGDIALOG_ENTRY );
       
   165     qDebug("EapFastInstallPacQueryDialog::closingDialog ENTER");
       
   166  
       
   167     closeDeviceDialog(false);
       
   168     
       
   169     qDebug("EapFastInstallPacQueryDialog::closingDialog EXIT");
       
   170     OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_CLOSINGDIALOG_EXIT );
       
   171 }
       
   172 
       
   173 /**
       
   174  * Updating the dialog during its showing is not allowed.
       
   175  */ 
       
   176 bool EapFastInstallPacQueryDialog::setDeviceDialogParameters
       
   177                 (const QVariantMap &parameters)
       
   178 {
       
   179     OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY );
       
   180     
       
   181     Q_UNUSED(parameters)
       
   182     // changing the dialog after presenting it is not supported.
       
   183     
       
   184     OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT );
       
   185     return true;
       
   186 }
       
   187 
       
   188 /**
       
   189  * Not supported, 0 always returned
       
   190  */
       
   191 int EapFastInstallPacQueryDialog::deviceDialogError() const
       
   192 {
       
   193     OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_DEVICEDIALOGERROR_ENTRY );
       
   194     OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_DEVICEDIALOGERROR_EXIT);
       
   195     return 0;
       
   196 }
       
   197 
       
   198 /**
       
   199  * Dialog is closed and the signal about closing is emitted
       
   200  */
       
   201 void EapFastInstallPacQueryDialog::closeDeviceDialog(bool byClient)
       
   202 {   
       
   203     OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_CLOSEDEVICEDIALOG_ENTRY );
       
   204     qDebug("EapFastInstallPacQueryDialog::closeDeviceDialog ENTER");
       
   205             
       
   206     //If the user closes the dialog, then the deviceDialogClosed is emitted
       
   207     if ( byClient == true )
       
   208         {
       
   209         qDebug("EapFastInstallPacQueryDialog::closeDeviceDialog: emit deviceDialogClosed");
       
   210         emit deviceDialogClosed();
       
   211         }
       
   212     
       
   213     qDebug("EapFastInstallPacQueryDialog::closeDeviceDialog EXIT");
       
   214     OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_CLOSEDEVICEDIALOG_EXIT );
       
   215 }
       
   216 
       
   217 /**
       
   218  * This dialog widget is returned to the caller
       
   219  */
       
   220 HbPopup *EapFastInstallPacQueryDialog::deviceDialogWidget() const
       
   221 {
       
   222     OstTraceFunctionEntry0( EAPFASTINSTALLPACQUERYDIALOG_DEVICEDIALOGWIDGET_ENTRY );
       
   223     qDebug("EapFastInstallPacQueryDialog::deviceDialogWidget ENTER");
       
   224     
       
   225     qDebug("EapFastInstallPacQueryDialog::deviceDialogWidget EXIT");
       
   226     OstTraceFunctionExit0( EAPFASTINSTALLPACQUERYDIALOG_DEVICEDIALOGWIDGET_EXIT );
       
   227     
       
   228     return const_cast<EapFastInstallPacQueryDialog*>(this);
       
   229 }
       
   230