83 FeatureManager::UnInitializeLib(); |
83 FeatureManager::UnInitializeLib(); |
84 Dprint ( ( _L( "CSCPPatternPlugin::ConstructL()" ) ) ); |
84 Dprint ( ( _L( "CSCPPatternPlugin::ConstructL()" ) ) ); |
85 return; |
85 return; |
86 } |
86 } |
87 |
87 |
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CSCPPatternPlugin::GetResource |
|
91 // GetResource, opens the localisation filesystem |
|
92 // Status : Approved |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 TInt CSCPPatternPlugin::GetResource() |
|
96 { |
|
97 Dprint( (_L("CSCPPatternPlugin::GetResource()") )); |
|
98 // The resource has to be loaded manually since it is not an application. |
|
99 |
|
100 if ( iFs == NULL ) |
|
101 { |
|
102 return KErrNotReady; |
|
103 } |
|
104 |
|
105 // can't use resource here because it is not added yet.... |
|
106 TFileName resourceFile; |
|
107 resourceFile.Append( KDriveZ ); |
|
108 resourceFile.Append( SCPPatternPluginSrcFile ); |
|
109 BaflUtils::NearestLanguageFile( *iFs, resourceFile ); |
|
110 |
|
111 TRAPD( err, |
|
112 iRf.OpenL( *iFs, resourceFile ); |
|
113 iRf.ConfirmSignatureL(); |
|
114 ); |
|
115 |
|
116 return err; |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------------------------------- |
|
120 // CSCPPatternPlugin::LoadResourceLC |
|
121 // LoadResourceLC, loads the localisation resource |
|
122 // Status : Approved |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 HBufC16* CSCPPatternPlugin::LoadResourceLC( TInt aResId ) |
|
126 { |
|
127 Dprint ( ( _L( "CSCPPatternPlugin::LoadResourceLC()" ) ) ); |
|
128 |
|
129 // load the actual resource |
|
130 HBufC8* readBuffer = iRf.AllocReadLC( aResId ); |
|
131 // as we are expecting HBufC16... |
|
132 const TPtrC16 ptrReadBuffer( (TText16*) readBuffer->Ptr(), |
|
133 ( readBuffer->Length() + 1 ) >> 1 ); |
|
134 HBufC16* textBuffer=HBufC16::NewL( ptrReadBuffer.Length() ); |
|
135 *textBuffer=ptrReadBuffer; |
|
136 CleanupStack::PopAndDestroy( readBuffer ); // readBuffer |
|
137 CleanupStack::PushL( textBuffer ); |
|
138 return textBuffer; |
|
139 } |
|
140 |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
88 // ---------------------------------------------------------------------------- |
143 // CSCPPatternPlugin::~CSCPPatternPlugin |
89 // CSCPPatternPlugin::~CSCPPatternPlugin |
144 // Destructor |
90 // Destructor |
145 // Status : Approved |
91 // Status : Approved |
146 // ---------------------------------------------------------------------------- |
92 // ---------------------------------------------------------------------------- |
160 // |
106 // |
161 // |
107 // |
162 // Status : Approved |
108 // Status : Approved |
163 // ---------------------------------------------------------------------------- |
109 // ---------------------------------------------------------------------------- |
164 // |
110 // |
165 CSCPParamObject* CSCPPatternPlugin::HandleEvent( TInt aID, CSCPParamObject& aParam ) |
111 void CSCPPatternPlugin :: HandleEventL( TInt aID, CSCPParamObject& aParam, CSCPParamObject& aOutParam ) |
166 { |
112 { |
167 |
|
168 Dprint ( ( _L( "CSCPPatternPlugin::HandleEvent()" ) ) ); |
113 Dprint ( ( _L( "CSCPPatternPlugin::HandleEvent()" ) ) ); |
169 |
|
170 // Make the ParamObject for success ack, Delete later |
|
171 CSCPParamObject* retParams = NULL; |
|
172 |
|
173 TBool errRaised; |
|
174 errRaised = EFalse; |
|
175 |
114 |
176 TBool isInvalid = EFalse; |
115 TBool isInvalid = EFalse; |
177 |
116 |
178 // check for Case |
117 // check for Case |
179 switch ( aID ) |
118 switch ( aID ) |
219 passcodeminspecialcharacters = 0; |
158 passcodeminspecialcharacters = 0; |
220 |
159 |
221 if ( config.Get( (RTerminalControl3rdPartySession::EPasscodeDisallowSimple), |
160 if ( config.Get( (RTerminalControl3rdPartySession::EPasscodeDisallowSimple), |
222 passcodedisallowsimple ) != KErrNone ) |
161 passcodedisallowsimple ) != KErrNone ) |
223 passcodedisallowsimple = EFalse; |
162 passcodedisallowsimple = EFalse; |
224 |
163 Dprint( ( _L( "CSCPPatternPlugin :: HandleEventL): EPasscodeMinLength :%d, EPasscodeMaxLength :%d, "), passcodeminlength,passcodemaxlength ) ); |
|
164 Dprint( ( _L( "CSCPPatternPlugin :: HandleEventL): EPasscodeMaxRepeatedCharacters :%d, EPasscodeRequireCharsAndNumbers :%d"), passcodemaxrepeatedcharacters,passcoderequirecharsandnumbers ) ); |
|
165 Dprint( ( _L( "CSCPPatternPlugin :: HandleEventL): EPasscodeRequireUpperAndLower :%d,minspecialcharacters :%d "), passcoderequireupperandlower ,passcodeminspecialcharacters) ); |
|
166 Dprint( ( _L( "CSCPPatternPlugin :: HandleEventL): EPasscodeConsecutiveNumbers :%d, EPasscodeDisallowSimple :%d, "), passcodeconsecutivenumbers,passcodeminspecialcharacters ) ); |
225 // Get the password from the paramObject |
167 // Get the password from the paramObject |
226 TBuf<KSCPPasscodeMaxLength> password; |
168 TBuf<KSCPPasscodeMaxLength> password; |
227 if ( aParam.Get( KSCPParamPassword, password ) != KErrNone ) |
169 if ( aParam.Get( KSCPParamPassword, password ) != KErrNone ) |
228 { |
170 { |
229 // Nothing to do anymore |
171 // Nothing to do anymore |
230 break; |
172 break; |
231 } |
173 } |
232 |
174 |
233 // The first rule is to check if securitycode has any |
175 // The first rule is to check if securitycode has any |
234 // forbidden chars, like WhiteSpace etc... |
176 // forbidden chars, like WhiteSpace etc... |
235 // If so, there is a problem >> KErrArgument |
177 // If so, there is a problem >> KErrArgument |
236 for (TInt c1=0; c1 < password.Length(); c1++) |
178 for (TInt c1=0; c1 < password.Length(); c1++) |
237 { |
179 { |
238 TChar ch = static_cast<TChar>( password[c1] ); |
180 TChar ch = static_cast<TChar>( password[c1] ); |
239 TChar::TCategory chCat = ch.GetCategory(); |
181 TChar::TCategory chCat = ch.GetCategory(); |
240 if ( ch.IsSpace() ) |
182 if ( ch.IsSpace() ) |
241 { |
183 { |
242 TRAPD( err, retParams = CSCPParamObject::NewL() ); |
184 aOutParam.Set( KSCPParamStatus, KErrArgument ); |
243 if ( err == KErrNone ) |
|
244 { |
|
245 retParams->Set( KSCPParamStatus, KErrArgument ); |
|
246 } |
|
247 |
|
248 argumentError = ETrue; |
185 argumentError = ETrue; |
249 break; |
186 break; |
250 } |
187 } |
251 } |
188 } |
252 |
189 |
262 passcoderequirecharsandnumbers || |
199 passcoderequirecharsandnumbers || |
263 passcodeconsecutivenumbers || |
200 passcodeconsecutivenumbers || |
264 passcodeminspecialcharacters != 0 || |
201 passcodeminspecialcharacters != 0 || |
265 passcodedisallowsimple) |
202 passcodedisallowsimple) |
266 { |
203 { |
267 // Get the filesystem for Resource |
|
268 // If fail, bail out |
|
269 TInt errgGR = GetResource(); |
|
270 if (errgGR != KErrNone) |
|
271 { |
|
272 errRaised = ETrue; |
|
273 break; // Break out |
|
274 } |
|
275 |
|
276 // Declare the Check flags |
204 // Declare the Check flags |
277 TBool istoosimilar = EFalse; |
205 TBool istoosimilar = EFalse; |
278 TBool consecutively = EFalse; |
206 TBool consecutively = EFalse; |
279 TBool consecutivechars = ETrue; |
207 TBool consecutivechars = ETrue; |
280 TBool singlerepeat = ETrue; |
208 TBool singlerepeat = ETrue; |
284 TInt upperCount = 0; // for passcoderequireupperandlower |
212 TInt upperCount = 0; // for passcoderequireupperandlower |
285 TInt alphaCount = 0; // for passcoderequirecharsandnumbers |
213 TInt alphaCount = 0; // for passcoderequirecharsandnumbers |
286 TInt specialCount = 0; // for passcodeminspecialcharacters |
214 TInt specialCount = 0; // for passcodeminspecialcharacters |
287 TChar temp = '1'; |
215 TChar temp = '1'; |
288 |
216 |
289 |
|
290 // Prompt buf, iNote can show only 97 chars, |
|
291 // without ... markings. |
|
292 HBufC* hbuf = NULL; |
|
293 |
|
294 // Check for required check or not. |
217 // Check for required check or not. |
295 if (passcodeminlength != 0) |
218 if (passcodeminlength != 0) |
296 { |
219 { |
297 // check for Min lenght |
220 // check for Min lenght |
298 if ( password.Length() < passcodeminlength ) |
221 if ( password.Length() < passcodeminlength ) |
299 { |
222 { |
|
223 //koya: return error code to SecUi |
|
224 Dprint ( ( _L( "EDeviceLockMinlength Failed" ) ) ); |
|
225 aOutParam.AddtoFailedPolices(EDeviceLockMinlength); |
300 isInvalid = ETrue; |
226 isInvalid = ETrue; |
301 TRAP_IGNORE( |
|
302 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_MIN, &passcodeminlength ) |
|
303 ); |
|
304 } |
227 } |
305 } |
228 |
306 |
|
307 if (!hbuf) |
|
308 { |
|
309 // Check for required check or not. |
229 // Check for required check or not. |
310 if (passcodemaxlength!=0) |
|
311 { |
|
312 // Check for Max Lenght |
230 // Check for Max Lenght |
313 if ( password.Length() > passcodemaxlength ) |
231 else if ( password.Length() > passcodemaxlength ) |
314 { |
232 { |
|
233 Dprint ( ( _L( "EDeviceLockMaxlength Failed" ) ) ); |
|
234 aOutParam.AddtoFailedPolices(EDeviceLockMaxlength); |
315 isInvalid = ETrue; |
235 isInvalid = ETrue; |
316 TRAP_IGNORE( |
|
317 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_MAX, &passcodemaxlength ); |
|
318 ); |
|
319 } |
|
320 } |
236 } |
321 } |
237 } |
322 |
238 |
323 if (!hbuf) |
|
324 { |
|
325 // Check for required check or not. |
239 // Check for required check or not. |
326 if ( passcodemaxrepeatedcharacters != 0 ) |
240 if ( passcodemaxrepeatedcharacters != 0 ) |
327 { |
241 { |
328 // Check for TooManySameChars |
242 // Check for TooManySameChars |
329 TRAPD( err, istoosimilar = TooManySameCharsL(password,passcodemaxrepeatedcharacters) ); |
243 TRAPD( err, istoosimilar = TooManySameCharsL(password,passcodemaxrepeatedcharacters) ); |
330 if ( ( err == KErrNone ) && ( istoosimilar ) ) |
244 if ( ( err == KErrNone ) && ( istoosimilar ) ) |
331 { |
245 { |
332 if ( passcodemaxrepeatedcharacters > 1 ) |
246 Dprint ( ( _L( "EDeviceLockAllowedMaxRepeatedChars Failed" ) ) ); |
333 { |
247 aOutParam.AddtoFailedPolices(EDeviceLockAllowedMaxRepeatedChars); |
334 isInvalid = ETrue; |
248 isInvalid = ETrue; |
335 TRAP_IGNORE( |
249 } |
336 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_REPEATED, |
|
337 &passcodemaxrepeatedcharacters ); |
|
338 ); |
|
339 } |
|
340 else // passcodemaxrepeatedcharacters == 1 |
|
341 { |
|
342 isInvalid = ETrue; |
|
343 TRAP_IGNORE( |
|
344 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_REPEATED_ONCE ); |
|
345 ); |
|
346 } |
|
347 } |
|
348 } |
250 } |
349 } |
|
350 |
251 |
351 if (!hbuf) |
|
352 { |
|
353 // Check for Alphadigit |
252 // Check for Alphadigit |
354 if ( passcoderequirecharsandnumbers) |
253 if ( passcoderequirecharsandnumbers) |
355 { |
254 { |
356 for (TInt adcounter=0; adcounter < password.Length(); adcounter++) |
255 for (TInt adcounter=0; adcounter < password.Length(); adcounter++) |
357 { |
256 { |
363 } |
262 } |
364 |
263 |
365 if (digitCount >= password.Length() || alphaCount >= password.Length() |
264 if (digitCount >= password.Length() || alphaCount >= password.Length() |
366 || digitCount == 0 || alphaCount == 0 ) |
265 || digitCount == 0 || alphaCount == 0 ) |
367 { |
266 { |
368 isInvalid = ETrue; |
267 Dprint ( ( _L( "EDeviceLockRequireCharsAndNumbers Failed" ) ) ); |
369 TRAP_IGNORE( |
268 aOutParam.AddtoFailedPolices(EDeviceLockRequireCharsAndNumbers); |
370 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_LETTERS_NUMBERS ); |
269 isInvalid = ETrue; |
371 ); |
|
372 } |
270 } |
373 } // End of Alphadigit Check |
271 } // End of Alphadigit Check |
374 } |
|
375 |
272 |
376 |
273 |
377 if (!hbuf) |
|
378 { |
|
379 // passcodeconsecutivenumbers |
274 // passcodeconsecutivenumbers |
380 if (passcodeconsecutivenumbers) |
275 if (passcodeconsecutivenumbers) |
381 { |
276 { |
382 consecutively = consecutivelyCheck(password); |
277 consecutively = consecutivelyCheck(password); |
383 |
278 |
384 if ( consecutively ) |
279 if ( consecutively ) |
385 { |
280 { |
|
281 Dprint ( ( _L( "EDeviceLockConsecutiveNumbers Failed" ) ) ); |
|
282 aOutParam.AddtoFailedPolices(EDeviceLockConsecutiveNumbers); |
386 isInvalid = ETrue; |
283 isInvalid = ETrue; |
387 TRAP_IGNORE( |
|
388 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_CONSECUTIVE ); |
|
389 ); |
|
390 } |
284 } |
391 } |
285 } |
392 } |
|
393 |
|
394 /* |
|
395 if (!hbuf) |
|
396 { |
|
397 // Check for required check or not. |
|
398 if (passcoderequireupperandlower) |
|
399 { |
|
400 // Count the IsDigits first and miinus them from the lenghth! |
|
401 // Count the possible NUM's count first! |
|
402 for (TInt numcounter=0; numcounter < password.Length(); numcounter++) |
|
403 { |
|
404 if ( static_cast<TChar>( password[numcounter] ).IsDigit() ) |
|
405 numberCount++; |
|
406 } |
|
407 |
|
408 // Check for Caps, both |
|
409 for (TInt capscounter=0; capscounter < password.Length(); capscounter++) |
|
410 { |
|
411 if ( static_cast<TChar>( password[capscounter] ).IsUpper() ) |
|
412 upperCount++; |
|
413 |
|
414 if ( static_cast<TChar>( password[capscounter] ).IsLower() ) |
|
415 lowerCount++; |
|
416 } |
|
417 |
|
418 if (upperCount >= (password.Length()-numberCount ) ) |
|
419 isallcaps = ETrue; |
|
420 |
|
421 if (lowerCount >= (password.Length() -numberCount) ) |
|
422 isallsmall = ETrue; |
|
423 |
|
424 if (isallsmall || isallcaps) |
|
425 { |
|
426 isInvalid = ETrue; |
|
427 TRAP_IGNORE( |
|
428 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_UPPER_LOWER ); |
|
429 ); |
|
430 } |
|
431 } // End of Caps check |
|
432 } |
|
433 */ |
|
434 |
|
435 if (!hbuf) |
|
436 { |
|
437 // Check for required check or not. |
286 // Check for required check or not. |
438 if (passcoderequireupperandlower) |
287 if (passcoderequireupperandlower) |
439 { |
288 { |
440 for (TInt counter=0; counter < password.Length(); counter++) |
289 for (TInt counter=0; counter < password.Length(); counter++) |
441 { |
290 { |
472 specialCount++; |
314 specialCount++; |
473 } |
315 } |
474 |
316 |
475 if ( specialCount < passcodeminspecialcharacters ) |
317 if ( specialCount < passcodeminspecialcharacters ) |
476 { |
318 { |
|
319 //koya: return error code to SecUi |
|
320 Dprint ( ( _L( "EDeviceLockMinSpecialCharacters Failed" ) ) ); |
|
321 aOutParam.AddtoFailedPolices(EDeviceLockMinSpecialCharacters); |
477 isInvalid = ETrue; |
322 isInvalid = ETrue; |
478 TRAP_IGNORE( |
323 } |
479 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_MIN_SPECIAL_CHARS, |
|
480 &passcodeminspecialcharacters ); |
|
481 ); |
|
482 } |
|
483 |
|
484 } |
324 } |
485 } |
325 |
486 |
|
487 if (!hbuf) |
|
488 { |
|
489 if (passcodedisallowsimple) |
326 if (passcodedisallowsimple) |
490 { |
327 { |
491 for (TInt counter=0; counter< (password.Length()-1); counter++) |
328 for (TInt counter=0; counter< (password.Length()-1); counter++) |
492 { |
329 { |
493 if ( (static_cast<TChar>(password[counter])) != (static_cast<TChar>(password[counter+1])) ) |
330 if ( (static_cast<TChar>(password[counter])) != (static_cast<TChar>(password[counter+1])) ) |
496 break; |
333 break; |
497 } |
334 } |
498 } |
335 } |
499 if (singlerepeat) |
336 if (singlerepeat) |
500 { |
337 { |
|
338 //koya: return error code to SecUi |
|
339 Dprint ( ( _L( "EDeviceLockSingleCharRepeatNotAllowed Failed" ) ) ); |
|
340 aOutParam.AddtoFailedPolices(EDeviceLockSingleCharRepeatNotAllowed); |
501 isInvalid = ETrue; |
341 isInvalid = ETrue; |
502 TRAP_IGNORE( |
|
503 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_SINGLE_REPEAT ) ); |
|
504 } |
342 } |
505 if (!hbuf) |
343 |
506 { |
|
507 for (TInt counter=0; counter< (password.Length()-1); counter++) |
344 for (TInt counter=0; counter< (password.Length()-1); counter++) |
508 { |
345 { |
509 //The consecutivity to be checked with only Alphanumeric characters. |
346 //The consecutivity to be checked with only Alphanumeric characters. |
510 //The check is being made for only the increasing order. Decreasing order is left for |
347 //The check is being made for only the increasing order. Decreasing order is left for |
511 //future implementation if needed. Right now it is left out as this will hit the |
348 //future implementation if needed. Right now it is left out as this will hit the |
525 break; |
362 break; |
526 } |
363 } |
527 } |
364 } |
528 if (consecutivechars) |
365 if (consecutivechars) |
529 { |
366 { |
|
367 //koya: return error code to SecUi |
|
368 Dprint ( ( _L( "EDevicelockConsecutiveCharsNotAllowed Failed" ) ) ); |
|
369 aOutParam.AddtoFailedPolices(EDevicelockConsecutiveCharsNotAllowed); |
530 isInvalid = ETrue; |
370 isInvalid = ETrue; |
531 TRAP_IGNORE( |
|
532 hbuf = LoadAndFormatResL( R_SET_SEC_CODE_CONSECUTIVE_CHARS ) ); |
|
533 } |
371 } |
534 } |
372 } |
535 } |
|
536 } |
|
537 |
|
538 |
|
539 if ( isInvalid ) |
373 if ( isInvalid ) |
540 { |
374 { |
541 // Create the result-object to return |
375 aOutParam.Set( KSCPParamStatus, KErrSCPInvalidCode ); |
542 TRAPD( err, retParams = CSCPParamObject::NewL() ); |
376 } |
543 |
|
544 if ( err == KErrNone ) |
|
545 { |
|
546 retParams->Set( KSCPParamStatus, KErrSCPInvalidCode ); |
|
547 retParams->Set( KSCPParamAction, KSCPActionShowUI ); |
|
548 retParams->Set( KSCPParamUIMode, KSCPUINote ); |
|
549 |
|
550 if ( hbuf != NULL ) |
|
551 { |
|
552 FormatResourceString(*hbuf); |
|
553 TPtr ptr = hbuf->Des(); |
|
554 retParams->Set( KSCPParamPromptText, ptr ); |
|
555 delete hbuf; |
|
556 } |
|
557 } |
|
558 } |
|
559 |
377 |
560 } // end of All Zero check |
378 } // end of All Zero check |
561 // All params were zero! no check! |
|
562 else |
|
563 { |
|
564 retParams = NULL; |
|
565 } |
|
566 |
|
567 break; |
379 break; |
568 } // KSCPEventValidate |
380 } // KSCPEventValidate |
569 |
381 |
570 case ( KSCPEventConfigurationQuery ): |
382 case ( KSCPEventConfigurationQuery ): |
571 { |
383 { |
585 || paramID == (RTerminalControl3rdPartySession::EPasscodeMaxRepeatedCharacters) |
397 || paramID == (RTerminalControl3rdPartySession::EPasscodeMaxRepeatedCharacters) |
586 || paramID == (RTerminalControl3rdPartySession::EPasscodeConsecutiveNumbers ) |
398 || paramID == (RTerminalControl3rdPartySession::EPasscodeConsecutiveNumbers ) |
587 || paramID == (RTerminalControl3rdPartySession::EPasscodeMinSpecialCharacters) |
399 || paramID == (RTerminalControl3rdPartySession::EPasscodeMinSpecialCharacters) |
588 || paramID == (RTerminalControl3rdPartySession::EPasscodeDisallowSimple)) |
400 || paramID == (RTerminalControl3rdPartySession::EPasscodeDisallowSimple)) |
589 { |
401 { |
590 |
|
591 // OK, we're interested, check that the value is valid |
|
592 TRAPD( err, retParams = CSCPParamObject::NewL() ); |
|
593 |
|
594 if ( err != KErrNone ) |
|
595 { |
|
596 break; // Fatal, cannot create paramObject |
|
597 } |
|
598 |
|
599 // All of our params are TInts |
402 // All of our params are TInts |
600 TInt paramValue; |
403 TInt paramValue; |
601 if ( aParam.Get( KSCPParamValue, paramValue ) != KErrNone ) |
404 if ( aParam.Get( KSCPParamValue, paramValue ) != KErrNone ) |
602 { |
405 { |
603 retParams->Set( KSCPParamStatus, KErrGeneral ); |
406 aOutParam.Set( KSCPParamStatus, KErrArgument ); |
604 break; |
407 break; |
605 } |
408 } |
606 |
409 |
607 TInt retStatus = KErrNone; |
410 TInt retStatus = KErrNone; |
608 switch ( paramID ) |
411 switch ( paramID ) |
673 retStatus = KErrArgument; |
476 retStatus = KErrArgument; |
674 } |
477 } |
675 break; |
478 break; |
676 } |
479 } |
677 |
480 |
678 retParams->Set( KSCPParamStatus, retStatus ); |
481 aOutParam.Set( KSCPParamStatus, retStatus ); |
679 } |
482 } |
680 else |
|
681 { |
|
682 retParams = NULL; |
|
683 } |
|
684 |
|
685 break; |
483 break; |
686 } //KSCPEventConfigurationQuery |
484 } //KSCPEventConfigurationQuery |
687 } // switch ( aID ) |
485 } // switch ( aID ) |
688 |
|
689 // Check if Any errors were raised and handle it |
|
690 if (errRaised) |
|
691 { |
|
692 if ( retParams != NULL ) |
|
693 { |
|
694 delete retParams; |
|
695 } |
|
696 retParams = NULL; |
|
697 } |
|
698 |
|
699 // The caller will own this pointer from now on |
486 // The caller will own this pointer from now on |
700 return retParams; |
|
701 } |
487 } |
702 |
488 |
703 // ---------------------------------------------------------------------------- |
489 // ---------------------------------------------------------------------------- |
704 // CSCPPatternPlugin::SetEventHandler |
490 // CSCPPatternPlugin::SetEventHandler |
705 // |
491 // |
814 } |
600 } |
815 |
601 |
816 return charTooManyInRow; |
602 return charTooManyInRow; |
817 } |
603 } |
818 |
604 |
819 |
|
820 // ---------------------------------------------------------------------------- |
|
821 // CSCPPatternPlugin::LoadAndFormatResL |
|
822 // Load the given resouce, and format the string according to the TInt parameters |
|
823 // if given. |
|
824 // |
|
825 // Status : Approved |
|
826 // ---------------------------------------------------------------------------- |
|
827 // |
|
828 HBufC* CSCPPatternPlugin::LoadAndFormatResL( TInt aResId, TInt* aParam1, TInt* aParam2 ) |
|
829 { |
|
830 HBufC16* resource = NULL; |
|
831 HBufC* hbuf = NULL; |
|
832 |
|
833 resource = LoadResourceLC( aResId ); |
|
834 FormatResourceString(*resource); |
|
835 TInt allocLen = 0; |
|
836 if ( aParam1 != NULL ) |
|
837 { |
|
838 allocLen += KSCPMaxIntLength; |
|
839 } |
|
840 if ( aParam2 != NULL ) |
|
841 { |
|
842 allocLen += KSCPMaxIntLength; |
|
843 } |
|
844 |
|
845 hbuf = HBufC::NewL( resource->Length() + allocLen ); |
|
846 |
|
847 if ( ( aParam1 == NULL ) && ( aParam2 == NULL ) ) |
|
848 { |
|
849 hbuf->Des().Copy( resource->Des() ); |
|
850 } |
|
851 else |
|
852 { |
|
853 if ( aParam1 == NULL ) |
|
854 { |
|
855 hbuf->Des().Format( resource->Des(), *aParam2 ); |
|
856 } |
|
857 else if ( aParam2 == NULL ) |
|
858 { |
|
859 hbuf->Des().Format(resource->Des(), *aParam1 ); |
|
860 } |
|
861 else |
|
862 { |
|
863 hbuf->Des().Format(resource->Des(), *aParam1, *aParam2 ); |
|
864 } |
|
865 } |
|
866 |
|
867 CleanupStack::PopAndDestroy( resource ); |
|
868 return hbuf; |
|
869 } |
|
870 |
|
871 // ---------------------------------------------------------------------------- |
|
872 // CSCPPatternPlugin::FormatResourceString |
|
873 // The buffer that is passed is formatted to have only %i as a format specifier instead of %N or %0N etc. |
|
874 // |
|
875 // Status : Approved |
|
876 // ---------------------------------------------------------------------------- |
|
877 // |
|
878 void CSCPPatternPlugin::FormatResourceString(HBufC16 &aResStr) |
|
879 { |
|
880 TInt pos = 0; |
|
881 TInt flag = 0; |
|
882 TPtr16 bufPtr = aResStr.Des(); |
|
883 _LIT (mess1, "%N"); |
|
884 _LIT (mess2, "%i"); |
|
885 _LIT (mess3, "%0N"); |
|
886 _LIT (mess4, "%1N"); |
|
887 |
|
888 while ((pos = bufPtr.Find(mess1)) !=KErrNotFound) |
|
889 { |
|
890 bufPtr.Replace(pos,2,mess2); |
|
891 flag = 1; |
|
892 break; |
|
893 } |
|
894 |
|
895 if(flag == 0) |
|
896 { |
|
897 while ((pos = bufPtr.Find(mess3)) != KErrNotFound) |
|
898 { |
|
899 bufPtr.Replace(pos,3,mess2); |
|
900 } |
|
901 |
|
902 while ((pos = bufPtr.Find(mess4)) != KErrNotFound) |
|
903 { |
|
904 bufPtr.Replace(pos,3,mess2); |
|
905 } |
|
906 } |
|
907 } |
|
908 |
|
909 // End of File |
605 // End of File |