securitysettings/eapqtdialogs/src/eapfastcreatemasterkeyquerydialog.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
parent 45 bad0cc58d154
child 55 9c2aa05919d9
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
     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: EAP-FAST Create Master Key Query Dialog implementation
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 6 %
       
    20 */
       
    21 
       
    22 // System includes
       
    23 #include <HbLineEdit>
       
    24 #include <HbAction>
       
    25 #include <HbMessageBox>
       
    26 #include <HbTranslator>
       
    27 #include <eapqtvalidator.h>
       
    28 #include <eapqtexpandedeaptype.h>
       
    29 #include <eapqtconfiginterface.h>
       
    30 #include <eapqtconfig.h>
       
    31 
       
    32 // User includes
       
    33 #include "eapfastcreatemasterkeyquerydialog.h"
       
    34 #include "OstTraceDefinitions.h"
       
    35 #ifdef OST_TRACE_COMPILER_IN_USE
       
    36 #include "eapfastcreatemasterkeyquerydialogTraces.h"
       
    37 #endif
       
    38 
       
    39 /*!
       
    40  * \class EapFastCreateMasterKeyQueryDialog
       
    41  * \brief Implements EAP-FAST Create Master Key Query Dialog. 
       
    42  */
       
    43 
       
    44 // External function prototypes
       
    45 
       
    46 // Local constants
       
    47  
       
    48 // ======== LOCAL FUNCTIONS ========
       
    49 
       
    50 // ======== MEMBER FUNCTIONS ========
       
    51 
       
    52 /*!
       
    53  * Constructor.
       
    54  * 
       
    55  * @param [in]  parameters Parameters for the Constructor.
       
    56  */
       
    57 EapFastCreateMasterKeyQueryDialog::EapFastCreateMasterKeyQueryDialog(const QVariantMap &parameters) 
       
    58  :mEdit1(NULL), 
       
    59   mEdit2(NULL), 
       
    60   mPwdValidator(NULL),
       
    61   mTranslator(new HbTranslator("eapprompts")),
       
    62   mErrMsgTranslator(new HbTranslator("cpdestinationplugin")),
       
    63   mClose(false),
       
    64   mOkActionPressed(false)
       
    65 {
       
    66     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_EAPFASTCREATEMASTERKEYQUERYDIALOG_ENTRY );
       
    67     qDebug("EapFastCreateMasterKeyQueryDialog::EapFastCreateMasterKeyQueryDialog ENTER");
       
    68        
       
    69     createDialog(parameters);
       
    70         
       
    71     OstTraceFunctionExit0( EAPFASTCREATEMASTERKEYQUERYDIALOG_EAPFASTCREATEMASTERKEYQUERYDIALOG_EXIT );
       
    72     qDebug("EapFastCreateMasterKeyQueryDialog::EapFastCreateMasterKeyQueryDialog EXIT");
       
    73 }
       
    74     
       
    75 /*!
       
    76  * The construction of the dialog
       
    77  *
       
    78  * @param [in] parameters Parameters for the Construction of the dialog.
       
    79  */ 
       
    80 void EapFastCreateMasterKeyQueryDialog::createDialog(const QVariantMap &parameters )
       
    81 {
       
    82     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_CREATEDIALOG_ENTRY );
       
    83     qDebug("EapFastCreateMasterKeyQueryDialog::createDialog ENTER");
       
    84     
       
    85     Q_UNUSED(parameters)
       
    86     
       
    87     QString labelText1(hbTrId("txt_occ_dialog_create_password_for_encrypted_pac_s"));
       
    88     QString labelText2(hbTrId("txt_occ_dialog_verify_password"));
       
    89         
       
    90     //Set the dialog to be on the screen until user reacts
       
    91     //by pressing any of the Action buttons
       
    92     this->setModal(true);
       
    93     this->setTimeout(HbPopup::NoTimeout);
       
    94     this->setDismissPolicy(HbPopup::NoDismiss);    
       
    95     this->setAdditionalRowVisible(true);
       
    96     
       
    97     this->setPromptText(labelText1, 0);   
       
    98     mEdit1 = this->lineEdit(0);
       
    99     mEdit1->setEchoMode(HbLineEdit::Password);
       
   100     
       
   101     this->setPromptText(labelText2, 1);   
       
   102     mEdit2 = this->lineEdit(1);        
       
   103     mEdit2->setEchoMode(HbLineEdit::Password);
       
   104     
       
   105     EapQtConfigInterface eap_config_if;
       
   106     
       
   107     mPwdValidator.reset( eap_config_if.validatorPacStore(
       
   108                 EapQtPacStoreConfig::PacStorePassword) ); 
       
   109     Q_ASSERT( mPwdValidator.isNull() == false );                
       
   110                      
       
   111     mPwdValidator->updateEditor(mEdit1);
       
   112     
       
   113    
       
   114     //Remove all default actions from the dialog  
       
   115     QList<QAction*> action_list = this->actions();        
       
   116     for ( int i = 0; i < action_list.count(); i++ ) {
       
   117         this->removeAction(action_list.at(i));
       
   118         } 
       
   119     
       
   120     //Add a new Ok button action 
       
   121     HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this); 
       
   122     this->addAction(actionOk);
       
   123     
       
   124     //Add a new Cancel button action 
       
   125     HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this);
       
   126     this->addAction(actionCancel);    
       
   127     
       
   128     //Disconnect action Ok from the default SLOT and connect to 
       
   129     //a SLOT owned by this class    
       
   130     disconnect(actionOk, SIGNAL(triggered()),this, SLOT(close()));
       
   131     bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed()));
       
   132     Q_ASSERT(connected == true);
       
   133     
       
   134     //Disconnect action Cancel from the default SLOT and connect to 
       
   135     //a SLOT owned by this class  
       
   136     disconnect(actionCancel, SIGNAL(triggered()),this, SLOT(close()));
       
   137     connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed()));
       
   138     Q_ASSERT(connected == true);
       
   139     
       
   140     // Connect the about to close and hide signals, so that we are able to inform 
       
   141     // the caller that the dialog was closed   
       
   142     connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
       
   143     Q_ASSERT(connected == true);
       
   144     connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
       
   145     Q_ASSERT(connected == true);
       
   146    
       
   147     OstTraceFunctionExit0( DUP1_EAPFASTCREATEMASTERKEYQUERYDIALOG_CREATEDIALOG_EXIT );
       
   148     qDebug("EapFastCreateMasterKeyQueryDialog::createDialog EXIT");
       
   149 }
       
   150 
       
   151 /*!
       
   152  * Destructor.
       
   153  */
       
   154 EapFastCreateMasterKeyQueryDialog::~EapFastCreateMasterKeyQueryDialog()
       
   155 {
       
   156     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_DEAPFASTCREATEMASTERKEYQUERYDIALOG_ENTRY );
       
   157     qDebug("EapFastCreateMasterKeyQueryDialog::~EapFastCreateMasterKeyQueryDialog");
       
   158     
       
   159     //The dialog widgets are deleted as the dialog is deleted
       
   160     // mPwdValidator:   scoped pointer deleted automatically
       
   161     
       
   162     OstTraceFunctionExit0( EAPFASTCREATEMASTERKEYQUERYDIALOG_DEAPFASTCREATEMASTERKEYQUERYDIALOG_EXIT );
       
   163 }
       
   164 
       
   165 /*!
       
   166  * Line edit validator
       
   167  *
       
   168  * @return true if content is valid.
       
   169  */
       
   170 bool EapFastCreateMasterKeyQueryDialog::validate() const
       
   171 {
       
   172     qDebug("EapFastCreateMasterKeyQueryDialog::validate");
       
   173     
       
   174     bool valid = false;
       
   175     
       
   176     if ( mPwdValidator->validate(mEdit1->text())== EapQtValidator::StatusOk &&
       
   177         mEdit1->text() == mEdit2->text()) {
       
   178         qDebug("EapFastCreateMasterKeyQueryDialog::validate: ret val: TRUE");
       
   179         valid = true;
       
   180     }
       
   181     return valid;
       
   182 }
       
   183 
       
   184 /*!
       
   185  * Function is called when the Ok Action button is pressed
       
   186  */
       
   187 void EapFastCreateMasterKeyQueryDialog::okPressed()
       
   188 {
       
   189     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_FIRSTBUTTONPRESSED_ENTRY );
       
   190     qDebug("EapFastCreateMasterKeyQueryDialog::okPressed ENTER");
       
   191     
       
   192     if ( validate() == true ) {
       
   193          
       
   194             QVariantMap data;
       
   195        
       
   196             data["password"] = mEdit1->text();
       
   197       
       
   198             qDebug("EapFastCreateMasterKeyQueryDialog::okPressed: emit deviceDialogData");
       
   199     
       
   200             emit deviceDialogData(data); 
       
   201             closeDeviceDialog(true);
       
   202         }
       
   203     else {
       
   204         HbMessageBox *box = 
       
   205             new HbMessageBox(hbTrId("txt_occ_info_passwords_do_not_match_try_again"),
       
   206             HbMessageBox::MessageTypeInformation);
       
   207         box->setAttribute(Qt::WA_DeleteOnClose);
       
   208         box->open();       
       
   209         }
       
   210     OstTraceFunctionExit0( EAPFASTCREATEMASTERKEYQUERYDIALOG_FIRSTBUTTONPRESSED_EXIT );
       
   211     qDebug("EapFastCreateMasterKeyQueryDialog::okPressed EXIT");
       
   212 }
       
   213 
       
   214 /*!
       
   215  * Function is called when the Cancel Action button is pressed
       
   216  */
       
   217 void EapFastCreateMasterKeyQueryDialog::cancelPressed()
       
   218 {
       
   219     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_CANCELPRESSED_ENTRY );
       
   220     qDebug("EapFastCreateMasterKeyQueryDialog::cancelPressed ENTER");
       
   221     
       
   222     if (!mClose) {
       
   223         mClose = true;
       
   224         closeDeviceDialog(true);
       
   225     }   
       
   226     qDebug("EapFastCreateMasterKeyQueryDialog::cancelPressed EXIT");
       
   227     OstTraceFunctionExit0( EAPFASTCREATEMASTERKEYQUERYDIALOG_CANCELPRESSED_EXIT );
       
   228 }
       
   229 
       
   230 /*!
       
   231  * Function is called when the dialog is about to close
       
   232  */
       
   233 void EapFastCreateMasterKeyQueryDialog::closingDialog()
       
   234 {
       
   235     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_CLOSINGDIALOG_ENTRY );
       
   236     qDebug("EapFastCreateMasterKeyQueryDialog::closingDialog ENTER");
       
   237  
       
   238     qDebug("EapFastCreateMasterKeyQueryDialog::closingDialog EXIT");
       
   239     OstTraceFunctionExit0( EAPFASTCREATEMASTERKEYQUERYDIALOG_CLOSINGDIALOG_EXIT );
       
   240 }
       
   241 
       
   242 /*!
       
   243  * Device dialog parameters to be set while dialog is displayed.
       
   244  * Not supported. 
       
   245  *
       
   246  * @param [in] parameters NOT USED
       
   247  * @return true always.
       
   248  */  
       
   249 bool EapFastCreateMasterKeyQueryDialog::setDeviceDialogParameters
       
   250                 (const QVariantMap &parameters)
       
   251 {
       
   252     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY );
       
   253     
       
   254     Q_UNUSED(parameters)
       
   255     // changing the dialog after presenting it is not supported.
       
   256     
       
   257     OstTraceFunctionExit0( EAPFASTCREATEMASTERKEYQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT );
       
   258     return true;
       
   259 }
       
   260 
       
   261 /*!
       
   262  * Not supported
       
   263  *
       
   264  * @return 0 always returned.
       
   265  */
       
   266 int EapFastCreateMasterKeyQueryDialog::deviceDialogError() const
       
   267 {
       
   268     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_DEVICEDIALOGERROR_ENTRY );
       
   269     OstTraceFunctionExit0( EAPFASTCREATEMASTERKEYQUERYDIALOG_DEVICEDIALOGERROR_EXIT);
       
   270     return 0;
       
   271 }
       
   272 
       
   273 /*!
       
   274  * Dialog is closed and the signal about closing is emitted
       
   275  *
       
   276  * @param [in] byClient indicates when the user closes the dialog
       
   277  */
       
   278 void EapFastCreateMasterKeyQueryDialog::closeDeviceDialog(bool byClient)
       
   279 {   
       
   280     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_CLOSEDEVICEDIALOG_ENTRY );
       
   281     qDebug("EapFastCreateMasterKeyQueryDialog::closeDeviceDialog ENTER");
       
   282         
       
   283     //If the user closes the dialog, then the deviceDialogClosed is emitted
       
   284     if ( byClient == true )
       
   285         {
       
   286         qDebug("EapFastCreateMasterKeyQueryDialog::closeDeviceDialog: emit deviceDialogClosed");
       
   287         emit deviceDialogClosed();
       
   288         }
       
   289     
       
   290     qDebug("EapFastCreateMasterKeyQueryDialog::closeDeviceDialog EXIT");
       
   291     OstTraceFunctionExit0( EAPFASTCREATEMASTERKEYQUERYDIALOG_CLOSEDEVICEDIALOG_EXIT );
       
   292 }
       
   293 
       
   294 /*!
       
   295  * This dialog widget is returned to the caller
       
   296  *
       
   297  * @return this dialog widget
       
   298  */
       
   299 HbPopup *EapFastCreateMasterKeyQueryDialog::deviceDialogWidget() const
       
   300 {
       
   301     OstTraceFunctionEntry0( EAPFASTCREATEMASTERKEYQUERYDIALOG_DEVICEDIALOGWIDGET_ENTRY );
       
   302     OstTraceFunctionExit0( EAPFASTCREATEMASTERKEYQUERYDIALOG_DEVICEDIALOGWIDGET_EXIT );
       
   303     
       
   304     return const_cast<EapFastCreateMasterKeyQueryDialog*>(this);
       
   305 }
       
   306