securitysettings/eapqtdialogs/src/eapfastpacstorepwquerydialog.cpp
changeset 49 43351a4f2da3
parent 44 22d80358905b
equal deleted inserted replaced
47:712b4ffd76bb 49:43351a4f2da3
    14 * Description: EAP-FAST PAC Store Password Query Dialog implementation
    14 * Description: EAP-FAST PAC Store Password Query Dialog implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 /*
    18 /*
    19 * %version: 7 %
    19 * %version: 12 %
    20 */
    20 */
    21 
    21 
    22 // System includes
    22 // System includes
    23 #include <HbTranslator>
    23 #include <HbTranslator>
    24 #include <HbAction>
    24 #include <HbAction>
    25 #include <HbTranslator>
    25 #include <HbTranslator>
    26 #include <HbMessageBox>
    26 #include <HbMessageBox>
    27 #include <HbParameterLengthLimiter>
    27 #include <HbParameterLengthLimiter>
    28 #include <eapqtvalidator.h>
    28 #include <HbEditorInterface>
    29 #include <eapqtexpandedeaptype.h>
    29 #include <EapSettings.h>
    30 #include <eapqtconfiginterface.h>
       
    31 #include <eapqtconfig.h>
       
    32 
    30 
    33 // User includes
    31 // User includes
    34 #include "eapfastpacstorepwquerydialog.h"
    32 #include "eapfastpacstorepwquerydialog.h"
    35 #include "OstTraceDefinitions.h"
    33 #include "OstTraceDefinitions.h"
    36 #ifdef OST_TRACE_COMPILER_IN_USE
    34 #ifdef OST_TRACE_COMPILER_IN_USE
    57  * 
    55  * 
    58  * @param [in]  parameters Parameters for the Constructor.
    56  * @param [in]  parameters Parameters for the Constructor.
    59  */
    57  */
    60 EapFastPacStorePwQueryDialog::EapFastPacStorePwQueryDialog(const QVariantMap &parameters) 
    58 EapFastPacStorePwQueryDialog::EapFastPacStorePwQueryDialog(const QVariantMap &parameters) 
    61  :mEdit(NULL), 
    59  :mEdit(NULL), 
    62  mPwdValidator(NULL),
       
    63  mTranslator(new HbTranslator("eapprompts")),
    60  mTranslator(new HbTranslator("eapprompts")),
    64  mErrMsgTranslator(new HbTranslator("cpdestinationplugin")),
    61  mErrMsgTranslator(new HbTranslator("cpdestinationplugin")),
    65  mClose(false)
    62  mClose(false)
    66 {
    63 {
    67     OstTraceFunctionEntry0( EAPFASTPACSTOREPWQUERYDIALOG_EAPFASTPACSTOREPWQUERYDIALOG_ENTRY );
    64     OstTraceFunctionEntry0( EAPFASTPACSTOREPWQUERYDIALOG_EAPFASTPACSTOREPWQUERYDIALOG_ENTRY );
    68     qDebug("EapFastPacStorePwQueryDialog::EapFastPacStorePwQueryDialog ENTER");
    65     qDebug("EapFastPacStorePwQueryDialog::EapFastPacStorePwQueryDialog ENTER");
    69     
    66     
    70     Q_UNUSED(parameters)
    67     Q_UNUSED(parameters)
    71           
    68 
    72     createDialog();
    69     createDialog();
    73      
    70      
    74     OstTraceFunctionExit0( EAPFASTPACSTOREPWQUERYDIALOG_EAPFASTPACSTOREPWQUERYDIALOG_EXIT );
    71     OstTraceFunctionExit0( EAPFASTPACSTOREPWQUERYDIALOG_EAPFASTPACSTOREPWQUERYDIALOG_EXIT );
    75     qDebug("EapFastPacStorePwQueryDialog::EapFastPacStorePwQueryDialog EXIT");
    72     qDebug("EapFastPacStorePwQueryDialog::EapFastPacStorePwQueryDialog EXIT");
    76 }
    73 }
    88     // Set the dialog to be on the screen for 60 seconds, unless
    85     // Set the dialog to be on the screen for 60 seconds, unless
    89     // the user reacts earlier
    86     // the user reacts earlier
    90     this->setModal(true);
    87     this->setModal(true);
    91     this->setTimeout(PacStorePwQueryTimeout);
    88     this->setTimeout(PacStorePwQueryTimeout);
    92     this->setDismissPolicy(HbPopup::NoDismiss);
    89     this->setDismissPolicy(HbPopup::NoDismiss);
       
    90     this->setDismissOnAction(false);    
    93     this->setPromptText(labelText, 0);  
    91     this->setPromptText(labelText, 0);  
    94     
    92     
    95     mEdit = this->lineEdit(0);
    93     mEdit = this->lineEdit(0);
    96     mEdit->setEchoMode(HbLineEdit::Password);
    94     mEdit->setEchoMode(HbLineEdit::Password);
    97       
    95     mEdit->setMaxLength(KGeneralStringMaxLength);
    98     EapQtConfigInterface eap_config_if;
    96     mEdit->setInputMethodHints(
    99         
    97         Qt::ImhNoAutoUppercase | Qt::ImhPreferLowercase | Qt::ImhNoPredictiveText);
   100     mPwdValidator.reset( eap_config_if.validatorPacStore(
    98     
   101                 EapQtPacStoreConfig::PacStorePasswordConfirmation) );    
    99     HbEditorInterface editInterface(mEdit);
   102     Q_ASSERT( mPwdValidator.isNull() == false );
   100     editInterface.setSmileyTheme(HbSmileyTheme());
   103     
   101 
   104     mPwdValidator->updateEditor(mEdit);
       
   105     
       
   106     
   102     
   107     //Remove all default actions from the dialog                   
   103     //Remove all default actions from the dialog                   
   108     QList<QAction*> action_list = this->actions();        
   104     QList<QAction*> action_list = this->actions();        
   109     for ( int i = 0; i < action_list.count(); i++ ) {
   105     for ( int i = 0; i < action_list.count(); i++ ) {
   110         this->removeAction(action_list.at(i));
   106         this->removeAction(action_list.at(i));
   116     
   112     
   117     //Add a new Cancel button action 
   113     //Add a new Cancel button action 
   118     HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this);
   114     HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this);
   119     this->addAction(actionCancel);    
   115     this->addAction(actionCancel);    
   120     
   116     
   121     //Disconnect action Ok from the default SLOT and connect to 
   117     //Connect to a SLOT owned by this class   
   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()));
   118     bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed()));
   125     Q_ASSERT(connected == true);
   119     Q_ASSERT(connected == true);
   126     
   120     
   127     //Disconnect action Cancel from the default SLOT and connect to 
   121     //Connect to a SLOT owned by this class  
   128     //a SLOT owned by this class  
       
   129     disconnect(actionCancel, SIGNAL(triggered()),this, SLOT(close()));
       
   130     connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed()));
   122     connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed()));
   131     Q_ASSERT(connected == true);
   123     Q_ASSERT(connected == true);
   132     
   124     
   133     // Connect the about to close and hide signals, so that we are able to inform 
   125     // Connect the about to close and hide signals, so that we are able to inform 
   134     // the caller that the dialog was closed   
   126     // the caller that the dialog was closed   
   147 EapFastPacStorePwQueryDialog::~EapFastPacStorePwQueryDialog()
   139 EapFastPacStorePwQueryDialog::~EapFastPacStorePwQueryDialog()
   148 {
   140 {
   149     OstTraceFunctionEntry0( EAPFASTPACSTOREPWQUERYDIALOG_DEAPFASTPACSTOREPWQUERYDIALOG_ENTRY );
   141     OstTraceFunctionEntry0( EAPFASTPACSTOREPWQUERYDIALOG_DEAPFASTPACSTOREPWQUERYDIALOG_ENTRY );
   150     
   142     
   151     // The dialog widgets are deleted as the dialog is deleted        
   143     // The dialog widgets are deleted as the dialog is deleted        
   152     // mPwdValidator:   scoped pointer deleted automatically
       
   153     
   144     
   154     OstTraceFunctionExit0( EAPFASTPACSTOREPWQUERYDIALOG_DEAPFASTPACSTOREPWQUERYDIALOG_EXIT );
   145     OstTraceFunctionExit0( EAPFASTPACSTOREPWQUERYDIALOG_DEAPFASTPACSTOREPWQUERYDIALOG_EXIT );
   155 }
   146 }
   156 
   147 
   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 
   148 
   177 /*!
   149 /*!
   178  * Function is called when the Ok Action button is pressed
   150  * Function is called when the Ok Action button is pressed
   179  */
   151  */
   180 void EapFastPacStorePwQueryDialog::okPressed()
   152 void EapFastPacStorePwQueryDialog::okPressed()
   181 {
   153 {
   182     OstTraceFunctionEntry0( EAPFASTPACSTOREPWQUERYDIALOG_OKPRESSED_ENTRY );
   154     OstTraceFunctionEntry0( EAPFASTPACSTOREPWQUERYDIALOG_OKPRESSED_ENTRY );
   183     qDebug("EapFastPacStorePwQueryDialog::okPressed ENTER");
   155     qDebug("EapFastPacStorePwQueryDialog::okPressed ENTER");
   184     
   156     
   185     if ( validate() == true ) {
   157     QVariantMap data;
       
   158         
       
   159     data["password"] = mEdit->text();
       
   160       
       
   161     qDebug("EapFastPacStorePwQueryDialog::okPressed: emit deviceDialogData");
       
   162     
       
   163     emit deviceDialogData(data); 
   186             
   164             
   187         QVariantMap data;
   165     OstTraceFunctionExit0( EAPFASTPACSTOREPWQUERYDIALOG_OKPRESSED_EXIT );
   188         
   166     qDebug("EapFastPacStorePwQueryDialog::okPressed EXIT");
   189         data["password"] = mEdit->text();
   167 }
   190       
   168 
   191         qDebug("EapFastPacStorePwQueryDialog::okPressed: emit deviceDialogData");
   169 /*!
   192     
   170  * Function is called when the Cancel Action button is pressed
   193         emit deviceDialogData(data); 
   171  */
       
   172 void EapFastPacStorePwQueryDialog::cancelPressed()
       
   173 {
       
   174     OstTraceFunctionEntry0( EAPFASTPACSTOREPWQUERYDIALOG_CANCELPRESSED_ENTRY );
       
   175     qDebug("EapFastPacStorePwQueryDialog::cancelPressed ENTER");
       
   176     
       
   177     if (!mClose) {
       
   178         mClose = true;
       
   179         closeDeviceDialog(true);
       
   180     }   
       
   181     qDebug("EapFastPacStorePwQueryDialog::cancelPressed EXIT");
       
   182     OstTraceFunctionExit0( EAPFASTPACSTOREPWQUERYDIALOG_CANCELPRESSED_EXIT );
       
   183 }
       
   184 
       
   185 /*!
       
   186  * Function is called when the dialog is about to close
       
   187  */
       
   188 void EapFastPacStorePwQueryDialog::closingDialog()
       
   189 {
       
   190     OstTraceFunctionEntry0( EAPFASTPACSTOREPWQUERYDIALOG_CLOSINGDIALOG_ENTRY );
       
   191     qDebug("EapFastPacStorePwQueryDialog::closingDialog ENTER");
       
   192      
       
   193     qDebug("EapFastPacStorePwQueryDialog::closingDialog EXIT");
       
   194     OstTraceFunctionExit0( EAPFASTPACSTOREPWQUERYDIALOG_CLOSINGDIALOG_EXIT );
       
   195 }
       
   196 
       
   197 /*!
       
   198  * Device dialog parameters to be set while dialog is displayed.
       
   199  *
       
   200  * @param [in] parameters Parameters for the method
       
   201  * @return true always.
       
   202  */  
       
   203 bool EapFastPacStorePwQueryDialog::setDeviceDialogParameters
       
   204                 (const QVariantMap &parameters)
       
   205 {
       
   206     OstTraceFunctionEntry0( EAPFASTPACSTOREPWQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY );
       
   207     qDebug("EapFastPacStorePwQueryDialog::setDeviceDialogParameters ENTER");
       
   208         
       
   209     QString key("pwdcorrectind");
       
   210     
       
   211     bool isPwdCorrect = false;
       
   212     
       
   213     //Get the needed information from parameters that indicates 
       
   214     //the correctness of the password 
       
   215     if ( parameters.empty() == false ) {
       
   216         if ( parameters.contains(key) ) {
       
   217             QVariant variant = parameters.value(key);
       
   218             isPwdCorrect = variant.toBool();
       
   219             }
       
   220         }      
       
   221     
       
   222     if ( isPwdCorrect != false ) {
       
   223         qDebug("EapFastPacStorePwQueryDialog::setDeviceDialogParameters: isPwdCorrect == TRUE");    
   194         closeDeviceDialog(true);
   224         closeDeviceDialog(true);
   195         }
   225         }
   196     else {
   226     else {
   197         HbMessageBox *box = 
   227         HbMessageBox *box = 
   198             new HbMessageBox(hbTrId("txt_occ_info_incorrect_password_msg_box"),
   228             new HbMessageBox(hbTrId("txt_occ_info_incorrect_password_msg_box"),
   199             HbMessageBox::MessageTypeInformation);
   229             HbMessageBox::MessageTypeInformation);
   200         
   230         
   201         box->setAttribute(Qt::WA_DeleteOnClose);
   231         box->setAttribute(Qt::WA_DeleteOnClose);
   202         box->open();       
   232         box->open();       
   203         }
   233         }
   204         
   234    
   205     OstTraceFunctionExit0( EAPFASTPACSTOREPWQUERYDIALOG_OKPRESSED_EXIT );
   235     qDebug("EapFastPacStorePwQueryDialog::setDeviceDialogParameters 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 );
   236     OstTraceFunctionExit0( EAPFASTPACSTOREPWQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT );
   253     return true;
   237     return true;
   254 }
   238 }
   255 
   239 
   256 /*!
   240 /*!