|
1 /* |
|
2 * Copyright (c) 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 "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 * Implementation of CSysErrCmd class. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "syserrcmd.h" |
|
20 #include "trace.h" |
|
21 |
|
22 #include <AknGlobalNote.h> |
|
23 #include <aknSDData.h> |
|
24 #include <data_caging_path_literals.hrh> |
|
25 #include <featmgr.h> |
|
26 #include <SecondaryDisplay/SecondaryDisplayStartupAPI.h> |
|
27 #include <StringLoader.h> |
|
28 #include <startup.rsg> |
|
29 #include <stringresourcereader.h> |
|
30 |
|
31 |
|
32 _LIT( KResourceFileName, "Z:startup.rsc" ); |
|
33 |
|
34 // ======== LOCAL FUNCTIONS ======== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CSysErrorPlugin::GetResourceFileNameLC |
|
38 // |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 static TFileName* GetResourceFileNameLC() |
|
42 { |
|
43 FUNC_LOG; |
|
44 |
|
45 // TParse uses a lot of stack space, so allocate it from heap. |
|
46 TParse* parse = new ( ELeave ) TParse; |
|
47 CleanupDeletePushL( parse ); |
|
48 TInt errorCode = parse->Set( KResourceFileName, |
|
49 &KDC_APP_RESOURCE_DIR, |
|
50 NULL ); |
|
51 ERROR( errorCode, "parse::Set() failed with error code %d" ); |
|
52 User::LeaveIfError( errorCode ); |
|
53 |
|
54 TFileName* filename = new ( ELeave ) TFileName( parse->FullName() ); |
|
55 |
|
56 CleanupStack::PopAndDestroy( parse ); |
|
57 CleanupDeletePushL( filename ); |
|
58 |
|
59 INFO_1( "Resource file name: %S", filename ); |
|
60 |
|
61 return filename; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CSysErrorPlugin::GetFatalErrorStringLC |
|
66 // |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 static TBool IsCoverUiSupported() |
|
70 { |
|
71 FUNC_LOG; |
|
72 |
|
73 // If this fails, default to false. |
|
74 TRAPD( errorCode, FeatureManager::InitializeLibL() ); |
|
75 ERROR( errorCode, "Failed to initialize FeatureManager" ); |
|
76 |
|
77 TBool retVal = EFalse; |
|
78 if ( errorCode == KErrNone && |
|
79 FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) |
|
80 { |
|
81 retVal = ETrue; |
|
82 } |
|
83 |
|
84 FeatureManager::UnInitializeLib(); |
|
85 |
|
86 INFO_1( "CoverUiSupported = %d", retVal ); |
|
87 return retVal; |
|
88 } |
|
89 |
|
90 // ======== MEMBER FUNCTIONS ======== |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // CSysErrCmd::NewL |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CSysErrCmd* CSysErrCmd::NewL() |
|
97 { |
|
98 FUNC_LOG; |
|
99 return new ( ELeave ) CSysErrCmd(); |
|
100 } |
|
101 |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CSysErrCmd::~CSysErrCmd |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 CSysErrCmd::~CSysErrCmd() |
|
108 { |
|
109 FUNC_LOG; |
|
110 |
|
111 delete iNote; |
|
112 } |
|
113 |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CSysErrCmd::Initialize |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 TInt CSysErrCmd::Initialize( CSsmCustomCommandEnv* aCmdEnv ) |
|
120 { |
|
121 FUNC_LOG; |
|
122 ASSERT_TRACE( aCmdEnv ); |
|
123 iEnv = aCmdEnv; |
|
124 return KErrNone; |
|
125 } |
|
126 |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CSysErrCmd::Execute |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void CSysErrCmd::Execute( const TDesC8& /*aParams*/, TRequestStatus& aRequest ) |
|
133 { |
|
134 FUNC_LOG; |
|
135 |
|
136 INFO_1( "[0x%08x] Execute", this ); |
|
137 TInt err( KErrNone ); |
|
138 TRAP( err, DoExecuteL( aRequest ) ); |
|
139 ERROR( err, "DoExecuteL failed." ); |
|
140 } |
|
141 |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CSysErrCmd::ExecuteCancel |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CSysErrCmd::ExecuteCancel() |
|
148 { |
|
149 FUNC_LOG; |
|
150 |
|
151 if ( iNote ) |
|
152 { |
|
153 TInt errorCode( KErrNone ); |
|
154 TRAP( errorCode, iNote->CancelNoteL( iNoteId ) ); |
|
155 ERROR( errorCode, "Failed to cancel global note" ); |
|
156 } |
|
157 |
|
158 delete iNote; // Note must be deleted here! Otherwise it doesn't complete |
|
159 iNote = NULL; // request with KErrCancel and Cancel() gets stuck. |
|
160 } |
|
161 |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // CSysErrCmd::Close |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 void CSysErrCmd::Close() |
|
168 { |
|
169 FUNC_LOG; |
|
170 } |
|
171 |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // CSysErrCmd::Release |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CSysErrCmd::Release() |
|
178 { |
|
179 FUNC_LOG; |
|
180 |
|
181 delete this; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // CSysErrCmd::DoExecuteL |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 void CSysErrCmd::DoExecuteL( TRequestStatus& aRequest ) |
|
189 { |
|
190 delete iNote; |
|
191 iNote = NULL; |
|
192 iNote = CAknGlobalNote::NewL(); |
|
193 |
|
194 if ( IsCoverUiSupported() ) |
|
195 { |
|
196 CAknSDData* sdData = CAknSDData::NewL( |
|
197 SecondaryDisplay::KCatStartup, |
|
198 SecondaryDisplay::ECmdShowErrorNote, |
|
199 TPckgBuf<TInt>( SecondaryDisplay::EContactService ) ); |
|
200 |
|
201 // ownership to notifier client |
|
202 iNote->SetSecondaryDisplayData( sdData ); |
|
203 } |
|
204 |
|
205 TFileName* filename = GetResourceFileNameLC(); |
|
206 |
|
207 RFs& fs = const_cast<RFs&>( iEnv->Rfs() ); |
|
208 |
|
209 CStringResourceReader* resReader = CStringResourceReader::NewLC( *filename, |
|
210 fs ); |
|
211 |
|
212 TPtrC errorStr( resReader->ReadResourceString( |
|
213 R_SU_SELFTEST_FAILED_NOTE_TEXT ) ); |
|
214 |
|
215 iNoteId = iNote->ShowNoteL( aRequest, EAknGlobalPermanentNote, errorStr ); |
|
216 |
|
217 CleanupStack::PopAndDestroy( resReader ); |
|
218 CleanupStack::PopAndDestroy( filename ); |
|
219 |
|
220 } |