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