28
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2010 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 |
break;
|
|
168 |
default:
|
|
169 |
break;
|
|
170 |
}
|
|
171 |
|
|
172 |
// delete self
|
|
173 |
if( iResourceId != R_QTN_VOIP_EM_CALL_ERROR_NOTE_NO_CS && iDie )
|
|
174 |
{
|
|
175 |
delete this;
|
|
176 |
return;
|
|
177 |
}
|
|
178 |
|
|
179 |
// peek one message from query array
|
|
180 |
if( iMsgQueryInfoArray.Count() > 0 )
|
|
181 |
{
|
|
182 |
TGlobalMsgQueryInfo msgQueryInfo = iMsgQueryInfoArray[0];
|
|
183 |
DoLaunchGlobalNoteL( msgQueryInfo.iResourceId,
|
|
184 |
msgQueryInfo.iSoftkeyId,
|
|
185 |
msgQueryInfo.iSecondaryDisplayIndex );
|
|
186 |
|
|
187 |
iMsgQueryInfoArray.Remove( 0 );
|
|
188 |
}
|
|
189 |
}
|
|
190 |
|
|
191 |
// -----------------------------------------------------------------------------
|
|
192 |
// CCchNoteHandler::CanBeDestroyed
|
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
//
|
|
195 |
TBool CCchNoteHandler::CanBeDestroyed()
|
|
196 |
{
|
|
197 |
if( IsActive() )
|
|
198 |
{
|
|
199 |
iDie = ETrue;
|
|
200 |
return EFalse;
|
|
201 |
}
|
|
202 |
else
|
|
203 |
{
|
|
204 |
return ETrue;
|
|
205 |
}
|
|
206 |
}
|
|
207 |
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
// CCchNoteHandler::DoCancel
|
|
210 |
// From CActive, cancels current operation.
|
|
211 |
// (other items were commented in a header).
|
|
212 |
// -----------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
void CCchNoteHandler::DoCancel()
|
|
215 |
{
|
|
216 |
iGlobalMsgQuery->CancelMsgQuery();
|
|
217 |
}
|
|
218 |
|
|
219 |
// -----------------------------------------------------------------------------
|
|
220 |
// CCchNoteHandler::RunError
|
|
221 |
// From CActive, handles exceptions in RunL.
|
|
222 |
// (other items were commented in a header).
|
|
223 |
// -----------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
TInt CCchNoteHandler::RunError( TInt /*aError*/ )
|
|
226 |
{
|
|
227 |
return KErrNone;
|
|
228 |
}
|
|
229 |
|
|
230 |
|
|
231 |
// -----------------------------------------------------------------------------
|
|
232 |
// CCchNoteHandler::LaunchGlobalNoteL
|
|
233 |
//
|
|
234 |
// (other items were commented in a header).
|
|
235 |
// -----------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
void CCchNoteHandler::LaunchGlobalNoteL( const TInt aResourceId,
|
|
238 |
const TInt aSoftKeyConfig,
|
|
239 |
const TInt aSecondaryDisplayIndex )
|
|
240 |
{
|
|
241 |
CCHLOGSTRING( "CCchNoteHandler::LaunchGlobalNoteL: IN" );
|
|
242 |
|
|
243 |
// Check there is global message query is shown at the moment
|
|
244 |
if ( IsActive() )
|
|
245 |
{
|
|
246 |
TBool alreadyAdded( EFalse );
|
|
247 |
for ( TInt i( 0 ) ; i < iMsgQueryInfoArray.Count() ; i++ )
|
|
248 |
{
|
|
249 |
if ( iMsgQueryInfoArray[ i ].iResourceId == aResourceId )
|
|
250 |
{
|
|
251 |
alreadyAdded = ETrue;
|
|
252 |
}
|
|
253 |
}
|
|
254 |
|
|
255 |
// Add to array only if note with same resource is not
|
|
256 |
// already in array
|
|
257 |
if ( !alreadyAdded && ( iResourceId != aResourceId ) )
|
|
258 |
{
|
|
259 |
// add the message query info to array
|
|
260 |
TGlobalMsgQueryInfo msgQueryInfo;
|
|
261 |
msgQueryInfo.iResourceId = aResourceId;
|
|
262 |
msgQueryInfo.iSoftkeyId = aSoftKeyConfig;
|
|
263 |
msgQueryInfo.iSecondaryDisplayIndex = aSecondaryDisplayIndex;
|
|
264 |
|
|
265 |
iMsgQueryInfoArray.AppendL( msgQueryInfo );
|
|
266 |
}
|
|
267 |
}
|
|
268 |
else
|
|
269 |
{
|
|
270 |
DoLaunchGlobalNoteL( aResourceId, aSoftKeyConfig, aSecondaryDisplayIndex );
|
|
271 |
}
|
|
272 |
|
|
273 |
if( aResourceId == R_QTN_VOIP_EM_CALL_ERROR_NOTE_NO_CS )
|
|
274 |
{
|
|
275 |
TGlobalMsgQueryInfo msgQueryInfo;
|
|
276 |
msgQueryInfo.iResourceId = R_QTN_VOIP_DO_NOT_SHOW_WARNING;
|
|
277 |
msgQueryInfo.iSoftkeyId = R_AVKON_SOFTKEYS_OK_CANCEL;
|
|
278 |
msgQueryInfo.iSecondaryDisplayIndex =
|
|
279 |
SecondaryDisplay::ECmdShowDoNotShowVoipEmergencyCallWarningQuery;
|
|
280 |
|
|
281 |
iMsgQueryInfoArray.AppendL( msgQueryInfo );
|
|
282 |
}
|
|
283 |
|
|
284 |
CCHLOGSTRING( "CCchNoteHandler::LaunchGlobalNoteL: OUT" );
|
|
285 |
}
|
|
286 |
|
|
287 |
// -----------------------------------------------------------------------------
|
|
288 |
// CCchNoteHandler::DoLaunchGlobalNoteL
|
|
289 |
//
|
|
290 |
// (other items were commented in a header).
|
|
291 |
// -----------------------------------------------------------------------------
|
|
292 |
//
|
|
293 |
void CCchNoteHandler::DoLaunchGlobalNoteL( const TInt aResourceId,
|
|
294 |
const TInt aSoftKeyConfig,
|
|
295 |
const TInt aSecondaryDisplayIndex )
|
|
296 |
{
|
|
297 |
CCHLOGSTRING( "CCchNoteHandler::LaunchGlobalNoteL: IN" );
|
|
298 |
|
|
299 |
iResourceId = aResourceId;
|
|
300 |
HBufC* textBuffer = LoadResourceL( aResourceId );
|
|
301 |
CleanupStack::PushL( textBuffer );
|
|
302 |
|
|
303 |
// Set secondary display data if necessary
|
|
304 |
if ( iCoverDisplaySupported )
|
|
305 |
{
|
|
306 |
CAknSDData* sd = CAknSDData::NewL(
|
|
307 |
SecondaryDisplay::KCatCch,
|
|
308 |
aSecondaryDisplayIndex,
|
|
309 |
KNullDesC8);
|
|
310 |
|
|
311 |
iGlobalMsgQuery->SetSecondaryDisplayData(sd);
|
|
312 |
}
|
|
313 |
|
|
314 |
iGlobalMsgQuery->ShowMsgQueryL(
|
|
315 |
iStatus,
|
|
316 |
textBuffer->Des(),
|
|
317 |
aSoftKeyConfig,
|
|
318 |
KNullDesC,
|
|
319 |
KNullDesC );
|
|
320 |
|
|
321 |
CleanupStack::PopAndDestroy( textBuffer );
|
|
322 |
SetActive();
|
|
323 |
|
|
324 |
CCHLOGSTRING( "CCchNoteHandler::LaunchGlobalNoteL: OUT" );
|
|
325 |
}
|
|
326 |
|
|
327 |
// -----------------------------------------------------------------------------
|
|
328 |
// CCchNoteHandler::LoadResourceL
|
|
329 |
// Loads the localized text resource from resource file
|
|
330 |
// (other items were commented in a header).
|
|
331 |
// -----------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
HBufC* CCchNoteHandler::LoadResourceL( TInt aResourceID )
|
|
334 |
{
|
|
335 |
RResourceFile resourceFile;
|
|
336 |
CleanupClosePushL( resourceFile );
|
|
337 |
resourceFile.OpenL( iFsSession, *iResourceFile );
|
|
338 |
resourceFile.ConfirmSignatureL( 0 );
|
|
339 |
HBufC8* readBuffer=resourceFile.AllocReadLC(
|
|
340 |
aResourceID );
|
|
341 |
const TPtrC16 ptrReadBuffer(
|
|
342 |
(TText16*) readBuffer->Ptr(),(readBuffer->Length()+1) >> 1 );
|
|
343 |
HBufC* textBuffer=HBufC16::NewL( ptrReadBuffer.Length() );
|
|
344 |
*textBuffer=ptrReadBuffer;
|
|
345 |
CleanupStack::PopAndDestroy( readBuffer );
|
|
346 |
CleanupStack::PopAndDestroy( &resourceFile );
|
|
347 |
return textBuffer;
|
|
348 |
}
|
|
349 |
|
|
350 |
// -----------------------------------------------------------------------------
|
|
351 |
// CCchNoteHandler::ScanFileC
|
|
352 |
// Finds out the correct path for a file
|
|
353 |
// (other items were commented in a header).
|
|
354 |
// -----------------------------------------------------------------------------
|
|
355 |
//
|
|
356 |
HBufC* CCchNoteHandler::ScanFileL( const TDesC& aFileName,
|
|
357 |
const TDesC& aFilePath )
|
|
358 |
{
|
|
359 |
CCHLOGSTRING( "CCchNoteHandler::ScanFileL: IN" );
|
|
360 |
TFindFile search( iFsSession);
|
|
361 |
CDir* dirlist;
|
|
362 |
HBufC* fullName = NULL;
|
|
363 |
TFileName filename(aFileName);
|
|
364 |
TInt err = search.FindWildByDir( filename, aFilePath, dirlist );
|
|
365 |
if (err == KErrNone)
|
|
366 |
{
|
|
367 |
CCHLOGSTRING( "CCchNoteHandler::ScanFileL: dir found" );
|
|
368 |
if ( dirlist && 0 < dirlist->Count() )
|
|
369 |
{
|
|
370 |
TParse fullentry;
|
|
371 |
fullentry.Set( (*dirlist)[0].iName, &search.File(), NULL );
|
|
372 |
TFileName nearestFile( fullentry.FullName() );
|
|
373 |
BaflUtils::NearestLanguageFile( iFsSession, nearestFile );
|
|
374 |
|
|
375 |
fullName = HBufC::NewL( nearestFile.Length() );
|
|
376 |
fullName->Des().Copy( nearestFile );
|
|
377 |
}
|
|
378 |
delete dirlist;
|
|
379 |
}
|
|
380 |
CCHLOGSTRING2( "CCchNoteHandler::ScanFileL: OUT value=%s",fullName );
|
|
381 |
return fullName;
|
|
382 |
}
|
|
383 |
|
|
384 |
// -----------------------------------------------------------------------------
|
|
385 |
// CCchNoteHandler::CchCenRep
|
|
386 |
// -----------------------------------------------------------------------------
|
|
387 |
//
|
|
388 |
CRepository* CCchNoteHandler::CchCenRep()
|
|
389 |
{
|
|
390 |
return iCchCenRep;
|
|
391 |
}
|
|
392 |
// End of File
|