9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Dialog implementation |
14 * Description: User authentication Dialog implementation |
15 * |
15 * |
16 */ |
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 4 % |
|
20 */ |
17 |
21 |
18 #include <eapqtvalidator.h> |
22 #include <eapqtvalidator.h> |
19 #include <eapqtexpandedeaptype.h> |
23 #include <eapqtexpandedeaptype.h> |
20 #include <eapqtconfiginterface.h> |
24 #include <eapqtconfiginterface.h> |
21 #include <eapqtconfig.h> |
25 #include <eapqtconfig.h> |
|
26 #include <HbParameterLengthLimiter> |
|
27 #include <HbTranslator> |
|
28 #include <HbLineEdit> |
|
29 #include <HbAction> |
22 #include "eapusernamepwddialog.h" |
30 #include "eapusernamepwddialog.h" |
23 #include "OstTraceDefinitions.h" |
31 #include "OstTraceDefinitions.h" |
24 #ifdef OST_TRACE_COMPILER_IN_USE |
32 #ifdef OST_TRACE_COMPILER_IN_USE |
25 |
33 |
26 #endif |
34 #endif |
31 EapUsernamePwdDialog::EapUsernamePwdDialog(const QVariantMap ¶meters) |
39 EapUsernamePwdDialog::EapUsernamePwdDialog(const QVariantMap ¶meters) |
32 :mEdit1(NULL), |
40 :mEdit1(NULL), |
33 mEdit2(NULL), |
41 mEdit2(NULL), |
34 mUnameValidator(NULL), |
42 mUnameValidator(NULL), |
35 mPwdValidator(NULL), |
43 mPwdValidator(NULL), |
36 mTranslator(new HbTranslator("eapprompts")) |
44 mTranslator(new HbTranslator("eapprompts")), |
|
45 mClose(false), |
|
46 mOkActionPressed(false) |
37 { |
47 { |
38 OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_EAPUSERNAMEPWDDIALOG_ENTRY ); |
48 OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_EAPUSERNAMEPWDDIALOG_ENTRY ); |
39 qDebug("EapUsernamePwdDialog::EapUsernamePwdDialog ENTER"); |
49 qDebug("EapUsernamePwdDialog::EapUsernamePwdDialog ENTER"); |
40 |
50 |
41 createDialog(parameters); |
51 createDialog(parameters); |
42 |
52 |
43 mClose = false; |
|
44 mOkActionPressed = false; |
|
45 |
|
46 OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_EAPUSERNAMEPWDDIALOG_EXIT ); |
53 OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_EAPUSERNAMEPWDDIALOG_EXIT ); |
47 qDebug("EapUsernamePwdDialog::EapUsernamePwdDialog EXIT"); |
54 qDebug("EapUsernamePwdDialog::EapUsernamePwdDialog EXIT"); |
48 } |
55 } |
49 |
56 |
50 /** |
57 /** |
53 void EapUsernamePwdDialog::createDialog(const QVariantMap ¶meters ) |
60 void EapUsernamePwdDialog::createDialog(const QVariantMap ¶meters ) |
54 { |
61 { |
55 OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_CREATEDIALOG_ENTRY ); |
62 OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_CREATEDIALOG_ENTRY ); |
56 qDebug("EapUsernamePwdDialog::createDialog ENTER"); |
63 qDebug("EapUsernamePwdDialog::createDialog ENTER"); |
57 |
64 |
58 QString keyauthmethod = QString("authmethod"); |
65 QString keyauthmethod("authmethod"); |
59 QString keyuname = QString("username"); |
66 QString keyuname("username"); |
60 QString keyeaptype = QString("eaptype"); |
67 QString keyeaptype("eaptype"); |
61 |
68 |
62 QString unamestr = QString(""); |
69 QString unamestr; |
63 QString authMethodstr = QString("FOO"); |
70 QString authMethodstr; |
64 |
71 |
|
72 //Get default username (if exists) and |
|
73 //auth method strings from parameters |
65 if ( parameters.empty() == false ) { |
74 if ( parameters.empty() == false ) { |
66 if ( parameters.contains(keyuname) ) { |
75 if ( parameters.contains(keyuname) ) { |
67 QVariant variant = parameters.value(keyuname); |
76 QVariant variant = parameters.value(keyuname); |
68 unamestr = variant.toString(); |
77 unamestr = variant.toString(); |
69 } |
78 } |
87 mEdit1 = this->lineEdit(0); |
96 mEdit1 = this->lineEdit(0); |
88 mEdit1->setText(unamestr); |
97 mEdit1->setText(unamestr); |
89 |
98 |
90 this->setPromptText(labelText2, 1); |
99 this->setPromptText(labelText2, 1); |
91 mEdit2 = this->lineEdit(1); |
100 mEdit2 = this->lineEdit(1); |
92 |
101 |
|
102 //Get the EAP type for the Line Edits (Validator) |
93 QByteArray ba; |
103 QByteArray ba; |
94 |
|
95 if ( parameters.contains(keyeaptype) ) { |
104 if ( parameters.contains(keyeaptype) ) { |
96 QVariant variant = parameters.value(keyeaptype); |
105 QVariant variant = parameters.value(keyeaptype); |
97 ba = variant.toByteArray(); |
106 ba = variant.toByteArray(); |
98 } |
107 } |
99 Q_ASSERT( ba.isEmpty() == false ); |
108 Q_ASSERT( ba.isEmpty() == false ); |
100 |
|
101 EapQtExpandedEapType e_type(ba); |
109 EapQtExpandedEapType e_type(ba); |
102 EapQtConfigInterface eap_config_if; |
110 EapQtConfigInterface eap_config_if; |
103 |
111 |
104 mUnameValidator = eap_config_if.validatorEap(e_type, |
112 mUnameValidator.reset(eap_config_if.validatorEap(e_type, |
105 EapQtConfig::Username); |
113 EapQtConfig::Username)); |
|
114 Q_ASSERT( mUnameValidator.isNull() == false ); |
|
115 |
106 mUnameValidator->updateEditor(mEdit1); |
116 mUnameValidator->updateEditor(mEdit1); |
107 |
117 |
108 mPwdValidator = eap_config_if.validatorEap(e_type, |
118 mPwdValidator.reset(eap_config_if.validatorEap(e_type, |
109 EapQtConfig::Password); |
119 EapQtConfig::Password)); |
|
120 Q_ASSERT( mPwdValidator.isNull() == false ); |
|
121 |
110 mPwdValidator->updateEditor(mEdit2); |
122 mPwdValidator->updateEditor(mEdit2); |
111 |
123 |
112 QList<QAction*> action_list = this->actions(); |
124 //Remove all default actions from the dialog |
113 |
125 QList<QAction*> action_list = this->actions(); |
114 for ( int i = 0; i < action_list.count(); i++ ) { |
126 for ( int i = 0; i < action_list.count(); i++ ) { |
115 this->removeAction(action_list.at(i)); |
127 this->removeAction(action_list.at(i)); |
116 } |
128 } |
117 |
129 |
|
130 //Add a new Ok button action |
118 HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this); |
131 HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this); |
119 this->addAction(actionOk); |
132 this->addAction(actionOk); |
|
133 //Add a new Cancel button action |
120 HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this); |
134 HbAction* actionCancel = new HbAction(hbTrId("txt_common_button_cancel"),this); |
121 this->addAction( actionCancel ); |
135 this->addAction( actionCancel ); |
122 |
136 |
|
137 //Disconnect action Ok from the default SLOT and connect to |
|
138 //a SLOT owned by this class |
123 disconnect(actionOk, SIGNAL(triggered()),this, SLOT(close())); |
139 disconnect(actionOk, SIGNAL(triggered()),this, SLOT(close())); |
124 bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed())); |
140 bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed())); |
125 Q_ASSERT(connected == true); |
141 Q_ASSERT(connected == true); |
126 |
142 |
|
143 //Disconnect action Cancel from the default SLOT and connect to |
|
144 //a SLOT owned by this class |
127 disconnect(actionCancel, SIGNAL(triggered()),this, SLOT(close())); |
145 disconnect(actionCancel, SIGNAL(triggered()),this, SLOT(close())); |
128 connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); |
146 connected = connect(actionCancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); |
129 Q_ASSERT(connected == true); |
147 Q_ASSERT(connected == true); |
130 |
148 |
131 // Connect the about to close and hide signals, so that we are able to inform |
149 // Connect the about to close and hide signals, so that we are able to inform |
146 { |
164 { |
147 OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_DEAPUSERNAMEPWDDIALOG_ENTRY ); |
165 OstTraceFunctionEntry0( EAPUSERNAMEPWDDIALOG_DEAPUSERNAMEPWDDIALOG_ENTRY ); |
148 qDebug("EapUsernamePwdDialog::~EapUsernamePwdDialog"); |
166 qDebug("EapUsernamePwdDialog::~EapUsernamePwdDialog"); |
149 |
167 |
150 //The dialog widgets are deleted as the dialog is deleted |
168 //The dialog widgets are deleted as the dialog is deleted |
151 delete mPwdValidator; |
169 // mPwdValidator: scoped pointer deleted automatically |
152 delete mUnameValidator; |
170 // mUnameValidator: scoped pointer deleted automatically |
153 |
171 |
154 OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_DEAPUSERNAMEPWDDIALOG_EXIT ); |
172 OstTraceFunctionExit0( EAPUSERNAMEPWDDIALOG_DEAPUSERNAMEPWDDIALOG_EXIT ); |
155 } |
173 } |
156 |
174 |
157 /** |
175 /** |
158 * Line edit validator |
176 * Line Edit Validator |
159 */ |
177 */ |
160 bool EapUsernamePwdDialog::validate() const |
178 bool EapUsernamePwdDialog::validate() const |
161 { |
179 { |
162 qDebug("EapUsernamePwdDialog::validate ENTER"); |
180 qDebug("EapUsernamePwdDialog::validate ENTER"); |
163 |
181 |