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