|
1 /* |
|
2 * Copyright (c) 2004 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: Implementation of multiline PIN query dialog |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CTPinPinQueryDialog.h" |
|
21 #include <CTSecDlgs.rsg> |
|
22 #include <eikenv.h> |
|
23 #include <barsread.h> |
|
24 #include <uikon/eiksrvui.h> |
|
25 #include <secdlg.h> |
|
26 #include <layoutmetadata.cdl.h> |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CCTPinPinQueryDialog::CCTPinPinQueryDialog |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CCTPinPinQueryDialog::CCTPinPinQueryDialog( |
|
37 const TDesC& aDlgText1, |
|
38 const TDesC& aDlgText2, |
|
39 TDes& aPin1, |
|
40 TDes& aPin2, |
|
41 const TInt aMinTextLength, |
|
42 const TInt aMaxTextLength, |
|
43 TBool& aRetVal): |
|
44 CAknMultiLineDataQueryDialog( ENoTone ), |
|
45 iDlgText1(aDlgText1), |
|
46 iDlgText2(aDlgText2), |
|
47 iPinValue1(aPin1), |
|
48 iPinValue2(aPin2), |
|
49 iRetVal(aRetVal) |
|
50 { |
|
51 iMaxTextLength = Min(aPin1.MaxLength(), aMaxTextLength); |
|
52 iMinTextLength = Max(0, aMinTextLength); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CCTPinPinQueryDialog::ConstructL |
|
57 // Symbian 2nd phase constructor can leave. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CCTPinPinQueryDialog::ConstructL() |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CCTPinPinQueryDialog::NewL |
|
66 // Two-phased constructor. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CCTPinPinQueryDialog* CCTPinPinQueryDialog::NewL( |
|
70 const TDesC& aDlgText1, |
|
71 const TDesC& aDlgText2, |
|
72 TDes& aPin1, |
|
73 TDes& aPin2, |
|
74 const TInt aMinTextLength, |
|
75 const TInt aMaxTextLength, |
|
76 TBool& aRetVal) |
|
77 { |
|
78 CCTPinPinQueryDialog* self = new( ELeave ) CCTPinPinQueryDialog( |
|
79 aDlgText1, aDlgText2, aPin1, aPin2, aMinTextLength, aMaxTextLength, aRetVal); |
|
80 |
|
81 CleanupStack::PushL( self ); |
|
82 self->SetDataL(aPin1, aPin2); |
|
83 CleanupStack::Pop(); |
|
84 |
|
85 return self; |
|
86 } |
|
87 |
|
88 // Destructor |
|
89 CCTPinPinQueryDialog::~CCTPinPinQueryDialog() |
|
90 { |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CCTPinPinQueryDialog::RunDlgLD() |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CCTPinPinQueryDialog::RunDlgLD(TRequestStatus& aClientStatus, TInt aResourceId) |
|
98 { |
|
99 iClientStatus = &aClientStatus; |
|
100 // OkToExitL function handles dialog response |
|
101 ExecuteLD(aResourceId); |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CCTPinPinQueryDialog::PreLayoutDynInitL() |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CCTPinPinQueryDialog::PreLayoutDynInitL() |
|
109 { |
|
110 SetMaxLengthOfFirstEditor(iMaxTextLength); |
|
111 SetMaxLengthOfSecondEditor(iMaxTextLength); |
|
112 SetPromptL(iDlgText1, iDlgText2); |
|
113 CAknMultiLineDataQueryDialog::PreLayoutDynInitL(); |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CCTPinPinQueryDialog::CheckIfEntryTextOk() |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 |
|
121 TBool CCTPinPinQueryDialog::CheckIfEntryTextOk() const |
|
122 { |
|
123 TPINValue pin1; |
|
124 TPINValue pin2; |
|
125 if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
126 { |
|
127 if ( FirstControl()->IsFocused() ) |
|
128 { |
|
129 TPINValue pin1; |
|
130 FirstControl()->GetText(pin1); |
|
131 return ((pin1.Length() <= iMaxTextLength && pin1.Length() >= iMinTextLength)); |
|
132 } |
|
133 else if ( SecondControl()->IsFocused() ) |
|
134 { |
|
135 TPINValue pin2; |
|
136 SecondControl()->GetText(pin2); |
|
137 return ((pin2.Length() <= iMaxTextLength && pin2.Length() >= iMinTextLength)); |
|
138 } |
|
139 } |
|
140 |
|
141 FirstControl()->GetText(pin1); |
|
142 SecondControl()->GetText(pin2); |
|
143 return ((pin1.Length() <= iMaxTextLength && pin1.Length() >= iMinTextLength)&&(pin2.Length() <= iMaxTextLength && pin2.Length() >= iMinTextLength)); |
|
144 } |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CCTPinPinQueryDialog::UpdateLeftSoftKeyL() |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CCTPinPinQueryDialog::UpdateLeftSoftKeyL() |
|
150 { |
|
151 CAknMultiLineDataQueryDialog::UpdateLeftSoftKeyL(); |
|
152 |
|
153 MakeLeftSoftkeyVisible(CheckIfEntryTextOk()); |
|
154 } |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CCTPinPinQueryDialog::PostLayoutDynInitL() |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CCTPinPinQueryDialog::PostLayoutDynInitL() |
|
160 { |
|
161 ((CEikServAppUi*)(CEikonEnv::Static())->EikAppUi())->SuppressAppSwitching(ETrue); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CCTPinPinQueryDialog::OkToExitL() |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 TBool CCTPinPinQueryDialog::OkToExitL( TInt aButtonId ) |
|
169 { |
|
170 if (!CAknMultiLineDataQueryDialog::OkToExitL(aButtonId)) |
|
171 { |
|
172 return EFalse; |
|
173 } |
|
174 if ( aButtonId == EEikBidCancel || aButtonId == EAknSoftkeyNo ) |
|
175 { |
|
176 iRetVal = EFalse; |
|
177 User::RequestComplete(iClientStatus, KErrNone); |
|
178 } |
|
179 else if ( aButtonId ==EAknSoftkeyYes || aButtonId == EAknSoftkeyOk) |
|
180 { |
|
181 FirstControl()->GetText(iPinValue1); |
|
182 SecondControl()->GetText(iPinValue2); |
|
183 iRetVal = ETrue; |
|
184 User::RequestComplete(iClientStatus, KErrNone); |
|
185 |
|
186 } |
|
187 ((CEikServAppUi*)(CEikonEnv::Static())->EikAppUi())->SuppressAppSwitching(EFalse); |
|
188 return ETrue; |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CCTPinPinQueryDialog::OfferKeyEventL() |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 TKeyResponse CCTPinPinQueryDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
196 { |
|
197 // '#' key is inactive in Pin query dialog |
|
198 if( (aKeyEvent.iScanCode == EStdKeyHash) && (aType == EEventKeyDown || aType == EEventKeyUp) ) |
|
199 { |
|
200 return EKeyWasConsumed; |
|
201 } |
|
202 // '*' key is inactive in Pin query dialog |
|
203 if (aKeyEvent.iCode == '*') |
|
204 { |
|
205 return EKeyWasConsumed; |
|
206 } |
|
207 return CAknMultiLineDataQueryDialog::OfferKeyEventL(aKeyEvent, aType); |
|
208 } |
|
209 |
|
210 // End of File |