securitysettings/eapqtdialogs/src/eapquerydialog.cpp
author hgs
Mon, 23 Aug 2010 13:36:11 +0300
changeset 44 22d80358905b
parent 36 c98682f98478
child 49 43351a4f2da3
permissions -rw-r--r--
201033
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
36
hgs
parents: 34
diff changeset
    14
* Description: EAP Challenge query Dialog implementation
34
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
/*
44
hgs
parents: 36
diff changeset
    19
* %version: 4 %
34
hgs
parents:
diff changeset
    20
*/
hgs
parents:
diff changeset
    21
36
hgs
parents: 34
diff changeset
    22
// System includes
34
hgs
parents:
diff changeset
    23
#include <HbLabel>
hgs
parents:
diff changeset
    24
#include <HbAction>
hgs
parents:
diff changeset
    25
#include <HbTranslator>
hgs
parents:
diff changeset
    26
#include <HbParameterLengthLimiter>
36
hgs
parents: 34
diff changeset
    27
hgs
parents: 34
diff changeset
    28
// User includes
34
hgs
parents:
diff changeset
    29
#include "eapquerydialog.h"
hgs
parents:
diff changeset
    30
#include "OstTraceDefinitions.h"
hgs
parents:
diff changeset
    31
#ifdef OST_TRACE_COMPILER_IN_USE
44
hgs
parents: 36
diff changeset
    32
#include "eapquerydialogTraces.h"
34
hgs
parents:
diff changeset
    33
#endif
hgs
parents:
diff changeset
    34
36
hgs
parents: 34
diff changeset
    35
/*!
hgs
parents: 34
diff changeset
    36
 * \class EapQueryDialog
hgs
parents: 34
diff changeset
    37
 * \brief Implements EAP Challenge query Dialog. 
hgs
parents: 34
diff changeset
    38
 */
hgs
parents: 34
diff changeset
    39
hgs
parents: 34
diff changeset
    40
// External function prototypes
hgs
parents: 34
diff changeset
    41
hgs
parents: 34
diff changeset
    42
// Local constants
34
hgs
parents:
diff changeset
    43
36
hgs
parents: 34
diff changeset
    44
//! The index numbers of the button of the dialog
hgs
parents: 34
diff changeset
    45
static const int okButtonIndex = 1;
hgs
parents: 34
diff changeset
    46
 
hgs
parents: 34
diff changeset
    47
// ======== LOCAL FUNCTIONS ========
hgs
parents: 34
diff changeset
    48
hgs
parents: 34
diff changeset
    49
// ======== MEMBER FUNCTIONS ========
hgs
parents: 34
diff changeset
    50
hgs
parents: 34
diff changeset
    51
/*!
hgs
parents: 34
diff changeset
    52
 * Constructor.
hgs
parents: 34
diff changeset
    53
 * 
hgs
parents: 34
diff changeset
    54
 * @param [in]  parameters Parameters for the Constructor.
34
hgs
parents:
diff changeset
    55
 */
hgs
parents:
diff changeset
    56
EapQueryDialog::EapQueryDialog(const QVariantMap &parameters)
hgs
parents:
diff changeset
    57
:mTranslator(new HbTranslator("eapprompts")),
hgs
parents:
diff changeset
    58
mOkActionPressed(false)    
hgs
parents:
diff changeset
    59
{
hgs
parents:
diff changeset
    60
    OstTraceFunctionEntry0( EAPQUERYDIALOG_EAPQUERYDIALOG_ENTRY );
hgs
parents:
diff changeset
    61
    qDebug("EapQueryDialog::EapQueryDialog ENTER");
hgs
parents:
diff changeset
    62
        
hgs
parents:
diff changeset
    63
    createDialog( parameters );
hgs
parents:
diff changeset
    64
    
hgs
parents:
diff changeset
    65
    OstTraceFunctionExit0( EAPQUERYDIALOG_EAPQUERYDIALOG_EXIT );
hgs
parents:
diff changeset
    66
    qDebug("EapQueryDialog::EapQueryDialog EXIT");
hgs
parents:
diff changeset
    67
}
hgs
parents:
diff changeset
    68
36
hgs
parents: 34
diff changeset
    69
/*!
34
hgs
parents:
diff changeset
    70
 * The construction of the dialog
36
hgs
parents: 34
diff changeset
    71
 *
hgs
parents: 34
diff changeset
    72
 * @param [in] parameters Parameters for the Construction of the dialog.
34
hgs
parents:
diff changeset
    73
 */ 
hgs
parents:
diff changeset
    74
void EapQueryDialog::createDialog(const QVariantMap &parameters )
hgs
parents:
diff changeset
    75
{
hgs
parents:
diff changeset
    76
    OstTraceFunctionEntry0( EAPQUERYDIALOG_CREATEDIALOG_ENTRY );
hgs
parents:
diff changeset
    77
    qDebug("EapQueryDialog::createDialog ENTER");
hgs
parents:
diff changeset
    78
     
hgs
parents:
diff changeset
    79
    QString message;   
hgs
parents:
diff changeset
    80
    QString authMethodstr; 
hgs
parents:
diff changeset
    81
    QString keyauthmethod("authmethod");  
hgs
parents:
diff changeset
    82
    QString keymessage("messagetxt");    
hgs
parents:
diff changeset
    83
    QVariant tmpVariant;  
hgs
parents:
diff changeset
    84
    
hgs
parents:
diff changeset
    85
    //Get auth method and message string from parameters          
hgs
parents:
diff changeset
    86
    if ( parameters.empty() == false ) {
hgs
parents:
diff changeset
    87
      
hgs
parents:
diff changeset
    88
        if ( parameters.contains(keyauthmethod) ) {
hgs
parents:
diff changeset
    89
            tmpVariant = parameters.value(keyauthmethod);
hgs
parents:
diff changeset
    90
            authMethodstr = tmpVariant.toString();
hgs
parents:
diff changeset
    91
            }  
hgs
parents:
diff changeset
    92
        if ( parameters.contains(keymessage) ) {
hgs
parents:
diff changeset
    93
            tmpVariant = parameters.value(keymessage);
hgs
parents:
diff changeset
    94
            message = tmpVariant.toString();
hgs
parents:
diff changeset
    95
            }
hgs
parents:
diff changeset
    96
        }    
hgs
parents:
diff changeset
    97
    
hgs
parents:
diff changeset
    98
    QString labelText1(HbParameterLengthLimiter(
hgs
parents:
diff changeset
    99
        hbTrId("txt_occ_title_1_message").arg(authMethodstr)));
hgs
parents:
diff changeset
   100
    QString labelText2 = message; 
hgs
parents:
diff changeset
   101
    
hgs
parents:
diff changeset
   102
    //Set the dialog to be on the screen until user reacts
hgs
parents:
diff changeset
   103
    //by pressing the Action button
hgs
parents:
diff changeset
   104
    this->setModal(true);
hgs
parents:
diff changeset
   105
    this->setTimeout(HbPopup::NoTimeout);
hgs
parents:
diff changeset
   106
    this->setDismissPolicy(HbPopup::NoDismiss);
hgs
parents:
diff changeset
   107
               
hgs
parents:
diff changeset
   108
    HbLabel* label1 = new HbLabel;
hgs
parents:
diff changeset
   109
    Q_ASSERT(label1 != NULL);
hgs
parents:
diff changeset
   110
    label1->setPlainText(labelText1);
hgs
parents:
diff changeset
   111
    label1->setFontSpec(HbFontSpec(HbFontSpec::Primary));
hgs
parents:
diff changeset
   112
    label1->setTextWrapping(Hb::TextWrapAnywhere);
hgs
parents:
diff changeset
   113
    
hgs
parents:
diff changeset
   114
    this->setHeadingWidget(label1);       
hgs
parents:
diff changeset
   115
    this->setText(labelText2);    
hgs
parents:
diff changeset
   116
    this->setIconVisible(false);
hgs
parents:
diff changeset
   117
    
hgs
parents:
diff changeset
   118
    //Remove all default actions from the dialog     
hgs
parents:
diff changeset
   119
    QList<QAction*> action_list = this->actions();
hgs
parents:
diff changeset
   120
    for ( int i = 0; i < action_list.count(); i++ ) {
hgs
parents:
diff changeset
   121
        this->removeAction(action_list.at(i));
hgs
parents:
diff changeset
   122
        }
hgs
parents:
diff changeset
   123
        
hgs
parents:
diff changeset
   124
    //Add a new Ok button action 
hgs
parents:
diff changeset
   125
    HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this); 
hgs
parents:
diff changeset
   126
    this->addAction(actionOk);
hgs
parents:
diff changeset
   127
    
hgs
parents:
diff changeset
   128
    //Disconnect action Ok from the default SLOT and connect to 
hgs
parents:
diff changeset
   129
    //a SLOT owned by this class 
hgs
parents:
diff changeset
   130
    disconnect(actionOk, SIGNAL(triggered()),this, SLOT(close()));
hgs
parents:
diff changeset
   131
    bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed()));
hgs
parents:
diff changeset
   132
    Q_ASSERT(connected == true);
hgs
parents:
diff changeset
   133
        
hgs
parents:
diff changeset
   134
    // Connect the about to close and hide signals, so that we are able to inform 
hgs
parents:
diff changeset
   135
    // the caller that the dialog was closed    
hgs
parents:
diff changeset
   136
    connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
hgs
parents:
diff changeset
   137
    Q_ASSERT(connected == true);
hgs
parents:
diff changeset
   138
    connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
hgs
parents:
diff changeset
   139
    Q_ASSERT(connected == true);
hgs
parents:
diff changeset
   140
   
hgs
parents:
diff changeset
   141
    OstTraceFunctionExit0( DUP1_EAPQUERYDIALOG_CREATEDIALOG_EXIT );
hgs
parents:
diff changeset
   142
    qDebug("EapQueryDialog::createDialog EXIT");
hgs
parents:
diff changeset
   143
}
hgs
parents:
diff changeset
   144
36
hgs
parents: 34
diff changeset
   145
/*!
hgs
parents: 34
diff changeset
   146
 * Destructor.
34
hgs
parents:
diff changeset
   147
 */
hgs
parents:
diff changeset
   148
EapQueryDialog::~EapQueryDialog()
hgs
parents:
diff changeset
   149
{
hgs
parents:
diff changeset
   150
    OstTraceFunctionEntry0( EAPQUERYDIALOG_DEAPQUERYDIALOG_ENTRY );
hgs
parents:
diff changeset
   151
    
hgs
parents:
diff changeset
   152
    // The dialog widgets are deleted as the dialog is deleted
hgs
parents:
diff changeset
   153
    
hgs
parents:
diff changeset
   154
    OstTraceFunctionExit0( EAPQUERYDIALOG_DEAPQUERYDIALOG_EXIT );
hgs
parents:
diff changeset
   155
}
hgs
parents:
diff changeset
   156
36
hgs
parents: 34
diff changeset
   157
/*!
34
hgs
parents:
diff changeset
   158
 * Function is called when the Ok Action button is pressed
hgs
parents:
diff changeset
   159
 */
hgs
parents:
diff changeset
   160
void EapQueryDialog::okPressed()
hgs
parents:
diff changeset
   161
{
hgs
parents:
diff changeset
   162
    OstTraceFunctionEntry0( EAPQUERYDIALOG_OKPRESSED_ENTRY );
hgs
parents:
diff changeset
   163
    qDebug("EapQueryDialog::okPressed ENTER");
hgs
parents:
diff changeset
   164
    
hgs
parents:
diff changeset
   165
    if ( mOkActionPressed == false ) {
hgs
parents:
diff changeset
   166
        
hgs
parents:
diff changeset
   167
            mOkActionPressed = true;
hgs
parents:
diff changeset
   168
            
hgs
parents:
diff changeset
   169
            QVariantMap data;
36
hgs
parents: 34
diff changeset
   170
            data["okbutton"] = okButtonIndex;
hgs
parents: 34
diff changeset
   171
            
34
hgs
parents:
diff changeset
   172
            // emit the data of the selected button and close the dialog
hgs
parents:
diff changeset
   173
            qDebug("EapQueryDialog::okPressed: emit deviceDialogData");
hgs
parents:
diff changeset
   174
            emit deviceDialogData(data);
hgs
parents:
diff changeset
   175
    
hgs
parents:
diff changeset
   176
            closeDeviceDialog(true);
hgs
parents:
diff changeset
   177
    }
hgs
parents:
diff changeset
   178
    OstTraceFunctionExit0( EAPQUERYDIALOG_OKPRESSED_EXIT );
hgs
parents:
diff changeset
   179
    qDebug("EapQueryDialog::okPressed EXIT");
hgs
parents:
diff changeset
   180
}
hgs
parents:
diff changeset
   181
36
hgs
parents: 34
diff changeset
   182
/*!
34
hgs
parents:
diff changeset
   183
 * Function is called when the dialog is about to close
hgs
parents:
diff changeset
   184
 */
hgs
parents:
diff changeset
   185
void EapQueryDialog::closingDialog()
hgs
parents:
diff changeset
   186
{
hgs
parents:
diff changeset
   187
    OstTraceFunctionEntry0( EAPQUERYDIALOG_CLOSINGDIALOG_ENTRY );
hgs
parents:
diff changeset
   188
    qDebug("EapQueryDialog::closingDialog ENTER");
hgs
parents:
diff changeset
   189
 
hgs
parents:
diff changeset
   190
    qDebug("EapQueryDialog::closingDialog EXIT");
hgs
parents:
diff changeset
   191
    OstTraceFunctionExit0( EAPQUERYDIALOG_CLOSINGDIALOG_EXIT );
hgs
parents:
diff changeset
   192
}
hgs
parents:
diff changeset
   193
36
hgs
parents: 34
diff changeset
   194
/*!
hgs
parents: 34
diff changeset
   195
 * Device dialog parameters to be set while dialog is displayed.
hgs
parents: 34
diff changeset
   196
 * Not supported. 
hgs
parents: 34
diff changeset
   197
 *
hgs
parents: 34
diff changeset
   198
 * @param [in] parameters NOT USED
hgs
parents: 34
diff changeset
   199
 * @return true always.
hgs
parents: 34
diff changeset
   200
 */  
34
hgs
parents:
diff changeset
   201
bool EapQueryDialog::setDeviceDialogParameters
hgs
parents:
diff changeset
   202
                (const QVariantMap &parameters)
hgs
parents:
diff changeset
   203
{
hgs
parents:
diff changeset
   204
    OstTraceFunctionEntry0( EAPQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY );
hgs
parents:
diff changeset
   205
    
hgs
parents:
diff changeset
   206
    Q_UNUSED(parameters)
hgs
parents:
diff changeset
   207
    // changing the dialog after presenting it is not supported.
hgs
parents:
diff changeset
   208
    
hgs
parents:
diff changeset
   209
    OstTraceFunctionExit0( EAPQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT );
hgs
parents:
diff changeset
   210
    return true;
hgs
parents:
diff changeset
   211
}
hgs
parents:
diff changeset
   212
36
hgs
parents: 34
diff changeset
   213
/*!
hgs
parents: 34
diff changeset
   214
 * Not supported
hgs
parents: 34
diff changeset
   215
 *
hgs
parents: 34
diff changeset
   216
 * @return 0 always returned.
34
hgs
parents:
diff changeset
   217
 */
hgs
parents:
diff changeset
   218
int EapQueryDialog::deviceDialogError() const
hgs
parents:
diff changeset
   219
{
hgs
parents:
diff changeset
   220
    OstTraceFunctionEntry0( EAPQUERYDIALOG_DEVICEDIALOGERROR_ENTRY );
hgs
parents:
diff changeset
   221
    OstTraceFunctionExit0( EAPQUERYDIALOG_DEVICEDIALOGERROR_EXIT);
hgs
parents:
diff changeset
   222
    return 0;
hgs
parents:
diff changeset
   223
}
hgs
parents:
diff changeset
   224
36
hgs
parents: 34
diff changeset
   225
/*!
34
hgs
parents:
diff changeset
   226
 * Dialog is closed and the signal about closing is emitted
36
hgs
parents: 34
diff changeset
   227
 *
hgs
parents: 34
diff changeset
   228
 * @param [in] byClient indicates when the user closes the dialog
34
hgs
parents:
diff changeset
   229
 */
hgs
parents:
diff changeset
   230
void EapQueryDialog::closeDeviceDialog(bool byClient)
hgs
parents:
diff changeset
   231
{   
hgs
parents:
diff changeset
   232
    OstTraceFunctionEntry0( EAPQUERYDIALOG_CLOSEDEVICEDIALOG_ENTRY );
hgs
parents:
diff changeset
   233
    qDebug("EapQueryDialog::closeDeviceDialog ENTER");
hgs
parents:
diff changeset
   234
        
hgs
parents:
diff changeset
   235
    //If the user closes the dialog, then the deviceDialogClosed is emitted
hgs
parents:
diff changeset
   236
    if ( byClient == true ) {
hgs
parents:
diff changeset
   237
        emit deviceDialogClosed();
hgs
parents:
diff changeset
   238
    }
hgs
parents:
diff changeset
   239
    
hgs
parents:
diff changeset
   240
    qDebug("EapQueryDialog::closeDeviceDialog EXIT");
hgs
parents:
diff changeset
   241
    OstTraceFunctionExit0( EAPQUERYDIALOG_CLOSEDEVICEDIALOG_EXIT );
hgs
parents:
diff changeset
   242
}
hgs
parents:
diff changeset
   243
36
hgs
parents: 34
diff changeset
   244
/*!
34
hgs
parents:
diff changeset
   245
 * This dialog widget is returned to the caller
36
hgs
parents: 34
diff changeset
   246
 *
hgs
parents: 34
diff changeset
   247
 * @return this dialog widget
34
hgs
parents:
diff changeset
   248
 */
hgs
parents:
diff changeset
   249
HbPopup *EapQueryDialog::deviceDialogWidget() const
hgs
parents:
diff changeset
   250
{
hgs
parents:
diff changeset
   251
    OstTraceFunctionEntry0( EAPQUERYDIALOG_DEVICEDIALOGWIDGET_ENTRY );
hgs
parents:
diff changeset
   252
    qDebug("EapQueryDialog::deviceDialogWidget ENTER");
hgs
parents:
diff changeset
   253
    
hgs
parents:
diff changeset
   254
    qDebug("EapQueryDialog::deviceDialogWidget EXIT");
hgs
parents:
diff changeset
   255
    OstTraceFunctionExit0( EAPQUERYDIALOG_DEVICEDIALOGWIDGET_EXIT );
hgs
parents:
diff changeset
   256
    
hgs
parents:
diff changeset
   257
    return const_cast<EapQueryDialog*>(this);
hgs
parents:
diff changeset
   258
}
hgs
parents:
diff changeset
   259