|
1 /* |
|
2 * Copyright (c) 2006-2009 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 the License "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: |
|
15 * CPinPluginDialog implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 */ |
|
23 |
|
24 #include "pinplugindialog.h" |
|
25 #include <authserver/auth_srv_errs.h> |
|
26 |
|
27 CPinPluginDialog::~CPinPluginDialog() |
|
28 { |
|
29 Deque(); |
|
30 iNotifier.Close(); |
|
31 } |
|
32 |
|
33 CPinPluginDialog* CPinPluginDialog::NewL() |
|
34 { |
|
35 CPinPluginDialog* self = CPinPluginDialog::NewLC(); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 CPinPluginDialog* CPinPluginDialog::NewLC() |
|
41 { |
|
42 CPinPluginDialog* self = new (ELeave) CPinPluginDialog(); |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(); |
|
45 return self; |
|
46 } |
|
47 |
|
48 CPinPluginDialog::CPinPluginDialog(): CActive(EPriorityStandard) |
|
49 { |
|
50 CActiveScheduler::Add(this); |
|
51 } |
|
52 |
|
53 void CPinPluginDialog::ConstructL() |
|
54 { |
|
55 User::LeaveIfError(iNotifier.Connect()); |
|
56 } |
|
57 |
|
58 void CPinPluginDialog::PinIdentify(const TInt aMinLength, const TInt aMaxLength, const TBool aRetry, |
|
59 TPinValue& aPinValue, TPinPluginDialogResult& aResult, TRequestStatus& aStatus) |
|
60 { |
|
61 iClientPinValue = &aPinValue; |
|
62 iClientPinDialogResult = &aResult; |
|
63 iState = KPinPluginIdentify; |
|
64 DoInitialize(EPinPluginIdentify, aStatus); |
|
65 TPinIdentifyInput pinInput; |
|
66 pinInput.iOperation = EPinPluginIdentify; |
|
67 pinInput.iRetry = aRetry; |
|
68 pinInput.iMinLength = aMinLength; |
|
69 pinInput.iMaxLength = aMaxLength; |
|
70 TPinIdentifyInputBuf pinInputBuf(pinInput); |
|
71 iPinIdentifyInputBuf.Copy(pinInputBuf); |
|
72 RequestDialog(iPinIdentifyInputBuf, iPinDialogOutputBuf); |
|
73 } |
|
74 |
|
75 |
|
76 |
|
77 void CPinPluginDialog::PinTraining(const TPinPluginTrainingMessage aType, const RPointerArray<TPinValue>& aPinNumbers, |
|
78 const TInt aMinLength, const TInt aMaxLength, TInt& aIndex, TInt& aCurrentLength, |
|
79 TPinPluginDialogResult& aResult, TRequestStatus& aStatus) |
|
80 { |
|
81 iClientPinIndex = &aIndex; |
|
82 iClientPinDialogResult = &aResult; |
|
83 iClientNewPinLength = &aCurrentLength; |
|
84 iState = KPinPluginTraining; |
|
85 DoInitialize(EPinPluginTraining, aStatus); |
|
86 TPinTrainingInput pinInput; |
|
87 pinInput.iOperation = EPinPluginTraining; |
|
88 pinInput.iMessage = aType; |
|
89 pinInput.iMinLength = aMinLength; |
|
90 pinInput.iMaxLength = aMaxLength; |
|
91 pinInput.iCurrentPinLength = aCurrentLength; |
|
92 pinInput.iPinValue1 = *(aPinNumbers[0]); |
|
93 pinInput.iPinValue2 = *(aPinNumbers[1]); |
|
94 pinInput.iPinValue3 = *(aPinNumbers[2]); |
|
95 pinInput.iPinValue4 = *(aPinNumbers[3]); |
|
96 TPinTrainingInputBuf pinInputBuf(pinInput); |
|
97 iPinTrainingInputBuf.Copy(pinInputBuf); |
|
98 RequestDialog(iPinTrainingInputBuf, iPinDialogOutputBuf); |
|
99 } |
|
100 |
|
101 |
|
102 void CPinPluginDialog::PinInfo(const TPinPluginInfoMessage aMessage, TRequestStatus& aStatus) |
|
103 { |
|
104 iState = KPinPluginInfo; |
|
105 DoInitialize(EPinPluginInfo, aStatus); |
|
106 TPinInfoInput pinInput; |
|
107 pinInput.iOperation = EPinPluginInfo; |
|
108 pinInput.iMessage = aMessage; |
|
109 TPinInfoInputBuf pinInputBuf(pinInput); |
|
110 iPinInfoInputBuf.Copy(pinInputBuf); |
|
111 RequestDialog(iPinInfoInputBuf, iPinDialogOutputBuf); |
|
112 } |
|
113 |
|
114 void CPinPluginDialog::DoInitialize(const TPinPluginDialogOperation aOperation, TRequestStatus& aStatus) |
|
115 { |
|
116 iCurrentOperation = aOperation; |
|
117 |
|
118 aStatus = KRequestPending; |
|
119 iClientStatus = &aStatus; |
|
120 } |
|
121 |
|
122 |
|
123 void CPinPluginDialog::RequestDialog(const TDesC8& aData, TDes8& aResponse) |
|
124 { |
|
125 iNotifier.StartNotifierAndGetResponse(iStatus, KUidPinPluginDialogNotifier, |
|
126 aData, aResponse); |
|
127 SetActive(); |
|
128 } |
|
129 |
|
130 void CPinPluginDialog::DoCancel() |
|
131 { |
|
132 iNotifier.CancelNotifier(KUidPinPluginDialogNotifier); |
|
133 if (iClientStatus) |
|
134 { |
|
135 User::RequestComplete(iClientStatus, KErrCancel); |
|
136 } |
|
137 } |
|
138 |
|
139 void CPinPluginDialog::RunL() |
|
140 { |
|
141 switch (iState) |
|
142 { |
|
143 case KPinPluginInfo: |
|
144 { |
|
145 //ignore the output as Info Dialog won't wait for user inputs |
|
146 } |
|
147 break; |
|
148 case KPinPluginTraining: |
|
149 { |
|
150 TPinDialogOutput& pinDialogOutput = iPinDialogOutputBuf(); |
|
151 *iClientPinIndex = pinDialogOutput.iIndex; |
|
152 *iClientNewPinLength = pinDialogOutput.iNewPinLength; |
|
153 *iClientPinDialogResult = pinDialogOutput.iResult; |
|
154 if(iStatus.Int() != KErrNone) |
|
155 { |
|
156 User::RequestComplete(iClientStatus, KErrAuthServRegistrationFailed); |
|
157 return; |
|
158 } |
|
159 } |
|
160 break; |
|
161 case KPinPluginIdentify: |
|
162 { |
|
163 TPinDialogOutput& pinDialogOutput = iPinDialogOutputBuf(); |
|
164 *iClientPinValue = pinDialogOutput.iPinValue; |
|
165 *iClientPinDialogResult = pinDialogOutput.iResult; |
|
166 } |
|
167 break; |
|
168 default: |
|
169 { |
|
170 User::Leave(KErrNotSupported); |
|
171 } |
|
172 break; |
|
173 } |
|
174 User::RequestComplete(iClientStatus, iStatus.Int()); |
|
175 } |
|
176 |
|
177 TInt CPinPluginDialog::RunError(TInt aError) |
|
178 { |
|
179 if (iClientStatus) |
|
180 { |
|
181 User::RequestComplete(iClientStatus, aError); |
|
182 } |
|
183 return KErrNone; |
|
184 } |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |