|
1 /* |
|
2 * Copyright (c) 2008-2008 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: CCh note handler. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "cchnotehandler.h" |
|
20 #include "cchprivatecrkeys.h" |
|
21 #include "cchserverbase.h" |
|
22 #include "cchfeaturemanager.h" |
|
23 #include <StringLoader.h> |
|
24 #include <cch.rsg> |
|
25 #include <AknGlobalNote.h> |
|
26 #include <AknGlobalMsgQuery.h> |
|
27 #include "cchsecondarydisplayapi.h" |
|
28 #include <aknSDData.h> |
|
29 #include <barsread.h> |
|
30 #include <bautils.h> |
|
31 #include "cchlogger.h" |
|
32 |
|
33 _LIT( KCchResourceDir, "\\resource\\apps\\" ); |
|
34 _LIT( KCchResourceFileName, "cch.r??" ); |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CCchNoteHandler::CCchNoteHandler |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CCchNoteHandler::CCchNoteHandler( CCCHServerBase& aServer ) |
|
45 : CActive ( EPriorityHigh ), |
|
46 iServer( aServer ), |
|
47 iCoverDisplaySupported( aServer.FeatureManager().CoverDisplaySupported() ) |
|
48 { |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CCchNoteHandler::NewL |
|
53 // Two-phased constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CCchNoteHandler* CCchNoteHandler::NewL( CCCHServerBase& aServer ) |
|
57 { |
|
58 CCchNoteHandler* self = |
|
59 new (ELeave) CCchNoteHandler( aServer ); |
|
60 |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop( self ); |
|
64 |
|
65 return self; |
|
66 } |
|
67 |
|
68 // ---------------------------------------------------------------------------- |
|
69 // CCchNoteHandler::ConstructL() |
|
70 // ---------------------------------------------------------------------------- |
|
71 |
|
72 void CCchNoteHandler::ConstructL() |
|
73 { |
|
74 iGlobalMsgQuery = CAknGlobalMsgQuery::NewL(); |
|
75 iCchCenRep = CRepository::NewL( KCRUidCch ); |
|
76 User::LeaveIfError( iFsSession.Connect() ); |
|
77 iResourceFile = ScanFileL( TFileName( KCchResourceFileName ), |
|
78 TFileName( KCchResourceDir ) ); |
|
79 User::LeaveIfNull( iResourceFile ); |
|
80 CActiveScheduler::Add( this ); |
|
81 } |
|
82 |
|
83 // ---------------------------------------------------------------------------- |
|
84 // CCchNoteHandler::~CCchNoteHandler() |
|
85 // Destructor |
|
86 // ---------------------------------------------------------------------------- |
|
87 |
|
88 CCchNoteHandler::~CCchNoteHandler() |
|
89 { |
|
90 Cancel(); |
|
91 iMsgQueryInfoArray.Close(); |
|
92 iFsSession.Close(); |
|
93 delete iResourceFile; |
|
94 delete iCchCenRep; |
|
95 delete iGlobalMsgQuery; |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CCchNoteHandler::RunL |
|
100 // From CActive, handles note/query dismissal. |
|
101 // (other items were commented in a header). |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CCchNoteHandler::RunL() |
|
105 { |
|
106 TInt status = iStatus.Int(); |
|
107 CCHLOGSTRING2( "CCchNoteHandler::RunL iResourceId: %d", iResourceId ); |
|
108 |
|
109 // update central repository |
|
110 switch ( iResourceId ) |
|
111 { |
|
112 case R_QTN_FIRST_EMERGENCY_WARNING_NOTE: |
|
113 { |
|
114 if ( status == EAknSoftkeyYes || status == EAknSoftkeyOk ) |
|
115 { |
|
116 iCchCenRep->Set( |
|
117 KCCHVoIPEmergencyWarningShown, |
|
118 ECCHVoIPEmergencyWarningAlreadyShown ); |
|
119 } |
|
120 if( iDie ) |
|
121 { |
|
122 |
|
123 delete this; |
|
124 return; |
|
125 } |
|
126 else |
|
127 { |
|
128 // now we are show this emergency note -> we can show |
|
129 // another if needed |
|
130 iServer.SetVoIPEmergencyNoteShown( EFalse ); |
|
131 } |
|
132 break; |
|
133 } |
|
134 case R_QTN_VOIP_DO_NOT_SHOW_WARNING: |
|
135 { |
|
136 if ( status == EAknSoftkeyYes || status == EAknSoftkeyOk ) |
|
137 { |
|
138 iCchCenRep->Set( |
|
139 KCCHVoIPShowEmergencyWarningOnOff, |
|
140 ECCHVoIPEmergencyWarningOnOffDoNotShowWarning ); |
|
141 |
|
142 } |
|
143 if( iDie ) |
|
144 { |
|
145 |
|
146 delete this; |
|
147 return; |
|
148 } |
|
149 else |
|
150 { |
|
151 // now we are show this emergency note -> we can show |
|
152 // another if needed |
|
153 iServer.SetVoIPEmergencyNoteShown( EFalse ); |
|
154 } |
|
155 break; |
|
156 } |
|
157 case R_QTN_SERVTAB_ALLOW_GPRS_WHEN_ROAMING_QUERY: |
|
158 { |
|
159 if ( status == EAknSoftkeyYes || status == EAknSoftkeyOk ) |
|
160 { |
|
161 // Set gprs roaming cost warning note as shown to cenrep |
|
162 iCchCenRep->Set( |
|
163 KCCHGprsRoamingCostWarningShown, |
|
164 ECCHGprsRoamingCostWarningAlreadyShown ); |
|
165 } |
|
166 } |
|
167 default: |
|
168 break; |
|
169 } |
|
170 |
|
171 // delete self |
|
172 if( iResourceId != R_QTN_VOIP_EM_CALL_ERROR_NOTE_NO_CS && iDie ) |
|
173 { |
|
174 delete this; |
|
175 return; |
|
176 } |
|
177 |
|
178 // peek one message from query array |
|
179 if( iMsgQueryInfoArray.Count() > 0 ) |
|
180 { |
|
181 TGlobalMsgQueryInfo msgQueryInfo = iMsgQueryInfoArray[0]; |
|
182 DoLaunchGlobalNoteL( msgQueryInfo.iResourceId, |
|
183 msgQueryInfo.iSoftkeyId, |
|
184 msgQueryInfo.iSecondaryDisplayIndex ); |
|
185 |
|
186 iMsgQueryInfoArray.Remove( 0 ); |
|
187 } |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CCchNoteHandler::CanBeDestroyed |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 TBool CCchNoteHandler::CanBeDestroyed() |
|
195 { |
|
196 if( IsActive() ) |
|
197 { |
|
198 iDie = ETrue; |
|
199 return EFalse; |
|
200 } |
|
201 else |
|
202 { |
|
203 return ETrue; |
|
204 } |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CCchNoteHandler::DoCancel |
|
209 // From CActive, cancels current operation. |
|
210 // (other items were commented in a header). |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CCchNoteHandler::DoCancel() |
|
214 { |
|
215 iGlobalMsgQuery->CancelMsgQuery(); |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CCchNoteHandler::RunError |
|
220 // From CActive, handles exceptions in RunL. |
|
221 // (other items were commented in a header). |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 TInt CCchNoteHandler::RunError( TInt /*aError*/ ) |
|
225 { |
|
226 return KErrNone; |
|
227 } |
|
228 |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CCchNoteHandler::LaunchGlobalNoteL |
|
232 // |
|
233 // (other items were commented in a header). |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 void CCchNoteHandler::LaunchGlobalNoteL( const TInt aResourceId, |
|
237 const TInt aSoftKeyConfig, |
|
238 const TInt aSecondaryDisplayIndex ) |
|
239 { |
|
240 // Check there is global message query is shown at the moment |
|
241 if ( IsActive() ) |
|
242 { |
|
243 // add the message query info to array |
|
244 TGlobalMsgQueryInfo msgQueryInfo; |
|
245 msgQueryInfo.iResourceId = aResourceId; |
|
246 msgQueryInfo.iSoftkeyId = aSoftKeyConfig; |
|
247 msgQueryInfo.iSecondaryDisplayIndex = aSecondaryDisplayIndex; |
|
248 |
|
249 iMsgQueryInfoArray.AppendL( msgQueryInfo ); |
|
250 } |
|
251 else |
|
252 { |
|
253 DoLaunchGlobalNoteL( aResourceId, aSoftKeyConfig, aSecondaryDisplayIndex ); |
|
254 } |
|
255 |
|
256 if( aResourceId == R_QTN_VOIP_EM_CALL_ERROR_NOTE_NO_CS ) |
|
257 { |
|
258 TGlobalMsgQueryInfo msgQueryInfo; |
|
259 msgQueryInfo.iResourceId = R_QTN_VOIP_DO_NOT_SHOW_WARNING; |
|
260 msgQueryInfo.iSoftkeyId = R_AVKON_SOFTKEYS_OK_CANCEL; |
|
261 msgQueryInfo.iSecondaryDisplayIndex = |
|
262 SecondaryDisplay::ECmdShowDoNotShowVoipEmergencyCallWarningQuery; |
|
263 |
|
264 iMsgQueryInfoArray.AppendL( msgQueryInfo ); |
|
265 } |
|
266 |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CCchNoteHandler::DoLaunchGlobalNoteL |
|
271 // |
|
272 // (other items were commented in a header). |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 void CCchNoteHandler::DoLaunchGlobalNoteL( const TInt aResourceId, |
|
276 const TInt aSoftKeyConfig, |
|
277 const TInt aSecondaryDisplayIndex ) |
|
278 { |
|
279 iResourceId = aResourceId; |
|
280 HBufC* textBuffer = LoadResourceL( aResourceId ); |
|
281 CleanupStack::PushL( textBuffer ); |
|
282 |
|
283 // Set secondary display data if necessary |
|
284 if ( iCoverDisplaySupported ) |
|
285 { |
|
286 CAknSDData* sd = CAknSDData::NewL( |
|
287 SecondaryDisplay::KCatCch, |
|
288 aSecondaryDisplayIndex, |
|
289 KNullDesC8); |
|
290 |
|
291 iGlobalMsgQuery->SetSecondaryDisplayData(sd); |
|
292 } |
|
293 |
|
294 iGlobalMsgQuery->ShowMsgQueryL( |
|
295 iStatus, |
|
296 textBuffer->Des(), |
|
297 aSoftKeyConfig, |
|
298 KNullDesC, |
|
299 KNullDesC ); |
|
300 |
|
301 CleanupStack::PopAndDestroy( textBuffer ); |
|
302 SetActive(); |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CCchNoteHandler::LoadResourceL |
|
307 // Loads the localized text resource from resource file |
|
308 // (other items were commented in a header). |
|
309 // ----------------------------------------------------------------------------- |
|
310 // |
|
311 HBufC* CCchNoteHandler::LoadResourceL( TInt aResourceID ) |
|
312 { |
|
313 RResourceFile resourceFile; |
|
314 CleanupClosePushL( resourceFile ); |
|
315 resourceFile.OpenL( iFsSession, *iResourceFile ); |
|
316 resourceFile.ConfirmSignatureL( 0 ); |
|
317 HBufC8* readBuffer=resourceFile.AllocReadLC( |
|
318 aResourceID ); |
|
319 const TPtrC16 ptrReadBuffer( |
|
320 (TText16*) readBuffer->Ptr(),(readBuffer->Length()+1) >> 1 ); |
|
321 HBufC* textBuffer=HBufC16::NewL( ptrReadBuffer.Length() ); |
|
322 *textBuffer=ptrReadBuffer; |
|
323 CleanupStack::PopAndDestroy( readBuffer ); |
|
324 CleanupStack::PopAndDestroy( &resourceFile ); |
|
325 return textBuffer; |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CCchNoteHandler::ScanFileC |
|
330 // Finds out the correct path for a file |
|
331 // (other items were commented in a header). |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 HBufC* CCchNoteHandler::ScanFileL( const TDesC& aFileName, |
|
335 const TDesC& aFilePath ) |
|
336 { |
|
337 CCHLOGSTRING( "CCchNoteHandler::ScanFileL: IN" ); |
|
338 TFindFile search( iFsSession); |
|
339 CDir* dirlist; |
|
340 HBufC* fullName = NULL; |
|
341 TFileName filename(aFileName); |
|
342 TInt err = search.FindWildByDir( filename, aFilePath, dirlist ); |
|
343 if (err == KErrNone) |
|
344 { |
|
345 CCHLOGSTRING( "CCchNoteHandler::ScanFileL: dir found" ); |
|
346 if ( dirlist && 0 < dirlist->Count() ) |
|
347 { |
|
348 TParse fullentry; |
|
349 fullentry.Set( (*dirlist)[0].iName, &search.File(), NULL ); |
|
350 TFileName nearestFile( fullentry.FullName() ); |
|
351 BaflUtils::NearestLanguageFile( iFsSession, nearestFile ); |
|
352 |
|
353 fullName = HBufC::NewL( nearestFile.Length() ); |
|
354 fullName->Des().Copy( nearestFile ); |
|
355 } |
|
356 delete dirlist; |
|
357 } |
|
358 CCHLOGSTRING2( "CCchNoteHandler::ScanFileL: OUT value=%s",fullName ); |
|
359 return fullName; |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CCchNoteHandler::CchCenRep |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 CRepository* CCchNoteHandler::CchCenRep() |
|
367 { |
|
368 return iCchCenRep; |
|
369 } |
|
370 // End of File |