|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "testpinnotifierplugin.h" |
|
23 #include <ssm/ssmuiproviderdll.h> |
|
24 #include <techview/eikdialg.h> |
|
25 #include <testpinnotifier.rsg> |
|
26 #include <bautils.h> |
|
27 #include <eikenv.h> |
|
28 #include <uikon.hrh> |
|
29 #include <ecom/implementationproxy.h> |
|
30 #include <techview/eikseced.h> |
|
31 #include <e32property.h> |
|
32 |
|
33 const TUint KCustomcmdServerPropertyKey = 0x0012AC; |
|
34 const TUid KCustomcmdServerSID={0x2000D75B}; // tcustomcmd_server SID = KSsmServerName SID (changed in tcustomcmd_server.mmp file) |
|
35 |
|
36 _LIT(KPinNotifierResFileNameAndPath,"\\resource\\apps\\testpinnotifier.rsc"); |
|
37 _LIT(KPinNotifierTitle,"Security Check"); |
|
38 |
|
39 //Hardcoding security pin code. |
|
40 _LIT(KPinCode,","); |
|
41 |
|
42 CArrayPtr<MEikSrvNotifierBase2>* NotifierArrayL() |
|
43 { |
|
44 CArrayPtrFlat<MEikSrvNotifierBase2>* subjects=new (ELeave)CArrayPtrFlat<MEikSrvNotifierBase2>(10); |
|
45 CleanupStack::PushL(subjects); |
|
46 subjects->AppendL(CSecurityPinNotifier::NewLC()); |
|
47 CleanupStack::Pop(2, subjects); |
|
48 return subjects; |
|
49 } |
|
50 |
|
51 //ECOM SUPPORT |
|
52 const TImplementationProxy ImplementationTable[] = |
|
53 { |
|
54 IMPLEMENTATION_PROXY_ENTRY(0x2000E667, NotifierArrayL) |
|
55 }; |
|
56 |
|
57 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
58 { |
|
59 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy) ; |
|
60 return ImplementationTable; |
|
61 } |
|
62 |
|
63 |
|
64 // Notifier methods |
|
65 void CSecurityPinNotifier::Release() |
|
66 { |
|
67 delete this; |
|
68 } |
|
69 |
|
70 CSecurityPinNotifier::TNotifierInfo CSecurityPinNotifier::RegisterL() |
|
71 { |
|
72 iInfo.iUid = CSsmUiSpecific::SecurityPinNotifierUid(); |
|
73 iInfo.iChannel = CSsmUiSpecific::ScreenOutputChannelUid(); |
|
74 iInfo.iPriority = ENotifierPriorityVHigh; |
|
75 return iInfo; |
|
76 } |
|
77 |
|
78 CSecurityPinNotifier::TNotifierInfo CSecurityPinNotifier::Info() const |
|
79 { |
|
80 return iInfo; |
|
81 } |
|
82 |
|
83 TPtrC8 CSecurityPinNotifier::StartL(const TDesC8& /*aBuffer*/) |
|
84 { |
|
85 RouseSleepingDialog(); |
|
86 return KNullDesC8(); |
|
87 } |
|
88 |
|
89 void CSecurityPinNotifier::StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage) |
|
90 { |
|
91 // Set this swp to indicate to stop the active schaduler |
|
92 const TInt KSwpCancelRequest = 99; |
|
93 TInt err = RProperty::Set(KCustomcmdServerSID, KCustomcmdServerPropertyKey,KSwpCancelRequest); |
|
94 |
|
95 iMessage = aMessage; |
|
96 iReplySlot = aReplySlot; |
|
97 SetTitleL(KPinNotifierTitle()); |
|
98 StartL(aBuffer); |
|
99 } |
|
100 |
|
101 void CSecurityPinNotifier::Cancel() |
|
102 { |
|
103 ExitSleepingDialog(); |
|
104 } |
|
105 |
|
106 TPtrC8 CSecurityPinNotifier::UpdateL(const TDesC8& /*aBuffer*/) |
|
107 { |
|
108 return KNullDesC8(); |
|
109 } |
|
110 |
|
111 void CSecurityPinNotifier::UpdateL(const TDesC8& aBuffer, TInt /*aReplySlot*/, const RMessagePtr2& /*aMessage*/) |
|
112 { |
|
113 UpdateL(aBuffer); |
|
114 } |
|
115 |
|
116 CSecurityPinNotifier* CSecurityPinNotifier::NewLC() |
|
117 { |
|
118 CSecurityPinNotifier* self=new (ELeave) CSecurityPinNotifier(); |
|
119 CleanupStack::PushL(self); |
|
120 self->ConstructL(); |
|
121 return self; |
|
122 } |
|
123 |
|
124 CSecurityPinNotifier::CSecurityPinNotifier() |
|
125 { |
|
126 } |
|
127 |
|
128 CSecurityPinNotifier::~CSecurityPinNotifier() |
|
129 { |
|
130 iEikonEnv->RemoveFromStack(this); |
|
131 } |
|
132 |
|
133 void CSecurityPinNotifier::ConstructL() |
|
134 { |
|
135 // load the resource file |
|
136 const TDriveNumber KStoreDrive = EDriveZ; |
|
137 TDriveUnit driveUnit(KStoreDrive); |
|
138 TDriveName drive=driveUnit.Name(); |
|
139 TFileName resourceFileName; |
|
140 resourceFileName.Insert(0, drive); |
|
141 |
|
142 resourceFileName.Append(KPinNotifierResFileNameAndPath); |
|
143 CEikonEnv& eikonEnv = *CEikonEnv::Static(); |
|
144 BaflUtils::NearestLanguageFile(eikonEnv.FsSession(), resourceFileName); |
|
145 TInt resourceFileId = eikonEnv.AddResourceFileL(resourceFileName); |
|
146 |
|
147 TRAPD(err,ConstructSleepingAlertDialogL(R_SECURITY_PIN)); |
|
148 iEikonEnv->DeleteResourceFile(resourceFileId); |
|
149 User::LeaveIfError(err); |
|
150 |
|
151 } |
|
152 |
|
153 void CSecurityPinNotifier::PreLayoutDynInitL() |
|
154 { |
|
155 } |
|
156 |
|
157 TBool CSecurityPinNotifier::OkToExitL(TInt /*aButtonId*/) |
|
158 { |
|
159 TPckgBuf<TInt> securityResultBuffer; |
|
160 securityResultBuffer = KErrGeneral; |
|
161 if (iMessage != RMessagePtr2()) |
|
162 { |
|
163 TBuf<5> newPINValueVerify; |
|
164 |
|
165 //Get pinter for the secret editor control |
|
166 CEikSecretEditor* pinEditor = static_cast<CEikSecretEditor*>(Control(0)); |
|
167 pinEditor->GetText(newPINValueVerify); |
|
168 |
|
169 //Verify the entered pin number |
|
170 if(0 == newPINValueVerify.Compare(KPinCode)) |
|
171 { |
|
172 securityResultBuffer = KErrNone; |
|
173 } |
|
174 |
|
175 pinEditor->Reset(); |
|
176 iMessage.Write(iReplySlot,securityResultBuffer); |
|
177 iMessage.Complete(KErrNone); |
|
178 // Set this swp to indicate to stop the active schaduler |
|
179 const TInt KSwpValForOnOkStopScheduler = 88; |
|
180 TInt err = RProperty::Set(KCustomcmdServerSID, KCustomcmdServerPropertyKey, KSwpValForOnOkStopScheduler); |
|
181 |
|
182 if(err) |
|
183 { |
|
184 return EFalse; |
|
185 } |
|
186 } |
|
187 return ETrue; |
|
188 } |