securitysettings/eapqtdialogs/src/eapmschapv2oldpwddialog.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 <eapqtvalidator.h>
       
    19 #include <eapqtexpandedeaptype.h>
       
    20 #include <eapqtconfiginterface.h>
       
    21 #include <eapqtconfig.h>
       
    22 #include "eapmschapv2oldpwddialog.h"
       
    23 #include "OstTraceDefinitions.h"
       
    24 #ifdef OST_TRACE_COMPILER_IN_USE
       
    25 #endif
       
    26 
       
    27 
       
    28 /**
       
    29  * The constructor
       
    30  */
       
    31 EapMschapv2OldPwdDialog::EapMschapv2OldPwdDialog(const QVariantMap &parameters) 
       
    32  :mEdit(NULL), 
       
    33  mPwdValidator(NULL),
       
    34  mActionOk(NULL),
       
    35  mTranslator(new HbTranslator("eapprompts"))
       
    36 {
       
    37     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_EAPFASTPACSTOREQUERYDIALOG_ENTRY );
       
    38     qDebug("EapMschapv2OldPwdDialog::EapMschapv2OldPwdDialog ENTER");
       
    39         
       
    40     createDialog(parameters);
       
    41     
       
    42     mClose = false;
       
    43     
       
    44     OstTraceFunctionExit0( EAPFASTPACSTOREQUERYDIALOG_EAPFASTPACSTOREQUERYDIALOG_EXIT );
       
    45     qDebug("EapMschapv2OldPwdDialog::EapMschapv2OldPwdDialog EXIT");
       
    46 }
       
    47     
       
    48 /**
       
    49  * The construction of the dialog
       
    50  */ 
       
    51 void EapMschapv2OldPwdDialog::createDialog(const QVariantMap &parameters )
       
    52 {
       
    53     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_CREATEDIALOG_ENTRY );
       
    54     qDebug("EapMschapv2OldPwdDialog::createDialog ENTER");
       
    55 
       
    56     QString labelText1 = QString(hbTrId("txt_occ_dialog_old_eapmschapv2_password"));
       
    57     
       
    58     Q_UNUSED(parameters)
       
    59     
       
    60     //Set the dialog to be on the screen until user reacts
       
    61     //by pressing any of the Action buttons
       
    62     this->setModal(true);
       
    63     this->setTimeout(HbPopup::NoTimeout);
       
    64     this->setDismissPolicy(HbPopup::NoDismiss);    
       
    65     this->setPromptText(labelText1, 0);      
       
    66     mEdit = this->lineEdit(0);
       
    67     mEdit->setEchoMode(HbLineEdit::Password);
       
    68       
       
    69     EapQtConfigInterface eap_config_if;
       
    70     
       
    71     mPwdValidator = eap_config_if.validatorEap(EapQtExpandedEapType::TypeEapMschapv2, 
       
    72                EapQtConfig::Password );      
       
    73     mPwdValidator->updateEditor(mEdit);
       
    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     mActionOk = new HbAction(hbTrId("txt_common_button_ok"),this); 
       
    82     this->addAction(mActionOk);
       
    83     
       
    84     HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this);
       
    85     this->addAction(actionCancel);    
       
    86      
       
    87     disconnect(mActionOk, SIGNAL(triggered()),this, SLOT(close()));
       
    88     bool connected = connect(mActionOk, SIGNAL(triggered()), this, SLOT(okPressed()));
       
    89     Q_ASSERT(connected == true);
       
    90     
       
    91     disconnect(actionCancel, SIGNAL(triggered()),this, SLOT(close()));
       
    92     connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed()));
       
    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_EAPFASTPACSTOREQUERYDIALOG_CREATEDIALOG_EXIT );
       
   103     qDebug("EapMschapv2OldPwdDialog::createDialog EXIT");
       
   104 }
       
   105 
       
   106 /**
       
   107  * Destructor
       
   108  */
       
   109 EapMschapv2OldPwdDialog::~EapMschapv2OldPwdDialog()
       
   110 {
       
   111     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_DEAPFASTPACSTOREQUERYDIALOG_ENTRY );
       
   112     
       
   113     // The dialog widgets are deleted as the dialog is deleted
       
   114     delete mPwdValidator;
       
   115     
       
   116     OstTraceFunctionExit0( EAPFASTPACSTOREQUERYDIALOG_DEAPFASTPACSTOREQUERYDIALOG_EXIT );
       
   117 }
       
   118 
       
   119 /**
       
   120  * Line edit validator
       
   121  */
       
   122 bool EapMschapv2OldPwdDialog::validate() const
       
   123 {
       
   124     qDebug("EapMschapv2OldPwdDialog::validate");
       
   125     
       
   126     bool valid = false;
       
   127 
       
   128     if ( mPwdValidator->validate(mEdit->text())== EapQtValidator::StatusOk ) {
       
   129         qDebug("EapMschapv2OldPwdDialog::validate: returns TRUE");
       
   130         valid = true;
       
   131     }
       
   132     return valid;
       
   133 }
       
   134 
       
   135 /**
       
   136  * Function is called when the Ok Action button is pressed
       
   137  */
       
   138 void EapMschapv2OldPwdDialog::okPressed()
       
   139 {
       
   140     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_FIRSTBUTTONPRESSED_ENTRY );
       
   141     qDebug("EapMschapv2OldPwdDialog::okPressed ENTER");
       
   142     
       
   143     if ( validate() == true ) {
       
   144             
       
   145         QVariantMap data;
       
   146     
       
   147         QString editStr = mEdit->text();
       
   148             
       
   149         QVariant variant(editStr);
       
   150     
       
   151         data["password"] = variant;
       
   152       
       
   153         qDebug("EapMschapv2OldPwdDialog::okPressed: emit deviceDialogData");
       
   154     
       
   155         emit deviceDialogData(data); 
       
   156         closeDeviceDialog(true);
       
   157         }
       
   158 
       
   159     OstTraceFunctionExit0( EAPFASTPACSTOREQUERYDIALOG_FIRSTBUTTONPRESSED_EXIT );
       
   160     qDebug("EapMschapv2OldPwdDialog::okPressed EXIT");
       
   161 }
       
   162 
       
   163 /**
       
   164  * Function is called when the Cancel Action button is pressed
       
   165  */
       
   166 void EapMschapv2OldPwdDialog::cancelPressed()
       
   167 {
       
   168     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_CANCELPRESSED_ENTRY );
       
   169     qDebug("EapMschapv2OldPwdDialog::cancelPressed ENTER");
       
   170     
       
   171     if (!mClose) {
       
   172         mClose = true;
       
   173         closeDeviceDialog(true);
       
   174     }   
       
   175     qDebug("EapMschapv2OldPwdDialog::cancelPressed EXIT");
       
   176     OstTraceFunctionExit0( EAPFASTPACSTOREQUERYDIALOG_CANCELPRESSED_EXIT );
       
   177 }
       
   178 
       
   179 /**
       
   180  * Function is called when the dialog is about to close
       
   181  * 
       
   182  */
       
   183 void EapMschapv2OldPwdDialog::closingDialog()
       
   184 {
       
   185     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_CLOSINGDIALOG_ENTRY );
       
   186     qDebug("EapMschapv2OldPwdDialog::closingDialog ENTER");
       
   187  
       
   188     closeDeviceDialog(false);
       
   189     
       
   190     qDebug("EapMschapv2OldPwdDialog::closingDialog EXIT");
       
   191     OstTraceFunctionExit0( EAPFASTPACSTOREQUERYDIALOG_CLOSINGDIALOG_EXIT );
       
   192 }
       
   193 
       
   194 /**
       
   195  * Updating the dialog during its showing is not allowed.
       
   196  */ 
       
   197 bool EapMschapv2OldPwdDialog::setDeviceDialogParameters
       
   198                 (const QVariantMap &parameters)
       
   199 {
       
   200     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY );
       
   201     
       
   202     Q_UNUSED(parameters)
       
   203     // changing the dialog after presenting it is not supported.
       
   204     
       
   205     OstTraceFunctionExit0( EAPFASTPACSTOREQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT );
       
   206     return true;
       
   207 }
       
   208 
       
   209 /**
       
   210  * Not supported, 0 always returned
       
   211  */
       
   212 int EapMschapv2OldPwdDialog::deviceDialogError() const
       
   213 {
       
   214     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_DEVICEDIALOGERROR_ENTRY );
       
   215     OstTraceFunctionExit0( EAPFASTPACSTOREQUERYDIALOG_DEVICEDIALOGERROR_EXIT);
       
   216     return 0;
       
   217 }
       
   218 
       
   219 /**
       
   220  * Dialog is closed and the signal about closing is emitted
       
   221  */
       
   222 void EapMschapv2OldPwdDialog::closeDeviceDialog(bool byClient)
       
   223 {   
       
   224     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_CLOSEDEVICEDIALOG_ENTRY );
       
   225     qDebug("EapMschapv2OldPwdDialog::closeDeviceDialog ENTER");
       
   226             
       
   227     //If the user closes the dialog, then the deviceDialogClosed is emitted
       
   228     if ( byClient == true ) {  
       
   229         qDebug("EapMschapv2OldPwdDialog::closeDeviceDialog: emit deviceDialogClosed");  
       
   230         emit deviceDialogClosed(); 
       
   231         }
       
   232     
       
   233     qDebug("EapMschapv2OldPwdDialog::closeDeviceDialog EXIT");
       
   234     OstTraceFunctionExit0( EAPFASTPACSTOREQUERYDIALOG_CLOSEDEVICEDIALOG_EXIT );
       
   235 }
       
   236 
       
   237 /**
       
   238  * This dialog widget is returned to the caller
       
   239  */
       
   240 HbPopup *EapMschapv2OldPwdDialog::deviceDialogWidget() const
       
   241 {
       
   242     OstTraceFunctionEntry0( EAPFASTPACSTOREQUERYDIALOG_DEVICEDIALOGWIDGET_ENTRY );
       
   243     OstTraceFunctionExit0( EAPFASTPACSTOREQUERYDIALOG_DEVICEDIALOGWIDGET_EXIT );
       
   244     
       
   245     return const_cast<EapMschapv2OldPwdDialog*>(this);
       
   246 }
       
   247