|
1 /* |
|
2 * Copyright (c) 2003-2007 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 Application UI class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <sysutil.h> // For FFSSpaceBelowCriticalLevelL(..) |
|
21 #include <aknnotewrappers.h> // Note dialogs |
|
22 #include <mpkcs12.h> |
|
23 #include <cryptostrength.h> |
|
24 #include <CertSaver.rsg> |
|
25 #include "CertSaverAppUi.h" |
|
26 #include "CertSaverContainer.h" |
|
27 #include "CertSaverDocument.h" |
|
28 #include "CertSaverModel.h" |
|
29 |
|
30 |
|
31 // ================= MEMBER FUNCTIONS ======================= |
|
32 // |
|
33 // ---------------------------------------------------------- |
|
34 // CCertSaverAppUi::ConstructL() |
|
35 // Epoc second phase constructor. |
|
36 // ---------------------------------------------------------- |
|
37 // |
|
38 void CCertSaverAppUi::ConstructL() |
|
39 { |
|
40 BaseConstructL( EAknEnableSkin | EAknEnableMSK ); |
|
41 |
|
42 iContainer = new( ELeave ) CCertSaverContainer(); |
|
43 iContainer->ConstructL( ClientRect() ); |
|
44 iContainer->SetMopParent( this ); |
|
45 AddToStackL( iContainer ); |
|
46 } |
|
47 |
|
48 // ---------------------------------------------------- |
|
49 // CCertSaverAppUi::~CCertSaverAppUi() |
|
50 // Destructor |
|
51 // Frees reserved resources |
|
52 // ---------------------------------------------------- |
|
53 // |
|
54 CCertSaverAppUi::~CCertSaverAppUi() |
|
55 { |
|
56 delete iModel; |
|
57 |
|
58 if( iContainer ) |
|
59 { |
|
60 RemoveFromStack( iContainer ); |
|
61 delete iContainer; |
|
62 } |
|
63 } |
|
64 |
|
65 // ------------------------------------------------------------------------------ |
|
66 // CCertSaverAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane) |
|
67 // This function is called by the EIKON framework just before it displays |
|
68 // a menu pane. Its default implementation is empty, and by overriding it, |
|
69 // the application can set the state of menu items dynamically according |
|
70 // to the state of application data. |
|
71 // ------------------------------------------------------------------------------ |
|
72 // |
|
73 void CCertSaverAppUi::DynInitMenuPaneL( |
|
74 TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/ ) |
|
75 { |
|
76 } |
|
77 |
|
78 // ---------------------------------------------------- |
|
79 // CCertSaverAppUi::HandleKeyEventL( |
|
80 // const TKeyEvent& aKeyEvent,TEventCode /*aType*/) |
|
81 // No key events are handled by the application. |
|
82 // ---------------------------------------------------- |
|
83 // |
|
84 TKeyResponse CCertSaverAppUi::HandleKeyEventL( |
|
85 const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/ ) |
|
86 { |
|
87 return EKeyWasNotConsumed; |
|
88 } |
|
89 |
|
90 // ---------------------------------------------------- |
|
91 // CCertSaverAppUi::HandleCommandL(TInt aCommand) |
|
92 // In principle, this function does nothing, because all |
|
93 // input is handled by dialogs. |
|
94 // ---------------------------------------------------- |
|
95 // |
|
96 void CCertSaverAppUi::HandleCommandL( TInt aCommand ) |
|
97 { |
|
98 switch ( aCommand ) |
|
99 { |
|
100 case EEikCmdExit: |
|
101 { |
|
102 doExit(); |
|
103 break; |
|
104 } |
|
105 default: |
|
106 break; |
|
107 } |
|
108 } |
|
109 |
|
110 // ---------------------------------------------------- |
|
111 // CCertSaverAppUi::RunFileL(const TDesC& aFileName) |
|
112 // Create CCertSaver dialog class and activates the |
|
113 // dialog. |
|
114 // ---------------------------------------------------- |
|
115 // |
|
116 void CCertSaverAppUi::RunFileL(RFile& aFile) |
|
117 { |
|
118 TCrypto::TStrength cryptoStrength = TCrypto::Strength(); |
|
119 if ( TCrypto::EWeak == cryptoStrength ) |
|
120 { |
|
121 User::Panic( KCertSaverPanic, KErrWrongCryptoLib ); |
|
122 } |
|
123 ((CCertSaverDocument*)iDocument)->Parser().SetContentL( aFile ); |
|
124 |
|
125 iModel = new (ELeave) CCertSaverModel( |
|
126 this, ((CCertSaverDocument*)iDocument)->Parser()); |
|
127 |
|
128 switch ( Document()->Parser().CertType() ) |
|
129 { |
|
130 case CCertParser::ETypeX509CA: |
|
131 { |
|
132 iModel->SaveCertificateL( (Document()->Parser().Certificate()), |
|
133 ECACertificate, EX509Certificate ); |
|
134 break; |
|
135 } |
|
136 case CCertParser::ETypeX509Peer: |
|
137 { |
|
138 iModel->SaveCertificateL( (Document()->Parser().Certificate()), |
|
139 EPeerCertificate, EX509Certificate ); |
|
140 break; |
|
141 } |
|
142 case CCertParser::ETypePKCS12: |
|
143 { |
|
144 iModel->SavePKCS12L(); |
|
145 break; |
|
146 } |
|
147 case CCertParser::ETypeCorrupt: |
|
148 { |
|
149 // Do nothing |
|
150 break; |
|
151 } |
|
152 default: |
|
153 { |
|
154 break; |
|
155 } |
|
156 } |
|
157 } |
|
158 |
|
159 // ---------------------------------------------------- |
|
160 // CCertSaverAppUi::CoeEnv() |
|
161 // Returns pointer to the control environment. |
|
162 // ---------------------------------------------------- |
|
163 // |
|
164 const CCoeEnv* CCertSaverAppUi::CoeEnv() const |
|
165 { |
|
166 return iCoeEnv; |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------- |
|
170 // CCertSaverAppUi::doExit() |
|
171 // Exits the application and notifies iDoorObserver about it. |
|
172 // ---------------------------------------------------- |
|
173 // |
|
174 void CCertSaverAppUi::doExit() |
|
175 { |
|
176 if ( iDoorObserver ) |
|
177 { |
|
178 iDoorObserver->NotifyExit( MApaEmbeddedDocObserver::EEmpty ); |
|
179 } |
|
180 Exit(); |
|
181 } |
|
182 |
|
183 // ---------------------------------------------------- |
|
184 // CCertSaverAppUi::HandleError(TInt aError, |
|
185 // const SExtendedError& aExtErr, TDes& aErrorText, |
|
186 // TDes& aContextText) |
|
187 // When a leave that is not trapped by application occurs, |
|
188 // this function is called. |
|
189 // ---------------------------------------------------- |
|
190 // |
|
191 TErrorHandlerResponse CCertSaverAppUi::HandleError( |
|
192 TInt aError, |
|
193 const SExtendedError& aExtErr, |
|
194 TDes& aErrorText, |
|
195 TDes& aContextText ) |
|
196 { |
|
197 iErrorOccured = ETrue; |
|
198 return CAknAppUi::HandleError( aError, aExtErr, aErrorText, aContextText ); |
|
199 } |
|
200 |
|
201 // ---------------------------------------------------- |
|
202 // CCertSaverAppUi::HandleForegroundEventL(TBool aForeground) |
|
203 // Exits the application if leave occurs. Leave is noticed by |
|
204 // member varible iErrorOccured. It is set to ETrue in |
|
205 // CCertSaverAppUi::HandleError. After error note has been |
|
206 // shown (by HandleError), this function is called by |
|
207 // framework. |
|
208 // ---------------------------------------------------- |
|
209 // |
|
210 void CCertSaverAppUi::HandleForegroundEventL( TBool aForeground ) |
|
211 { |
|
212 if ( iErrorOccured ) |
|
213 { |
|
214 doExit(); |
|
215 } |
|
216 CAknAppUi::HandleForegroundEventL( aForeground ); |
|
217 } |
|
218 // ---------------------------------------------------- |
|
219 // CCertSaverAppUi::ProcessCommandParametersL() |
|
220 // ---------------------------------------------------- |
|
221 // |
|
222 TBool CCertSaverAppUi::ProcessCommandParametersL( |
|
223 TApaCommand /*aCommand*/, |
|
224 TFileName& /*aDocumentName*/, |
|
225 const TDesC8& /*aTail*/ ) |
|
226 { |
|
227 return ETrue; |
|
228 } |
|
229 |
|
230 // End of File |