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: Dialog observer implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: 15 % |
|
20 */ |
|
21 |
|
22 // System include files |
|
23 #include <hb/hbcore/hbsymbianvariant.h> |
|
24 #include <e32debug.h> |
|
25 |
|
26 // User include files |
|
27 #include "eap_auth_notifier.h" |
|
28 #include "eap_auth_observer.h" |
|
29 |
|
30 // External function prototypes |
|
31 |
|
32 // Local constants |
|
33 |
|
34 // ======== LOCAL FUNCTIONS ======== |
|
35 |
|
36 // ======== MEMBER FUNCTIONS ======== |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Two-phased constructor. |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CEapAuthObserver* CEapAuthObserver::NewL( |
|
43 CEapAuthNotifier* aNotifier ) |
|
44 { |
|
45 RDebug::Print(_L("CEapAuthObserver::NewL") ); |
|
46 |
|
47 CEapAuthObserver* self = new ( ELeave ) CEapAuthObserver( aNotifier ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // Constructor |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CEapAuthObserver::CEapAuthObserver( |
|
56 CEapAuthNotifier* aNotifier ): |
|
57 iNotifier( aNotifier ) |
|
58 { |
|
59 RDebug::Print(_L("CEapAuthObserver::CEapAuthObserver") ); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Destructor |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CEapAuthObserver::~CEapAuthObserver() |
|
67 { |
|
68 RDebug::Print(_L("CEapAuthObserver::~CEapAuthObserver") ); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // Handles the setting of the notifier (dialog) type |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void CEapAuthObserver::SetNotifierType( CEapAuthNotifier::EEapNotifierType aType ) |
|
76 { |
|
77 RDebug::Print(_L("CEapAuthObserver::setNotifierType") ); |
|
78 |
|
79 iType = aType; |
|
80 } |
|
81 |
|
82 // Derived function: |
|
83 // --------------------------------------------------------------------------- |
|
84 // From class MHbDeviceDialogObserver. |
|
85 // Handles the user input received from the dialog |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CEapAuthObserver::DataReceived( CHbSymbianVariantMap& aData ) |
|
89 { |
|
90 RDebug::Print(_L("CEapAuthObserver::DataReceived") ); |
|
91 |
|
92 if ( iType == CEapAuthNotifier::EEapNotifierTypeLEapUsernamePasswordDialog ) |
|
93 { |
|
94 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeLEapUsernamePasswordDialog") ); |
|
95 UsernamePasswordDlgDataReceived(aData); |
|
96 } |
|
97 else if ( iType == CEapAuthNotifier::EEapNotifierTypeGTCUsernamePasswordDialog ) |
|
98 { |
|
99 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeGTCUsernamePasswordDialog") ); |
|
100 UsernamePasswordDlgDataReceived(aData); |
|
101 } |
|
102 else if ( iType == CEapAuthNotifier::EEapNotifierTypePapUsernamePasswordDialog ) |
|
103 { |
|
104 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypePapUsernamePasswordDialog") ); |
|
105 UsernamePasswordDlgDataReceived(aData); |
|
106 } |
|
107 else if ( iType == CEapAuthNotifier::EEapNotifierTypeEapMsChapV2UsernamePasswordDialog ) |
|
108 { |
|
109 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeEapMsChapV2UsernamePasswordDialog") ); |
|
110 UsernamePasswordDlgDataReceived(aData); |
|
111 } |
|
112 else if ( iType == CEapAuthNotifier::EEapNotifierTypeMsChapV2UsernamePasswordDialog ) |
|
113 { |
|
114 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeMsChapV2UsernamePasswordDialog") ); |
|
115 UsernamePasswordDlgDataReceived(aData); |
|
116 } |
|
117 else if ( iType == CEapAuthNotifier::EEapNotifierTypeGTCQueryDialog ) |
|
118 { |
|
119 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeGTCQueryDialog") ); |
|
120 PwdQueryDataReceived(aData); |
|
121 } |
|
122 else if ( iType == CEapAuthNotifier::EEapNotifierTypePapAuthQueryDialog ) |
|
123 { |
|
124 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypePapAuthQueryDialog") ); |
|
125 PwdQueryDataReceived(aData); |
|
126 } |
|
127 else if ( iType == CEapAuthNotifier::EEapNotifierTypeFastPacStorePwQueryDialog ) |
|
128 { |
|
129 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeFastPacStorePwQueryDialog") ); |
|
130 PwdQueryDataReceived(aData); |
|
131 } |
|
132 else if ( iType == CEapAuthNotifier::EEapNotifierTypeFastCreateMasterkeyQueryDialog ) |
|
133 { |
|
134 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeFastCreateMasterkeyQueryDialog") ); |
|
135 PwdQueryDataReceived(aData); |
|
136 } |
|
137 else if ( iType == CEapAuthNotifier::EEapNotifierTypeFastPacFilePwQueryDialog ) |
|
138 { |
|
139 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeFastPacFilePwQueryDialog") ); |
|
140 PwdQueryDataReceived(aData); |
|
141 } |
|
142 else if ( iType == CEapAuthNotifier::EEapNotifierTypeMsChapV2OldPasswordDialog ) |
|
143 { |
|
144 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeMsChapV2OldPasswordDialog") ); |
|
145 OldPwdQueryDataReceived(aData); |
|
146 } |
|
147 else if ( iType == CEapAuthNotifier::EEapNotifierTypeMsChapV2NewPasswordDialog ) |
|
148 { |
|
149 RDebug::Print(_L("CEapAuthObserver::DataReceived: EEapNotifierTypeMsChapV2NewPasswordDialog") ); |
|
150 PwdQueryDataReceived(aData); |
|
151 } |
|
152 |
|
153 TInt status = KErrNone; |
|
154 |
|
155 TRAP_IGNORE( iNotifier->CompleteL( status )); |
|
156 } |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // Handles the user name password input received from the dialog |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 void CEapAuthObserver::UsernamePasswordDlgDataReceived( |
|
163 CHbSymbianVariantMap& aData ) |
|
164 { |
|
165 RDebug::Print(_L("CEapAuthObserver::UsernamePasswordDlgDataReceived") ); |
|
166 |
|
167 _LIT(KUsername, "username"); |
|
168 _LIT(KPassword, "password"); |
|
169 |
|
170 CEapAuthNotifier::TEapDialogInfo PasswordInfo; |
|
171 TDesC* Data = NULL; |
|
172 |
|
173 PasswordInfo.iIsIdentityQuery = EFalse; |
|
174 PasswordInfo.iPasswordPromptEnabled = EFalse; |
|
175 |
|
176 const CHbSymbianVariant *my_variant = aData.Get(KUsername); |
|
177 if ( my_variant != NULL ) |
|
178 { |
|
179 ASSERT( my_variant->Type() == CHbSymbianVariant::EDes ); |
|
180 |
|
181 Data = reinterpret_cast<TDesC*>(my_variant->Data()); |
|
182 PasswordInfo.iUsername.Copy( Data->Ptr(), Data->Length() ); |
|
183 PasswordInfo.iIsIdentityQuery = ETrue; |
|
184 RDebug::Print(_L("CEapAuthObserver::DataReceived: PasswordInfo.iUsername = %S\n"), &PasswordInfo.iUsername ); |
|
185 } |
|
186 my_variant = aData.Get(KPassword); |
|
187 if ( my_variant != NULL ) |
|
188 { |
|
189 ASSERT( my_variant->Type() == CHbSymbianVariant::EDes ); |
|
190 |
|
191 Data = reinterpret_cast<TDesC*>(my_variant->Data()); |
|
192 PasswordInfo.iPassword.Copy( Data->Ptr(), Data->Length() ); |
|
193 PasswordInfo.iPasswordPromptEnabled = ETrue; |
|
194 RDebug::Print(_L("CEapAuthObserver::DataReceived: PasswordInfo.iPassword = %S\n"), &PasswordInfo.iPassword ); |
|
195 } |
|
196 |
|
197 iNotifier->SetSelectedUnameAndPwd( PasswordInfo ); |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // Handles the old password query user input received from the dialog |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 void CEapAuthObserver::OldPwdQueryDataReceived( CHbSymbianVariantMap& aData ) |
|
205 { |
|
206 RDebug::Print(_L("CEapAuthObserver::OldPwdQueryDataReceived") ); |
|
207 |
|
208 _LIT(KPassword, "password"); |
|
209 |
|
210 CEapAuthNotifier::TEapDialogInfo PasswordInfo; |
|
211 TDesC* Data = NULL; |
|
212 |
|
213 const CHbSymbianVariant *my_variant = aData.Get(KPassword); |
|
214 if ( my_variant != NULL ) |
|
215 { |
|
216 ASSERT( my_variant->Type() == CHbSymbianVariant::EDes ); |
|
217 |
|
218 Data = reinterpret_cast<TDesC*>(my_variant->Data()); |
|
219 PasswordInfo.iOldPassword.Copy( Data->Ptr(), Data->Length() ); |
|
220 |
|
221 RDebug::Print(_L("CEapAuthObserver::OldPwdQueryDataReceived: PasswordInfo.iOldPassword = %S\n"), &PasswordInfo.iOldPassword ); |
|
222 } |
|
223 |
|
224 iNotifier->SetSelectedOldPassword( PasswordInfo ); |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // Handles the password query user input received from the dialog |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 void CEapAuthObserver::PwdQueryDataReceived( CHbSymbianVariantMap& aData ) |
|
232 { |
|
233 RDebug::Print(_L("CEapAuthObserver::PwdQueryDataReceived") ); |
|
234 |
|
235 _LIT(KPassword, "password"); |
|
236 |
|
237 CEapAuthNotifier::TEapDialogInfo PasswordInfo; |
|
238 TDesC* Data = NULL; |
|
239 |
|
240 const CHbSymbianVariant *my_variant = aData.Get(KPassword); |
|
241 if ( my_variant != NULL ) |
|
242 { |
|
243 ASSERT( my_variant->Type() == CHbSymbianVariant::EDes ); |
|
244 |
|
245 Data = reinterpret_cast<TDesC*>(my_variant->Data()); |
|
246 PasswordInfo.iPassword.Copy( Data->Ptr(), Data->Length() ); |
|
247 |
|
248 RDebug::Print(_L("CEapAuthObserver::PwdQueryDataReceived: PasswordInfo.iPassword = %S\n"), &PasswordInfo.iPassword ); |
|
249 } |
|
250 |
|
251 iNotifier->SetSelectedPassword( PasswordInfo ); |
|
252 } |
|
253 |
|
254 // Derived function: |
|
255 // --------------------------------------------------------------------------- |
|
256 // From class MHbDeviceDialogObserver. |
|
257 // Handles the closing of the dialog |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CEapAuthObserver::DeviceDialogClosed( TInt /*aCompletionCode*/ ) |
|
261 { |
|
262 // Dialog was closed, let's complete with that error code |
|
263 RDebug::Print(_L("CEapAuthObserver::DeviceDialogClosed")); |
|
264 |
|
265 TInt status = KErrCancel; |
|
266 |
|
267 if ( iType != CEapAuthNotifier::EEapNotifierTypeFastStartAuthProvWaitNote && |
|
268 iType != CEapAuthNotifier::EEapNotifierTypeFastStartUnauthProvWaitNote ) |
|
269 { |
|
270 TRAP_IGNORE( iNotifier->CompleteL( status )); |
|
271 } |
|
272 } |
|
273 |
|
274 |
|