|
1 /* |
|
2 * Copyright (c) 2004 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: Login SAP select UI control. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32std.h> |
|
20 #include <CIMPSSAPSettings.h> |
|
21 #include <PEngWVPresenceErrors2.h> |
|
22 #include <CPEngNWSessionSlotID2.h> |
|
23 #include <CPEngNWSessionSlotManager2.h> |
|
24 #include <PEngPresenceEngineConsts2.h> |
|
25 #include <barsc.h> |
|
26 #include <impsconnectionuing.rsg> |
|
27 |
|
28 #include "CCnUiLoginUiCntrlStep.h" |
|
29 #include "CnUiSapLoginDataRefresher.h" |
|
30 #include "CCnUiConnOpener.h" |
|
31 #include "MCnUiUiControlContext.h" |
|
32 #include "MCnUiUiFacade.h" |
|
33 #include "MCnUiConnectionHandler.h" |
|
34 #include "MCnUiConnModeHandler.h" |
|
35 #include "MCnUiClientPlugin.h" |
|
36 #include "MCnUiConnModeRewaker.h" |
|
37 #include "CnUiSapDataPacker.h" |
|
38 |
|
39 #include "CnUiErrors.h" |
|
40 |
|
41 #include "CnUiClientId.h" |
|
42 #include "impscommonuibuilddefinitions.h" |
|
43 #include "IMPSCommonUiDebugPrint.h" |
|
44 |
|
45 #include "cnuitermsofusedialoghandler.h" |
|
46 #include "mimpsshareddata.h" |
|
47 #include "cimpsshareddatafactory.h" |
|
48 #include "cnuiresourcefilename.h" |
|
49 |
|
50 #include "VariantKeys.h" |
|
51 #include <centralrepository.h> |
|
52 |
|
53 // ================= MEMBER FUNCTIONS ======================= |
|
54 // Two-phased constructor. |
|
55 CCnUiLoginUiCntrlStep* CCnUiLoginUiCntrlStep::NewLC( MCnUiUiControlContext& aCCntxt, |
|
56 CIMPSSAPSettings& aLoginSap, |
|
57 TIMPSLoginType aLoginType, |
|
58 CPEngNWSessionSlotID2& aNWSessionSlotID, |
|
59 TIMPSConnectionClient aClient ) |
|
60 { |
|
61 CCnUiLoginUiCntrlStep* self = new ( ELeave ) CCnUiLoginUiCntrlStep( aCCntxt, |
|
62 aLoginSap, |
|
63 aNWSessionSlotID, |
|
64 aClient, |
|
65 aLoginType ); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL(); |
|
68 return self; |
|
69 } |
|
70 |
|
71 |
|
72 // Destructor |
|
73 CCnUiLoginUiCntrlStep::~CCnUiLoginUiCntrlStep() |
|
74 { |
|
75 if ( iConnOpener->IsActive() ) |
|
76 { |
|
77 iConnOpener->Cancel(); |
|
78 } |
|
79 delete iConnOpener; |
|
80 delete iWaitNote; |
|
81 iRFs.Close(); |
|
82 delete iSharedData; |
|
83 } |
|
84 |
|
85 // C++ default constructor can NOT contain any code, that |
|
86 // might leave. |
|
87 // |
|
88 CCnUiLoginUiCntrlStep::CCnUiLoginUiCntrlStep( MCnUiUiControlContext& aCCntxt, |
|
89 CIMPSSAPSettings& aLoginSap, |
|
90 CPEngNWSessionSlotID2& aNWSessionSlotID, |
|
91 TIMPSConnectionClient aClient, |
|
92 TIMPSLoginType aLoginType ) |
|
93 : iCCntxt( aCCntxt ), |
|
94 iLoginSap( aLoginSap ), |
|
95 iLoginType( aLoginType ), |
|
96 iSessionSlotID( aNWSessionSlotID ), |
|
97 iClient( aClient ) |
|
98 { |
|
99 } |
|
100 |
|
101 |
|
102 // Symbian OS default constructor can leave. |
|
103 void CCnUiLoginUiCntrlStep::ConstructL() |
|
104 { |
|
105 iConnOpener = CCnUiConnOpener::NewL(); |
|
106 iSharedData = CIMPSSharedDataFactory::CreateTemporaryKeyHandlerL( NULL, KBrandingUid ); |
|
107 } |
|
108 |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CCnUiLoginUiCntrlStep::RunStepL() |
|
112 // from MCnUiCntrlStep |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TInt CCnUiLoginUiCntrlStep::RunStepL() |
|
116 { |
|
117 TInt loginTrieStatus = KErrNone; |
|
118 |
|
119 TBool loginRetryOngoing( EFalse ); |
|
120 TBool loginRetryAllowed = ETrue; |
|
121 while ( loginRetryAllowed ) |
|
122 { |
|
123 //initialization is needed on every round since |
|
124 //there might have run some sub steps when handling login result |
|
125 TIMPSConnectionClient clientToLogIn; |
|
126 TInt initErr = DoInitLoginStepL( clientToLogIn ); |
|
127 if ( initErr != ECnUiLoginInitContinue ) |
|
128 { |
|
129 return initErr; |
|
130 } |
|
131 |
|
132 if ( ( iLoginSap.SAPUserId().Length() == 0 ) || |
|
133 ( iLoginSap.SAPUserPassword().Length() == 0 ) ) |
|
134 { |
|
135 if ( !CnUiSapLoginDataRefresher::RefreshLoginDataL( iCCntxt.Ui(), |
|
136 iLoginSap, |
|
137 EFalse ) ) |
|
138 { |
|
139 //user canceled the login data query |
|
140 iCCntxt.Ui().ShowNoteL( ECnUiConnCanceled ); |
|
141 return KErrCancel; |
|
142 } |
|
143 else |
|
144 { |
|
145 // User ID may have changed |
|
146 // Check Terms of use variation |
|
147 if ( ReadResourceIntValueL( RSC_CHAT_VARIATION_IMPSCU_TOU_MESSAGE ) |
|
148 && iLoginSap.SAPUserId().Length() > 0 ) |
|
149 { |
|
150 TInt retVal = CnUiTermsOfUseDialogHandler::HandleTermsOfUseDialogL( |
|
151 iLoginSap, iCCntxt.Ui(), iCCntxt.SapStoreL() ); |
|
152 |
|
153 if ( retVal == KErrCancel ) |
|
154 { |
|
155 // User canceled ToU query, login cancelled |
|
156 // note is already shown inside HandleTermsOfUseDialogL |
|
157 // method, return KErrCancel |
|
158 return retVal; |
|
159 } |
|
160 } |
|
161 } |
|
162 } |
|
163 |
|
164 if ( iLoginSap.ClientId().Length() == 0 ) |
|
165 { |
|
166 iLoginSap.SetClientIdL( KClientId() ); |
|
167 } |
|
168 |
|
169 // set the network session slot ID |
|
170 iSessionSlotID.SetServiceAddressL( iLoginSap.SAPAddress() ); |
|
171 iSessionSlotID.SetUserIdL( iLoginSap.SAPUserId() ); |
|
172 |
|
173 if ( iClient == EIMPSConnClientIM ) |
|
174 { |
|
175 iSessionSlotID.SetAppIdL( KPEngAppIdIM() ); |
|
176 } |
|
177 else |
|
178 { |
|
179 iSessionSlotID.SetAppIdL( KPEngAppIdPEC() ); |
|
180 } |
|
181 |
|
182 // create a network session slot to PEC engine |
|
183 CPEngNWSessionSlotManager2* slotManager = CPEngNWSessionSlotManager2::NewLC(); |
|
184 |
|
185 TInt err = slotManager->CreateNWSessionSlot( iSessionSlotID ); |
|
186 // we can ignore KErrAlreadyExist, since if the error is that |
|
187 // we can just start using the slot |
|
188 if ( ( err != KErrNone ) && ( err != KErrAlreadyExists ) ) |
|
189 { |
|
190 User::Leave( err ); |
|
191 } |
|
192 CleanupStack::PopAndDestroy( slotManager ); |
|
193 |
|
194 //proceed with login, notify first observers |
|
195 iCCntxt.ProcessObserverProxy().NotifyAccessingSapL( iLoginSap ); |
|
196 |
|
197 |
|
198 //store clients needing AA rewake to login SAP |
|
199 RArray< TIMPSConnectionClient > clientsNeedingAARewake; |
|
200 CleanupClosePushL( clientsNeedingAARewake ); |
|
201 iCCntxt.ConnModeRewaker().GetAARewakeListL( clientsNeedingAARewake ); |
|
202 |
|
203 CnUiSapDataPacker::PackAAClientsL( clientsNeedingAARewake, iLoginSap ); |
|
204 CleanupStack::PopAndDestroy(); //clientsNeedingAARewake |
|
205 |
|
206 TBool refreshPlugin( EFalse ); |
|
207 if ( loginRetryOngoing ) |
|
208 { |
|
209 refreshPlugin = ETrue; |
|
210 loginRetryOngoing = EFalse; |
|
211 } |
|
212 //Open the client connection using the connection opener |
|
213 //control listens opener progress events |
|
214 //and sets up proper wait notes according the opener states |
|
215 loginTrieStatus = iConnOpener->MakeLoginForClient( |
|
216 clientToLogIn, |
|
217 iLoginSap, |
|
218 iCCntxt.ClientPluginL( clientToLogIn, iSessionSlotID, refreshPlugin ), |
|
219 iCCntxt.ConnHandler(), |
|
220 this, |
|
221 iSessionSlotID ); |
|
222 |
|
223 //connection opener finished its processing |
|
224 //clear any existing wait note set by the progress step. |
|
225 //own wait note container used ==> direct deletion ok. |
|
226 delete iWaitNote; |
|
227 iWaitNote = NULL; |
|
228 |
|
229 //handle success |
|
230 if ( loginTrieStatus == KErrNone ) |
|
231 { |
|
232 //Rewake list is now stored in logged in SAP |
|
233 //==> clear existing rewake list |
|
234 iCCntxt.ConnModeRewaker().ClearAARewakeList(); |
|
235 |
|
236 //and notify about user level login |
|
237 if ( iLoginType == EIMPSAAConnectionStart ) |
|
238 { |
|
239 iCCntxt.ConnModeHandler().SendUserSelectionL( EUserLevelAAConnectionStart, |
|
240 clientToLogIn ); |
|
241 } |
|
242 else |
|
243 { |
|
244 iCCntxt.ConnModeHandler().SendUserSelectionL( EUserLevelLogin, |
|
245 clientToLogIn ); |
|
246 } |
|
247 |
|
248 //login is completed |
|
249 return KErrNone; |
|
250 } |
|
251 |
|
252 |
|
253 //handle errors & determine wheter to try again |
|
254 //only here listed errors may cause the restart from begining |
|
255 switch ( loginTrieStatus ) |
|
256 { |
|
257 case KPEngNwErrInvalidPassword: |
|
258 case KPEngNwErrUnknownUser: |
|
259 case KPEngNwErrInvalidOrUnSupportedUserProperties: |
|
260 case KPEngNwErrUnauthorized: |
|
261 { |
|
262 loginTrieStatus = HandleLoginDataFailureL( loginTrieStatus ); |
|
263 if ( !loginTrieStatus ) |
|
264 { |
|
265 loginRetryOngoing = ETrue; |
|
266 } |
|
267 break; |
|
268 } |
|
269 |
|
270 case KCnUiErrorAlreadyConnectedToAnotherSap: |
|
271 { |
|
272 loginTrieStatus = HandleConflictingSapConnectionL( loginTrieStatus, |
|
273 clientToLogIn ); |
|
274 break; |
|
275 } |
|
276 |
|
277 default: |
|
278 { |
|
279 //in all other cases restart isn't allowed but some note is needed |
|
280 iCCntxt.Ui().ShowLoginErrorNoteL( loginTrieStatus ); |
|
281 break; |
|
282 } |
|
283 } |
|
284 |
|
285 if ( loginTrieStatus != KErrNone ) |
|
286 { |
|
287 //No retry allowed ==> stop login tries here |
|
288 loginRetryAllowed = EFalse; |
|
289 } |
|
290 } |
|
291 |
|
292 return loginTrieStatus; |
|
293 } |
|
294 |
|
295 |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CCnUiLoginUiCntrlStep::HandleCompleteL() |
|
299 // from MCnUiCntrlStep |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 TCnUiHandleCompleteStatus CCnUiLoginUiCntrlStep::HandleCompleteL() |
|
303 { |
|
304 //nothing to complete |
|
305 return ECnUiStepContinueTeardown; |
|
306 } |
|
307 |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CCnUiLoginUiCntrlStep::UndoStepL() |
|
311 // from MCnUiCntrlStep |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void CCnUiLoginUiCntrlStep::UndoStepL() |
|
315 { |
|
316 //nothing to undo |
|
317 } |
|
318 |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CCnUiLoginUiCntrlStep::HandleWaitNoteCancel() |
|
322 // from MCnUiWaitNoteObserver |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 void CCnUiLoginUiCntrlStep::HandleWaitNoteCancel() |
|
326 { |
|
327 iConnOpener->CancelLogin(); |
|
328 } |
|
329 |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CCnUiLoginUiCntrlStep::HandleProgressStateEnter() |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 void CCnUiLoginUiCntrlStep::HandleProgressStateEnter( TInt aStateId, |
|
336 TIMPSConnectionClient aClient ) |
|
337 { |
|
338 IMPSCUI_DP_FUNC_ENTER( "CCnUiLoginUiCntrlStep::HandleProgressStateEnter()" ); |
|
339 TRAPD( leaveErr, DoShowLoginStateSpecificWaitnoteL( aStateId, aClient ) ) |
|
340 if ( ( aStateId == ECnOpenerProcessingPlugin ) && ( !leaveErr ) ) |
|
341 { |
|
342 //show login ok note |
|
343 TRAP( leaveErr, iCCntxt.Ui().ShowNoteL( ECnUiConnectionOK ) ); |
|
344 } |
|
345 iCCntxt.Ui().HandleIfError( leaveErr ); |
|
346 IMPSCUI_DP_FUNC_DONE( "CCnUiLoginUiCntrlStep::HandleProgressStateEnter()" ); |
|
347 } |
|
348 |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CCnUiLoginUiCntrlStep::DoInitLoginStepL() |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 TInt CCnUiLoginUiCntrlStep::DoInitLoginStepL( TIMPSConnectionClient& aClient ) |
|
355 { |
|
356 TIMPSConnectionClient clientId = iCCntxt.ControlledClient(); |
|
357 if ( iCCntxt.ConnHandler().TheClientLoggedInL( clientId ) ) |
|
358 { |
|
359 //current client is already logged in |
|
360 return KCnUiErrorClientAlreadyConnected; |
|
361 } |
|
362 |
|
363 aClient = clientId; |
|
364 return ECnUiLoginInitContinue; |
|
365 } |
|
366 |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // CCnUiLoginUiCntrlStep::DoShowLoginStateSpecificWaitnoteL() |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 void CCnUiLoginUiCntrlStep::DoShowLoginStateSpecificWaitnoteL( TInt aStateId, |
|
373 TIMPSConnectionClient aClient ) |
|
374 { |
|
375 switch ( aStateId ) |
|
376 { |
|
377 //FLOW TROUGH |
|
378 case ECnOpenerOpeningSAPConnection: |
|
379 case ECnOpenerClosingInterferingSAPConnection: |
|
380 { |
|
381 if ( !iWaitNote ) |
|
382 { |
|
383 // opening SAP connection |
|
384 if ( aClient == EIMPSConnClientIM ) |
|
385 { |
|
386 iWaitNote = iCCntxt.Ui().WaitNoteL( ECnUiWaitNoteConnectingChat, |
|
387 iLoginSap.SAPName(), |
|
388 this ); |
|
389 } |
|
390 |
|
391 else |
|
392 { |
|
393 //client is considered to be PEC |
|
394 iWaitNote = iCCntxt.Ui().WaitNoteL( ECnUiWaitNoteConnectingPEC, |
|
395 iLoginSap.SAPName(), |
|
396 this ); |
|
397 } |
|
398 } |
|
399 |
|
400 break; |
|
401 } |
|
402 case ECnOpenerProcessingPlugin: |
|
403 case ECnOpenerIdle: |
|
404 case ECnOpenerClosingOwnedSAPConnection: |
|
405 default: |
|
406 { |
|
407 //clear any existing wait note set by the previous |
|
408 //progress steps. No wait note used during these steps. |
|
409 //own wait note container used ==> direct deletion ok. |
|
410 delete iWaitNote; |
|
411 iWaitNote = NULL; |
|
412 |
|
413 break; |
|
414 } |
|
415 } |
|
416 } |
|
417 |
|
418 |
|
419 |
|
420 // ----------------------------------------------------------------------------- |
|
421 // CCnUiLoginUiCntrlStep::HandleLoginDataFailureL() |
|
422 // ----------------------------------------------------------------------------- |
|
423 // |
|
424 TInt CCnUiLoginUiCntrlStep::HandleLoginDataFailureL( TInt aTrieError ) |
|
425 { |
|
426 //login has failed to improper user name or password |
|
427 //show a note for the reason & refresh the login data |
|
428 iCCntxt.Ui().ShowLoginErrorNoteL( aTrieError ); |
|
429 if ( CnUiSapLoginDataRefresher::RefreshLoginDataL( iCCntxt.Ui(), iLoginSap, ETrue ) ) |
|
430 { |
|
431 return KErrNone; //user accepted the login data query ==> retry |
|
432 } |
|
433 |
|
434 else |
|
435 { |
|
436 //user canceled the login data query |
|
437 iCCntxt.Ui().ShowNoteL( ECnUiConnCanceled ); |
|
438 return KErrCancel; |
|
439 } |
|
440 } |
|
441 |
|
442 |
|
443 // ----------------------------------------------------------------------------- |
|
444 // CCnUiLoginUiCntrlStep::HandleConflictingSapConnectionL() |
|
445 // ----------------------------------------------------------------------------- |
|
446 // |
|
447 TInt CCnUiLoginUiCntrlStep::HandleConflictingSapConnectionL( |
|
448 TInt aTrieError, |
|
449 TIMPSConnectionClient aTriedLoginClient ) |
|
450 { |
|
451 TBool dropExistingConnection = EFalse; |
|
452 if ( aTriedLoginClient == EIMPSConnClientPEC ) |
|
453 { |
|
454 //PEC trying to connect |
|
455 //==> the other existing client must be IM |
|
456 dropExistingConnection = iCCntxt.Ui().ConfirmationQueryL( ECnUiDropIMLogin, |
|
457 iLoginSap.SAPName() ); |
|
458 } |
|
459 else |
|
460 { |
|
461 dropExistingConnection = iCCntxt.Ui().ConfirmationQueryL( ECnUiDropPECLogin, |
|
462 iLoginSap.SAPName() ); |
|
463 } |
|
464 |
|
465 |
|
466 if ( !dropExistingConnection ) |
|
467 { |
|
468 //user doesn't want to terminate existing connection |
|
469 iCCntxt.Ui().ShowNoteL( ECnUiConnCanceled ); |
|
470 return KErrCancel; |
|
471 } |
|
472 |
|
473 //user selected to drop existing connection |
|
474 //if disconnecting succeeds, then retry is allowed |
|
475 //else return the original error |
|
476 if ( TryDisconnectOtherConnectionsL() ) |
|
477 { |
|
478 return KErrNone; |
|
479 } |
|
480 else |
|
481 { |
|
482 return aTrieError; |
|
483 } |
|
484 } |
|
485 |
|
486 |
|
487 // ----------------------------------------------------------------------------- |
|
488 // CCnUiLoginUiCntrlStep::TryDisconnectOtherConnectionsL() |
|
489 // ----------------------------------------------------------------------------- |
|
490 // |
|
491 TBool CCnUiLoginUiCntrlStep::TryDisconnectOtherConnectionsL() |
|
492 { |
|
493 TBool subOperationOk = EFalse; |
|
494 CIMPSSAPSettings* disconnectedSap = CIMPSSAPSettings::NewLC(); |
|
495 RArray< TIMPSConnectionClient > disconnectedClients; |
|
496 CleanupClosePushL( disconnectedClients ); |
|
497 |
|
498 |
|
499 TInt disconnStatus = iCCntxt.SubOpDisconnectAllL( *disconnectedSap, |
|
500 disconnectedClients, |
|
501 iSessionSlotID ); |
|
502 if ( ( disconnStatus == KErrNone ) || |
|
503 ( disconnStatus == KCnUiErrorNoClientsToDisconnect ) ) |
|
504 { |
|
505 //sub operation succeeded |
|
506 subOperationOk = ETrue; |
|
507 |
|
508 //Add disconnected clients to AA mode rewaker |
|
509 const TInt disconnectedClientsCount = disconnectedClients.Count(); |
|
510 for ( TInt ii = 0; ii < disconnectedClientsCount; ii++ ) |
|
511 { |
|
512 TIMPSConnectionClient client = disconnectedClients[ ii ]; |
|
513 MCnUiClientPlugin& clientPlugin = iCCntxt.ClientPluginL( client, iSessionSlotID ); |
|
514 |
|
515 iCCntxt.ConnModeRewaker().AddToAAModeRewakeListL( clientPlugin, iSessionSlotID ); |
|
516 } |
|
517 } |
|
518 |
|
519 CleanupStack::PopAndDestroy( 2 ); //disconnectedClients, disconnectedSap |
|
520 return subOperationOk; |
|
521 } |
|
522 |
|
523 // ----------------------------------------------------------------------------- |
|
524 // CCnUiLoginUiCntrlStep::OpenResourceFileLC() |
|
525 // !!!Notice!!!. Two variables in cleanupstack after call of this method. |
|
526 // ----------------------------------------------------------------------------- |
|
527 // |
|
528 void CCnUiLoginUiCntrlStep::OpenResourceFileLC( RResourceFile& aResourceFile ) |
|
529 { |
|
530 TFileName resourceFileName; |
|
531 iRFs.Close(); |
|
532 User::LeaveIfError( iRFs.Connect() ); |
|
533 |
|
534 TInt err = iSharedData->GetStringKey( ( TIMPSSharedKeys )KBrandingResourceKey, resourceFileName ); |
|
535 if ( err || !resourceFileName.Length() ) |
|
536 { |
|
537 CnUiResourceFileName::NearestVariationForCurrentLanguage( iRFs, resourceFileName ); |
|
538 } |
|
539 aResourceFile.OpenL( iRFs, resourceFileName ); |
|
540 CleanupClosePushL( aResourceFile ); |
|
541 aResourceFile.ConfirmSignatureL(); |
|
542 } |
|
543 |
|
544 // ----------------------------------------------------------------------------- |
|
545 // CCnUiLoginUiCntrlStep::ReadResourceIntValueL() |
|
546 // ----------------------------------------------------------------------------- |
|
547 // |
|
548 TInt CCnUiLoginUiCntrlStep::ReadResourceIntValueL( TInt aResourceId ) |
|
549 { |
|
550 |
|
551 |
|
552 TInt val( 0 ); |
|
553 TInt err ( KErrNone ); |
|
554 |
|
555 CRepository* rep = 0; |
|
556 |
|
557 TRAP( err, rep = CRepository::NewL( KCRUidIMNG ) ); |
|
558 |
|
559 if ( err == KErrNone ) |
|
560 { |
|
561 TInt key = aResourceId + KIMCUStartVariationID; |
|
562 |
|
563 err = rep->Get( key, val ); |
|
564 |
|
565 delete rep; |
|
566 } |
|
567 |
|
568 if ( err != KErrNone ) |
|
569 { |
|
570 |
|
571 RResourceFile resFile; |
|
572 OpenResourceFileLC( resFile ); // Two items in cleanup stack. |
|
573 |
|
574 aResourceId = aResourceId + RSC_CRRSS_CHAT_VARIATION_IMPSCU_START_ID; |
|
575 |
|
576 // read the data to a buffer |
|
577 TInt plainResourceId = 0x00000fff & aResourceId; // Remove offset from id |
|
578 HBufC8* rawDataBuf = resFile.AllocReadLC( plainResourceId ); |
|
579 |
|
580 // it's now as ascii code: \x00 for 0, \x01 for 1, etc. |
|
581 TUint value = ( *rawDataBuf )[ 0 ]; |
|
582 |
|
583 CleanupStack::PopAndDestroy( 2 ); // rawDataBuf, resFile |
|
584 |
|
585 val = value; |
|
586 } |
|
587 |
|
588 return val; |
|
589 |
|
590 } |
|
591 |
|
592 // End of File |
|
593 |
|
594 |